27

For some reason, I need to write a “minus” sign as a subscript on some symbols, but if I simply write $\Pi_{-}$ the result looks kind of odd. I've found that $\Pi{\scriptstyle -}$ looks reasonably better. But if want to add this “minus” subscript and a prime, then I get an unwanted space between the prime and the fake subscript.

alt text

So, is there a way to simply raise the subscript a bit?

Note: I've considered writing something like $\Pi\mathrlap{'}{\scriptstyle -}$, which actually produces something like I want. But then it is difficult to define a macro such that I can write \Neg{\Pi} and \Neg{\Pi'} to add the “subscript minus” on the symbol I supply as an argument.

3 Answers 3

50

You can put {\raisebox{2pt}{$\scriptstyle-$}} in the subscript. You may need to play with \mathchoice if you want a solution that will work in subsubscripts as well.

Edit: Or better yet, \mathpalette:

\makeatletter
\newcommand{\raisemath}[1]{\mathpalette{\raisem@th{#1}}}
\newcommand{\raisem@th}[3]{\raisebox{#1}{$#2#3$}}
\makeatother

and use $\Pi_{\raisemath{2pt}{-}}$.

2
  • 1
    I went with this answer because it has the least trickery and works fine to define other macros. Commented Nov 11, 2010 at 22:39
  • Nearly 4 years later this and still people find this post helpful. This seems to be the best and easily "automated" solution out there. Thank you.
    – henry
    Commented Oct 15, 2014 at 19:45
9

The answer to your question depends on what behaviour of the subscript you expect. What TeX does by default is that it gives the subscript a lower position if there's also a superscript; see this question. If that's OK for you then you can use Harald's solution. If not then you can use the following hack. Beware, this \Piminus accepts ' or nothing as an argument, but nothing else.

\documentclass{article}

\newdimen\savedxvi
\newdimen\savedxvii
\makeatletter
\newcommand*\Piminus{%
    \@ifnextchar'{\print@pi'\@gobble}
                 {\print@pi\relax\relax}}
\def\print@pi#1#2{%
    \savedxvi=\fontdimen16\textfont2
    \savedxvii=\fontdimen17\textfont2
    \mbox{%
    $\fontdimen16\textfont2=0pt
     \fontdimen17\textfont2=0pt
     \Pi_{\smash-}#1$}%
    \fontdimen16\textfont2=\savedxvi
    \fontdimen17\textfont2=\savedxvii
    #2}
\makeatother

\begin{document}
$\Piminus \Piminus' \Pi_-$
\end{document}

Short explanation: \fontdimen16 is the amount the subscript is lowered when there is no superscript, \fontdimen17 is used when there is a superscript. They have to be restored since they aren't local to the group.

EDIT:

To explain a bit more: Not only are the changes of the \fontdimen parameters global, you also have to keep in mind that it's of no use to change the value of a \fontdimen parameter within one math list $ ... $ several times. Only the values valid at the end of the math list will be used for the whole list. This is the reason why in my above solution I used \mbox{$ ... $}.

Here's a slightly more elaborate version that allows multiple primes, and also e.g. '^2. It hacks into TeX's ingenious definition of '. One could also implement that \Piminus^2 works as is should, but this I leave as an exercise.

\documentclass{article}

\newdimen\savedxvi
\newdimen\savedxvii
\makeatletter
\newcommand*\restoredimen{%
    \fontdimen16\textfont2=\savedxvi
    \fontdimen17\textfont2=\savedxvii}
\newcommand*\qwe{$\egroup\restoredimen}
\newcommand*\Piminus{%
    \@ifnextchar'{\expandafter\Pi@minus\@gobble}
                 {\print@pi\qwe}}
\def\Pi@minus{\print@pi{^\bgroup\aftergroup\qwe\prim@s}}
\def\print@pi#1{%
    \savedxvi=\fontdimen16\textfont2
    \savedxvii=\fontdimen17\textfont2
    \hbox\bgroup%
    $\fontdimen16\textfont2=0pt
     \fontdimen17\textfont2=0pt
     \Pi_{\smash-}#1}
\makeatother

\begin{document}
$\Piminus \Piminus' \Piminus'' \Pi_- \Piminus'^2$
\end{document}
3
  • This looks interesting, and is probably the way to raise a subscript. The odd thing is that the change is global, and then one needs to do a lot of macro hackery to get the desired result. I know it can be done, but it would be a pain to make it work with e.g. \Piminus'' Commented Nov 11, 2010 at 22:42
  • @Juan: I've failed more than once to implement changes of the \fontdimen s correctly. This was one of the reasons why I gave this slightly trickery answer: to show what one has to keep in mind when working with \fontdimen. I'll add another more trickery version that allows multiple primes. Commented Nov 13, 2010 at 7:46
  • Strange things with luatex it doesn't react to any value changing in assignment of ...\textfont2=0pt... while pdflatex works fine.
    – Linuxss
    Commented Apr 25, 2019 at 10:23
2

Just a few thoughts,

First it might help to use the \prime command as in ^{\prime} rather than using a tick, both for look and it probably macros better as well.

You might try playing with the overset command i.e. \Pi\overset{^{\prime}}{_{-}}

Also the mhchem package has done a lot of work to deal with overset scripts, as chemists need to deal with similar problems in formulae.

Finally you might check to see if there is a character you would rather use for your - rather than a -. A great reference is the short math guide from AMS.

1
  • 3
    ' does nothing else than putting ^{\prime}! (And '' puts ^{\prime\prime}; ingenious definition of '.) Commented Nov 10, 2010 at 15:32

You must log in to answer this question.

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