7

I have searched along in this site and in other places and I am left with some questions.

So here is my code :

\documentclass[a4paper]{article}

\usepackage[english]{babel}
\usepackage{amsmath}

\begin{document}
\begin{align*}
\left( \dfrac{d^2\overrightarrow{OM}}{dt^2} \right)_{\mathcal{R}_A}
    &= \left( \dfrac{d^2\overrightarrow{OO'}}{dt^2} \right)_{\mathcal{R}_A} +\left( \dfrac{d^2\overrightarrow{O'M}}{dt^2} \right)_{\mathcal{R}_A} \\
    &= \overrightarrow{a_a}(O') + \left( \dfrac{d^2}{dt^2}  \left( x' \overrightarrow{u'_x}+y' \overrightarrow{u'_y}+z' \overrightarrow{u'_z} \right)  \right) \\
    &= \overrightarrow{a_a}(O') + x'\left( \dfrac{d^2 \overrightarrow{u'_x} }{dt^2} \right)_{\mathcal{R}_A}+ 2 \dot{x} \left( \dfrac{d \overrightarrow{u'_x} }{dt} \right)_{\mathcal{R}_A} + \ddot{x}'\overrightarrow{u'_x} \\
    &\mathrel{\hphantom{= \overrightarrow{a_a}(O') }} +\, y'\left( \dfrac{d^2 \overrightarrow{u'_y} }{dt^2} \right)_{\mathcal{R}_A}+ 2 \dot{y} \left( \dfrac{d \overrightarrow{u'_y} }{dt} \right)_{\mathcal{R}_A} + \ddot{y}'\overrightarrow{u'_y} \\
    & \mathrel{\hphantom{= \overrightarrow{a_a}(O') }} +\, z'\left( \dfrac{d^2 \overrightarrow{u'_z} }{dt^2} \right)_{\mathcal{R}_A}+ 2 \dot{z} \left( \dfrac{d \overrightarrow{u'_z} }{dt} \right)_{\mathcal{R}_A} + \ddot{z}'\overrightarrow{u'_z} 
\end{align*}
\end{document}

And here is my result with some painted lines enter image description here

So I have some questions about alignment that turn around the point that with the \mathrel{\hphantom}, I somewhat managed to align my first + '(although it seems there is a tiny misalignment, if someone has a suggestion I am happy with it), but the next terms nevertheless do not align themselves. Why is that so ? And it seems worst for my third line, that seems it self not to be aligned with the second one. Among these lines, why did I have to add a \, after my first displayed + of the lines, although it is already taken into account in the first line ?

  • 1
    the reason for the misalignment is the very slight difference in width of the x, y, and z. the answers with align[ed]at* are the best approach here. – barbara beeton Oct 28 '16 at 15:02
  • I had thought about that, but the result I obtain would mean that x is slightly wider than y, that sound very strange doesn't it ? – Anthony Martin Oct 28 '16 at 21:35
  • it wouldn't be too surprising to me to find that these letters really do have slightly different widths. i will check that tomorrow, when i can look at my copy of volume e of computers & typesetting, which contains the drawing instructions for all the cm fonts. (an alternate method of checking would be to run tftopl on the file cmmi10.tfm, to get a human-readable version of the metrics.) – barbara beeton Oct 29 '16 at 0:55
  • The idea itself does not seem incredible to me, but my interrogation was more that I would believe that y would be larger than z or x, from a very naive standpoint – Anthony Martin Oct 29 '16 at 21:39
8

A solution without \hphantom, but with alignat*. I took the opportunity to improve the look of the vectors with the esvect package, and simplified the code for the derivatives with the esdiff package: it has a \diff* command, with an optional argument (the order of derivation) and $3$ mandatory arguments: the function to derive, the name of the variable and the point at which the derivative is evaluated. A similar diffp* command exists for partial derivatives.

\documentclass[a4paper]{article}

\usepackage[english]{babel}
\usepackage{mathtools, esvect}%
 \usepackage{esdiff}
\begin{document}

\begin{alignat*}{4}
 \diff*{\vv{OM}}{t}{\mathcal{R}_A}
    &=\mathrlap{\diff*[2]{\vv{OO'}}{t}{\mathcal{R}_A}+\diff*[2]{\vv{O'M}}{t}{\mathcal{R}_A}} \\
    &=\vv{a_a}(O') & & + \mathrlap{\diff[2]{}{t} \Bigl( x' \vv{u'_x}+y' \vv{u'_y}+z' \vv{u'_z} \Bigr)} \\
    & & & + x'\diff*[2]{\vv{u'_x}}{t}{\mathcal{R}_A} & & + 2 \dot{x} \diff*{\vv{u'_x} }{t}{\mathcal{R}_A} && + \ddot{x}'\vv{u'_x} \\
    & & & + y'\diff*[2]{\vv{u'_y}}{t}{\mathcal{R}_A} & & + 2 \dot{y}\diff*{\vv{u'_y}}{t}{\mathcal{R}_A} & &+ \ddot{y}'\vv{u'_y} \\
    & & &+ z'\diff*[2]{\vv{u'_z}}{t}{\mathcal{R}_A} & & + 2 \dot{z}\diff*{\vv{u'_z}}{t}{\mathcal{R}_A} & & + \ddot{z}'\vv{u'_z}
\end{alignat*}

\end{document} 

enter image description here

  • That is both great and slightly annoying, as you make me rewrite my whole code as your solution is by far better :). Thanks for the tips, these arrows are magnificent – Anthony Martin Oct 30 '16 at 9:45
5

Split the \hphantom, so that only the equal sign is in the \mathrel:

\documentclass[a4paper]{article}

\usepackage[english]{babel}
\usepackage{amsmath,tikz}

\begin{document}
\begin{align*}
x   &= \overrightarrow{a_a}(O') + x'\\
    &\mathrel{\hphantom{= \overrightarrow{a_a}(O') }} +\, y'\\
    &\mathrel{\hphantom{=}} \hphantom{\overrightarrow{a_a}(O')} + y'\\
    &\mathrel{\hphantom{=}} \hphantom{\overrightarrow{a_a}(O')} \tikz[overlay]\draw[red](6pt,0)--++(0,3);+ z'
\end{align*}
\end{document}

enter image description here

  • Thanks, could you elaborate a bit on why is this so, so that I can at best understand it, or at least know what to put in a \mathrel or not the next time I encounter such a thing. Additionnaly, the other + signs, are not aligned, is this 'normal' in the sens only due to differences in sizes of x, y and z ? – Anthony Martin Oct 28 '16 at 13:03
  • Only the equal sign is a relation symbol, so you should only put it (or its phantom) in a \mathrel. If you want to align the following plus symbols too you should use a nested aligned or alignedat as suggested by campa, doing it with \hphantom would be rather painful. – Ulrike Fischer Oct 28 '16 at 13:07

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.