Tag Info

Hot answers tagged

172

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}, ...


100

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


60

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


50

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


40

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 ...


33

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


29

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}}$


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} ...


23

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 ...


22

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


21

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}.


21

' 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 ...


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 ...


17

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 ...


17

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 ...


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} ...


17

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.


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:


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

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 ...


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 --- ...


14

The default positions of sub and superscripts are closer to the baseline in textstyle as TeX tries to maximise the chance that the expression does not disturb the paragraph line spacing. Your first example is the standard setting for inline math, however with the larger scripts caused by the subscripting, TeX has to move them further apart. This is ...


14

Why is the vertical positioning different in the two expressions? Because in the first case you're adding subscripts and superscripts to the parenthesis, while in the second case the whole subformula is the nucleus of the math atom to which the superscript and subscript fields are added. Is there anything the LaTeX user should pay attention to to get such ...


14

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.


14

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}


14

Or what about an empty optional argument? \newcommand*\Ne[1][]{N^{e#1}} Which you can use $\Ne$ or $\Ne[T]$


14

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 ...



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