3

I'm getting a weird spacing for the S and the 3P, ideally they would be aligned just before the equal sign of their associated row. I tried using &\span S&&... but it gave me an error. Any help would be greatly appreciated.

MWE:

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath,amssymb}
\begin{document}
\begin{alignat}{2}
&   S&&=Pe^{j_\infty t}\nonumber\\
&   3P&&=Pe^{\frac{t\ln2}{5}}\nonumber\\
    &\iff3&&=e^{\frac{t\ln2}{5}}\nonumber\\
    &\iff\ln3&&=\frac{t\ln2}{5}\nonumber\\
    &\iff t&&=\frac{5\ln3}{\ln2}\nonumber\\
&   &&\cong7.92481250\text{ years}\nonumber
\end{alignat}{2}
\end{document}
Francesco
  • 372
  • Don't you want something, instead, like this? \documentclass[a4paper,12pt]{article} \usepackage{amsmath,amssymb} \begin{document} \begin{alignat}{2} S&=Pe^{j_\infty t}\nonumber\\ 3P&=Pe^{\frac{t\ln2}{5}}\nonumber\\ \iff3&=e^{\frac{t\ln2}{5}}\nonumber\\ \iff\ln3&=\frac{t\ln2}{5}\nonumber\\ \iff t&=\frac{5\ln3}{\ln2}\nonumber\\ &\cong7.92481250\text{ years}\nonumber \end{alignat} \end{document} ? I get rid of the leading & in each row and convert the && in each row to a single & – Steven B. Segletes Jul 25 '17 at 20:24
  • 1
    Hi Steven, thanks for your reply. That's what I originally had, but that is not what I am looking to produce. That is the fall back if I can't make it the way I'm asking about. – Francesco Jul 25 '17 at 20:26
  • I'm also aware that I could use \hspace{xpt} where x is the appropriate horizontal spacing in points, but that seems to defeat the purpose of what I am hoping Latex can do for me. :D – Francesco Jul 25 '17 at 20:28

1 Answers1

4

Maybe you're looking for this:

enter image description here

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath,amssymb}
\begin{document}
\begin{alignat*}{2}
     &&    S &= Pe^{j_\infty t} \\
     &&   3P &= Pe^{\frac{t\ln2}{5}} \\
\iff &&    3 &= e^{\frac{t\ln2}{5}} \\
\iff && \ln3 &= \frac{t\ln2}{5} \\
\iff &&    t &= \frac{5\ln3}{\ln2} \\
     &\quad&&\approx 7.92481250\,\mathrm{years}
\end{alignat*}
\end{document}

Within alignat and align, pairs of columns are produced; the first column of the pair is right aligned, the second one is left aligned. The difference is that alignat doesn't add space between these pairs of columns (and this is the reason why one should specify the number of pairs).

Here the \iff symbols are in a right aligned column; the left aligned one just contains \quad. Then comes the standard “right”-“left” part for the equations.

egreg
  • 1,121,712
  • Hi egreg, thanks for your reply! This is exactly what I was looking for!

    As a comparison I tried using & and then &&, essentially switching them, and it produced an undesired result where the values immediately to the left of the equal signs followed the \iff and the white space. Can you explain why and how your solution produces the desired result?

    – Francesco Jul 25 '17 at 20:43
  • 1
    @Francesco Done. – egreg Jul 25 '17 at 20:51