26

I was writing this formula:

$$^gp = ^gR^l_l+^go_l$$

$g$ are superscripts, but they should be close to other letters. How can I solve this problem?

3

5 Answers 5

26

For a quick and dirty solution, try putting an empty group {} before the ^ symbol.

\documentclass{article}
\begin{document}
\[
^gp = {}^gR^l_l+{}^go_l
\]
\end{document}

For a better method, check out the mathtools package, which provides the \prescript command.

2
  • This prevents the superscripts from being appended to the symbols they occur before. Of course it has no effect on the first superscript. Since italicized letters slant to the right it is reasonable to want the superscripts pushed to the right as well, further than what this answer provides. For this use \! as in the answer I've posted.
    – j0equ1nn
    Feb 4, 2016 at 22:34
  • Yes, this also fails to double-raise superscripts the way \left(x^y\right)^z does. Using {}^z\left({}^yx\right) gives us z at the same height as y. Aug 15, 2017 at 17:02
10

In addition to the other solutions already presented, here is another one:

The (super-small) leftidx package provides left and right super- and subscripts to be typeset by means of \leftidx that is defined as follows:

\newcommand\leftidx[3]{%
  {\vphantom{#2}}#1#2#3%
}

It therefore provides

\leftidx{<left indexes>}{<object>}{<right indexes>}

where <left indexes> and <right indexes> are similar in context to regular super and subscript usage. Here's an example:

\documentclass{article}
\usepackage{leftidx}% http://ctan.org/pkg/leftidx
\begin{document}
\[\leftidx{^g}{p}{} = \leftidx{^g}{R}{^l_l}+\leftidx{^g}{o}{_l}\]
\end{document}

Leftidx package example

5

Regardless of how you are implementing mathmode, this will move the superscripts closer to what they precede:

^g\!p = {}^g\!R^l_l+{}^g\!o_l

This will work inside single or double $, inside align, etc. If the issue was simply that you didn't want the superscripts appended to the symbols before them, then you have your answer already by inserting the {}. Personally I have sometimes wanted the superscripts closer even beyond this, to compensate for italicized letters slanting to the right. The

\!

simply reduces horizontal space.

1
  • I ran into this independently, wanting closer superscripts since italicized letters slant to the right. This is more apparent though with capital letters. Look at what happens for instance with $^gS$ versus $^g\!S$.
    – j0equ1nn
    Feb 4, 2016 at 22:36
3

The first solution suggested by @Ian Thompson may have some alignment issues (depending on what you actually have as super-/subscripts). But there again, a work-around is:

\begin{equation*}
{}^{14}_{6}\text{C}
\qquad \text{versus} \qquad
{}^{14}_{\phantom{1}6}\text{C}
\end{equation*}

NOTE: Example taken from The Not So Short Introduction to LaTeX2e (page 70).

1

I have a relatively effective solution that I've been using, although it is considerably easier by setting a shortcut (I use the Equation Editor in MS Word, which is based off TeX/LaTeX), in any case, what I do is use a Zero-Width Space (ZWSP - \zwsp) or Zero-Width Non-Joiner (ZWNJ - \zwnj), which are coded as follows:

\zwsp (Word)

\hskip0pt (TeX)

\hspace{0pt} (LaTeX)

\: (Groff)

\zwnj (Word)

I don't know if ZWNJ has a proper TeX/LaTeX code.

In any case, I use the auto-replace shortcut, \zw, for ZWSP, and it works well for me.

So, how I type out the ^gp=^gR^l_l+^go_l formula above is as follows:

\zw^g p = \zw^g R^l_l +\zw^g o_l

I'm not versed in actual TeX/LaTeX, so I'm an ignorant outsider, but I'm hoping my trick helps.

Not the answer you're looking for? Browse other questions tagged .