# Tag Info

229

You should not use math, when it is normal text. Use \textsuperscript instead: 2\textsuperscript{nd}. You can also define a shortcut for this, e.g. \newcommand{\ts}{\textsuperscript} Then you could use 2\ts{nd} in the text. Edit: An even nicer solution is to load the package nth with the option super and use the \nth command: \nth{1}, \nth{2}, \nth{3}, ...

207

You can use \textsuperscript{th}. It sets its contents in text mode and can be used in math or text mode.

62

\documentclass{article} \def\powertower#1#2{#1\ifnum#2>1 ^{\powertower{#1}{\numexpr#2-1\relax}}\fi} \begin{document} $\powertower{x}{100}$ \end{document}

58

I guess the quickest and easiest solution is to simply write "2nd", "3rd", etc. Superscripts aren't really necessary.

45

An alternative to nth package is fmtcount. In this case the command is \ordinalnum. By default the ordinal is formatted as superscript, but this is optional, as it is also in nth: \usepackage{fmtcount} % equivalent to \usepackage[super]{nth} \usepackage[level]{fmtcount} % equivalent to \usepackage{nth} But there are some advantages over nth: Limited ...

35

It is not clear what you want the output to be $y\in[0,1]^{d\prime}$ the \prime is in the superscript along with d. If you want the prime to be on d then just use $y\in[0,1]^{d'}$ which is equivalent to $y\in[0,1]^{d^{\prime}}$

33

\documentclass[12pt]{article} \begin{document} $x^{x^{x^{x^{x^{x^{x^{x^{x^x}}}}}}}}$ \end{document}

27

I dedicate this code to Sean. :) Long live expl3! :) \documentclass{article} \usepackage{expl3} \usepackage{xparse} \ExplSyntaxOn \cs_new:Npn \paulo_epicrecursion:nn #1 #2 { #1^{ \int_compare:nTF { #2 > 1 } { \paulo_epicrecursion:nn { #1 } { \int_eval:n { #2 - 1 } } } { #1 } } } \NewDocumentCommand{ \powertower } { m m } { ...

27

Here's a shorter version with LaTeX3 functions: \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{ \powertower } { m m } { #1 \prg_replicate:nn { #2 - 1 } { ^\c_group_begin_token #1 } \prg_replicate:nn { #2 - 1 } { \c_group_end_token } } \ExplSyntaxOff \begin{document} $\powertower{x}{10}$ \end{document} ...

24

The following image shows the boxes of each character as seen by tex, for each of the cases in egreg's answer. You can clearly see how the boxes of the parenthesis are "too wide", which causes the exponent to be too far. In addition, using egreg's suggestion (\biggl() removes unwanted space before the box of the left parenthesis. Note For generating the ...

23

I think you can justly regard this strange behaviour as kind of a bug in TeX's sub- and superscript positioning algorithm; it doesn't make sense that both the sub- and the superscript are raised. See below for some suggestions on how to fix the problem. At the end I offer a new positioning algorithm, and I compare it with the old algorithm. (Sorry for the ...

23

' in math mode expands to ^\prime, so your code is equivalent to T^{\prime}_{...}^{...}, which explains the error you get. You can either swap sub- and superscripts to be T'^{...}_{...} (' is defined in a way that merges it with an adjacent superscript), or use \prime inside the superscript as suggested in Werner's answer, so both ...

23

For 99% of applications, Werner's answer is good enough. But since Marienplatz has offered a bounty, there presumably is interest in other ways to do this. So here, I show it done with a stack over a null entry. My preamble definition (output on the second line) appears to give the exact same result as \textsuperscript (output on the first line). But ...

22

Put braces around the entire part that you want superscripted: $8^{(a - b)}$

22

If you are using ConTeXt MkIV, you can even imitate the automatic conversion of MS Word: \usemodule[translate] \translateinput[2nd][2\high{nd}] \enableinputtranslation \starttext On the 2nd of November \unknown \stoptext This will translate all 2nd into 2\high{nd}.

22

It is better to use the bm package for bold math italics, as it gets the positioning of accents and the spacing for sub- and superscripts right. The bm package will also redefine \boldsymbol, so you don't have to replace all \boldsymbol with \bm throughout the document. Therefore, make sure to load bm after amsbsy, which is loaded by amsmath. Still, I ...

21

You have to supply a "fake" object for TeX to put indices to: ${}^1_2X^3_4$ However, for chemistry typesetting you should use one of the specialized packages, such as mhchem. This example is taken from mhchem documentation: \ce{^{227}_{90}Th+} It will typeset the symbol for a positive Thorium ion with a charge of 90 and atomic mass of 227.

21

This is a case where manual adjustment is needed. The coloring has nothing to do with it. It has to do with the shape of the parenthesis, which is quite wide. I'd recommend using \biggl and \biggr, in particular because of the coefficient in front of the open parenthesis. \documentclass{article} \usepackage{xcolor} \begin{document} ...

20

When TeX assembles the various "atoms" of a formula into a whole (a "molecule", if you will), it mainly keeps track of each atom's enclosing rectangular "box", and it arranges the boxes horizontally and vertically according to the rules listed in Appendix G of the TeXbook. In the process of arranging the boxes, TeX doesn't actually "know" what's inside each ...

18

LaTeX knows eight math styles, four main ones and four secondary. They are called \displaystyle, \textstyle, \scriptstyle and \scriptscriptstyle. In general TeX chooses automatically the right style. In some constructions it uses the secondary style, frequently called the “cramped version”. For instance, when typesetting a fraction when the current style is ...

18

What? afraid of going beyond 255? not me! This was obtained as $\epictower{x}{600}$. I must point out that this reproduces exactly what TeX would have done (were it not for the limitation to 255 group levels) inclusive of what appears as a quite odd feature regarding extra horizontal spaces; these spaces may be seen from using \fboxes, let me demonstrate ...

18

You can insert \prime symbol as part of the superscript ^{...}, rather than having "two superscripts": \documentclass{article} \begin{document} $T_{\alpha_{1}\alpha_{2}\ldots\alpha_{n}}^{\prime\mu_{1}\mu_{2}\ldots\mu_{m}}$ \end{document}

18

in latex.ltx there is a line \let\sp=^ so there is an alternate command, \sp, that will produce a superscript. @egreg notes in a comment that this isn't available for mathjax, so it's apparently not "portable". however, david cervone (mathjax lead developer) says that MathJax does handle \let\sp=^ [...]. MathJax's \let only works to set a control ...

17

I don't really know why the result is bad; I suspect it has to do with the width of the letter. I wouldn't use such a notation, but that's a personal opinion. With \vec{o}^{\,t} the superscript is moved a bit to the right. One might perhaps let TeX do some computations in order that the shift to the right of the superscript is automatic.

17

Let us make things complicated. \documentclass{article} \usepackage{calc} \begin{document} $L^{2,3/4,5/6}_{1,\makebox[\widthof{3/4}]{$\scriptstyle 2,$}\makebox[\widthof{5/6}]{$\scriptstyle 3\hphantom{,}$}}$ \end{document} I agree with Benjamin's comments. Hence an attempt to increase the spaces. \documentclass{article} \usepackage{calc} ...

16

If you are typesetting chemical formula, look up the mhchem package. This allows you to typeset chemical formulae easily. For example: \ce{CO2} has the "2" as a subscript. Neat. \documentclass{article} \usepackage{mhchem} \begin{document} \ce{H2SO4} \end{document} Yields:

16

The text asterisk is raised, while the math asterisk is used for denoting an operation. You can use \mbox{*} or \text{*} (if you load amsmath). However, in general $Q^{*}$ is preferred. You can get the behavior automatically: \documentclass{article} \usepackage{amsmath} %%% magic code starts \mathcode*=\string"8000 \begingroup \catcode*=\active ...

15

you're using the right quote inside the superscript. that will make the primes too small. you should use \prime instead. is this more like what you want? this was produced with $f^{\prime\prime\prime\cdots\prime\prime}$ explanation: the right quote is a shorthand for $^\prime$, and special treatment is given to multiple right quotes so that they ...

15

The first one might not be a good idea, like you already noticed, because op could be mistaken for o⋅p. But I don’t think the other options are correct either. \operatorname{op} puts correct spacing around keywords, when used as mathematical operators. That is not the case here. \text{op}, at least syntactical, means prose. But you are trying to display ...

14

Here are several methods for showing the ^ character -- in math mode, text mode, and "verbatim" ("monospaced font") mode. (The third text mode variant and the verbatim variant courtesy of cmhughes and Johannes_B...) \documentclass{article} \begin{document} $y\string^2$ --- math mode y\string^2 --- text mode, variant 1 (same as math mode) y\^{}2 --- ...

Only top voted, non community-wiki answers of a minimum length are eligible