0

How to use properly the indices in Latex editor like Tex studio ?

For example, when I am typing $x^{p_{q_r}}$, it looks like $p$ and $q$ sits side by side and $r$ is at down. But these are all proper subscript. What should I use for more clear position ?

In case of two indices (one is subscript of other), everything looks fine, but in case three indices it looks not good. What is salvation ?

For example, see

enter image description here

learner
  • 663
  • For manual tweaking there is always raisebox. – oliversm Sep 10 '20 at 16:23
  • @oliversm, I didn't get you.Can please explain it? – learner Sep 10 '20 at 16:53
  • (a) Can you include a full MWE showing this? In my standard set-up the output of $x^{p_{q_r}}$ looks just fine. (b) oliversm means that if the output has the symbols too high or too low in your opinion, you can always vertically shift it manually using the \raisebox command. http://www.emerson.emory.edu/services/latex/latex_148.html But I doubt you would want to do it manually everytime you run into this. – Willie Wong Sep 10 '20 at 18:00
  • @WillieWong, Please see the image in the question above. I used $x_1^{q_{1_1}}$ but it looks $q$ and $1$ sits together. i want to put them in proper subscript position . How would be the code using \raisebox ? What is the package ? – learner Sep 10 '20 at 18:12

2 Answers2

2

Okay, so the issue is primarily that the shape of the lower case q, with a descender, makes it looks almost level with the 2nd level subscript 1. If you look at the base of the second level subscript 1, it is clearly lower than the bottom of the "loop" in q.

So what you need to do is to modify how much the subscripts are lowered. You can control this by setting \fontdim for the appropriate lengths. A discussion of how this works can be found in this post.

To illustrate the method, see the following code:

\documentclass{article}

\makeatletter %%% These three lines are to ensure the math fonts \check@mathfonts %%% are configured prior the call of \fontdim. Include \makeatother %%% if you run into an error about \nullfont.

\begin{document} [ x^{q_{1_1}} ] %% Standard format. For reference.

\fontdimen16\scriptfont2=3pt % <--- This is the line that sets the height.

[ x^{q_{1_1}} ] %% Same expression, for comparison. \end{document}

The output (top line is original, bottom line is with the increased subscript height):

enter image description here

You will have to play around with the parameters to find what makes you pleased aesthetically.

Willie Wong
  • 24,733
  • 8
  • 74
  • 106
  • Thank you very much – learner Sep 10 '20 at 19:03
  • Why \[ x^{q_{k_j}} \] showing error ? Why not replacement of the indices allowed ? – learner Sep 10 '20 at 19:35
  • What error? If you just replace 1_1 by k_j in the sample code I posted, it should compile with no problem. Please be more precise about the error you see. – Willie Wong Sep 10 '20 at 19:58
  • Actually when I am using [ x^{q_{k_j}} ] within a math-expression like $f(x)=g([ x^{q_{k_j}} ])$, it showing but when I am writing it simply [ x^{q_{k_j}} ] without any $ $ quotation, it is working fine. Anyway using your package mentioned above and using the fontdim above, I am just using x^{q_{k_j}} and it looks now nice – learner Sep 11 '20 at 12:52
1

enter image description here

I suggest to define a macro to save some typing and to avoid inconsistent layout. Modify the length -0.2ex to shift the index of q.

\documentclass{article}
\newcommand\xq[2]{x_{#2}^{q\raisebox{-0.2ex}{$_{{}_{{#1}_{#2}}}$}}}
\begin{document}
$\xq11 \xq12 \cdots \xq1d$
\end{document}
gernot
  • 49,614
  • Thank you very much. Is \newcommand\xq[2]{x_{#2}^{q\raisebox{-0.2ex}{$_{{}_{{#1}_{#2}}}$}}} a command ? – learner Sep 10 '20 at 19:02
  • Yes,it worked, but why $ \xqd1 \xqd2 \cdots \xqdd $ is giving error replacing 1 by d ? – learner Sep 10 '20 at 19:13
  • 1
    Because \xqd is taken to be the name of the macro, which does not exist. Either add a space, \xq d1, or use braces: \xq{d}{1} – gernot Sep 10 '20 at 19:15
  • 1
    \newcommand defines a macro/a shortcut. In this case the name of the shortcut is \xq, and it takes two arguments (therefore [2]), which are references by #1 and #2 in the text of the shortcut. – gernot Sep 10 '20 at 19:17
  • Thank you very much. It worked as you said. – learner Sep 10 '20 at 19:18