Hi there,
I would like to define a new command to make sub- and superscripts easier. I found this online, which works well:
\newcommand{\super}[1]{\ensuremath{^{\textnormal{#1}}}}
\newcommand{\sub}[1]{\ensuremath{_{\textnormal{#1}}}}
However, my normal text is 11pt and thus the sub/superscripted letters are too big for my taste. How can I define this command so it uses, say, 8pt?
Thanks!
Math & Science ⇒ newcommand superscript
NEW: TikZ book now 40% off at Amazon.com for a short time.
- Stefan Kottwitz
- Site Admin
- Posts: 10321
- Joined: Mon Mar 10, 2008 9:44 pm
newcommand superscript
Hi,
insert an appropriate font size command. To match the size LaTeX uses for subscripts choose \scriptsize, like
Btw. \textnormal prevents the italic shape which is normally used in math sub-/superscripts.
Stefan
insert an appropriate font size command. To match the size LaTeX uses for subscripts choose \scriptsize, like
Code: Select all
\newcommand{\super}[1]{\ensuremath{^{\textnormal{\scriptsize #1}}}}
Stefan
LaTeX.org admin
newcommand superscript
Sweet, thanks!

Which is exactly why I'm using it...\textnormal prevents the italic shape which is normally used in math sub-/superscripts.

- svend_tveskaeg
- Posts: 478
- Joined: Sun Jul 12, 2009 5:31 am
newcommand superscript
@dax42:
Morten Høgholm once came up with an elegant solution on a Danish mailing list:
I hope this is (somewhat) what you are looking for.
Morten Høgholm once came up with an elegant solution on a Danish mailing list:
Code: Select all
\documentclass[a4paper,12pt]{article}
\usepackage{mathtools}
\makeatletter
\newcommand\textupperscript[2]{%
\@textupperscript{\selectfont#1}{\selectfont#2}
}
\def\@textupperscript#1#2{%
{\m@th\ensuremath{%
^{\mbox{\fontsize\sf@size\z@#1}}
_{\mbox{\fontsize\sf@size\z@#2}}
}}
}
\def\@super{^}
\def\@sub{_}
\catcode`^\active
\catcode`_\active
\def\@super@sub#1_#2{\textbothscript{#1}{#2}}
\def\@sub@super#1^#2{\textbothscript{#2}{#1}}
\def\@@super#1{\@ifnextchar_{\@super@sub{#1}}{\textsuperscript{#1}}}
\def\@@sub#1{\@ifnextchar^{\@sub@super{#1}}{\textsubscript{#1}}}
\def^{\let\@next\relax\ifmmode\@super\else\let\@next\@@super\fi\@next}
\def_{\let\@next\relax\ifmmode\@sub\else\let\@next\@@sub\fi\@next}
\makeatother
\begin{document}
Something:
\begin{equation*}
\Psi\textupperscript{Horse}{Fish}(x)
\end{equation*}
\end{document}
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
-- Zapp Brannigan, Futurama (season 1, episode 4)