The first two lines have fewer characters than the second two in the the align*
environment, they are flushed right and seem awkwardly out of alignment with the last two equations. (Note that the only reason I have an additional space in front within the text command in the last two equations like \text{ if...}
and not \text{if...}
like the first two is just from a (failed) attempt at fixing the spacing).
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
\frac{x^{n+1}}{x^2+1} &= x^{n-1}-x^{n-3}+x^{n-5}-\ldots-\frac{1}{x^2+1} & \text{if $n$ is odd and is } 1,5,9,13,\ldots\\
\frac{x^{n+1}}{x^2+1} &= x^{n-1}-x^{n-3}+x^{n-5}-\ldots+\frac{1}{x^2+1} & \text{if $n$ is odd and is } 3,7,11,15,\ldots\\
\frac{x^{n+1}}{x^2+1} &= x^{n-1}-x^{n-3}+x^{n-5}-\ldots-\frac{x}{x^2+1} & \text{ if $n$ is even and is } 2,6,10,14,\ldots\\
\frac{x^{n+1}}{x^2+1} &= x^{n-1}-x^{n-3}+x^{n-5}-\ldots+\frac{x}{x^2+1} & \text{ if $n$ is even and is } 4,8,12,16,\ldots
\end{align*}
\end{document}
which outputs:
I have ways to sooth this (like just saying n=4k+1, 4k+2, etc. or just specifying the conditions elsewhere before or after the equations), but for future reference, what would be a nice way to fix this inside of the align*
environment? I think it would just look better if things were aligned to the left in the second part of the lines. Is there any best practice for something like this?
Also, I am aware of the cases
and dcases
environments and whatnot (which is what I finally used), but am seeking answers for this environment specifically.
Best Answer
align
(and its starred versionalign*
aligns content using aR
ight&
L
eft approach around the alignment character&
. Multiple alignments follow the same approach, separated by a single&
. The following minimal example highlights this:The first line shows a bunch of
R
ight andL
eft alignments, separated by alignment markers&
. The second line has the pseudocode mimicing the alignment, for clarity.With the above information, you want the left construction around the
=
to be aligned likeR1&L1
, while you want the textual description to be aligned to theL
eft only (without aR
ight counterpart) and therefore would use&&L2
:Note the use of
\dots
, which automatically switches to\cdots
within a binary operator sequence, and\ldots
within a series.