6

I am writing the following formula:

% arara: lualatex

\documentclass{article}
\usepackage{mathtools}
\usepackage{unicode-math}

\begin{document}
\[y_\mathup{COG}=\frac{h}{3}\frac{l_\mathup{c,a}+2l_\mathup{c,i}}{l_\mathup{c,a}+l_\mathup{c,i}}\]
\end{document}

which yields:

enter image description here

I don't like the way, the h and l_\mathup{index} is vertically aligned. Is that typical behavior? Good style? Could I avoid that?

6

You can trick LaTeX into thinking the h had a subscript and thereby moving it upward to align with the l.

Alternatively, you can \smash the subscripts or the ls and thus lower them (this might look a bit cramped if you compare the space above and below the fraction bar).

\documentclass{article}
\usepackage{mathtools}
\usepackage{unicode-math}

\begin{document}
\begin{centering}
no modification
\[\enskip y_\mathup{COG}=\frac{h}{3}\frac{l_{\mathup{c,a}}+2l_\mathup{c,i}}{l_\mathup{c,a}+l_\mathup{c,i}}\]
\verb|\vphantom|
\[\enskip y_\mathup{COG}=\frac{h_{\vphantom{\mathup{c,a}}}}{3}\frac{l_{\mathup{c,a}}+2l_\mathup{c,i}}{l_\mathup{c,a}+l_\mathup{c,i}}\]
\verb|\smash|
\[\enskip y_\mathup{COG}=\frac{h}{3}\frac{l_{\smash{\mathup{c,a}}}+2l_{\smash{\mathup{c,i}}}}{l_{\smash{\mathup{c,a}}}+l_{\smash{\mathup{c,i}}}}\]
\end{centering}
\[\enskip y_\mathup{COG}=\frac{h}{3}\frac{l+2l}{l+l}\]
\end{document}

enter image description here


This behaviour seems to be caused by unicode-math, if compiled without that package the h and l are properly aligned without any modifications, indeed the modifications do not even seem to have an effect.

  • 3
    I wouldn't call this method a "trick". The \vphantom instruction was created on purpose to let users insert "struts" -- items that have height and/or depth but no width and hence are invisible -- to modify the heights and depths of the "boxes" that are TeX's most basic typeset items. – Mico Sep 10 '13 at 10:10
  • 1
    I mark this as an answer because it solves the problem. Thanks. The real answer, however, seems to be, that unicode-math has a bug. Without it, everything looks beautiful (like your \vphantom solution). – LaRiFaRi Sep 10 '13 at 10:32
  • github.com/wspr/unicode-math/issues/259 says, it is not a bug. I've added the vphantoms now. – LaRiFaRi Sep 10 '13 at 12:18
1

No, it's not typical behavior or good style (to my taste, at least). You won't have it, for instance, if you don't use the mathtools package:

\documentclass{article}

\begin{document}
\[y_{COG}=\frac{h}{3}\frac{l_{c,a}+2l_{c,i}}{l_{c,a}+l_{c,i}}\]
\end{document}

I don't have the package installed, so I cannot easily tell you if it's your doing or a bug. One thing is certain, though, I think you need to add your \mathup subscripts in extra braces, like this:

\documentclass{article}
\usepackage{mathtools}
\usepackage{unicode-math}

\begin{document}
\[
  y_{\mathup{COG}} =
    \frac{h}{3}
    \frac{l_{\mathup{c,a}}+2l_{\mathup{c,i}}}
         {l_{\mathup{c,a}}+l_{\mathup{c,i}}}
\]
\end{document}

This could be the source of your problem.

  • Thank you. Actually the bug is in unicode-math. Mathtools works fine. I replaced unicode-math by amssymb and that works also. I will report that. Your second remark: the braces don't change anything. They are redundant. – LaRiFaRi Sep 10 '13 at 10:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.