Math & Science ⇒ newcommand superscript
newcommand superscript
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!
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- Stefan Kottwitz
- Site Admin
- Posts: 10359
- Joined: Mon Mar 10, 2008 9:44 pm
newcommand superscript
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
newcommand superscript
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
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}
-- Zapp Brannigan, Futurama (season 1, episode 4)