# 3 column math alignment

Is there a standard for how to align three columns of math I could follow? And what is the LaTex for that?

If no standard, how can I nicely format the columns in 3-column math? For example

-1               \leq \sin(t)              \leq 1
\int_0^x (-1) dt \leq \int_0^x \cos(t)  dt \leq \int_0^x (1) dt
-x               \leq \cos(x)-1            \leq x


I want the columns to line up over the inequalities. The left column flushed to the right and the right column flush left. The center column centered.

Note that I've tried 'alignat', but can't quite get the spacing working right since it insists on aligning everything right/left/right/left..., and the columns are too far apart.

Also tried 'tabular', but the columns are too wide and it doesn't indent according to 'fleqn,reqno' in my documentclass statement.

In principle you do not need any of these.

\documentclass{article}
\begin{document}
$\begin{array}{rcccl} -1 & \leq & \sin(t) & \leq & 1 \\ \displaystyle\int\limits_0^x (-1)\, \mathrm{d}t & \displaystyle\leq & \displaystyle\int\limits_0^x \cos(t)\, \mathrm{d}t & \leq & \displaystyle\int\limits_0^x (1)\, \mathrm{d}t \\ -x & \leq & \cos(x)-1 & \leq & x \end{array}$
\end{document}


Of course, you may feel that using \displaystyle sucks, in this case consider

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{alignat*}{3}
-1                & \leq &  \sin(t) &  \leq  1  \\
\int\limits_0^x (-1)\, \mathrm{d}t   & \leq  &
\int\limits_0^x \cos(t)\,  \mathrm{d}t &  \leq  \int\limits_0^x (1)\, \mathrm{d}t
\\
-x              & \leq  & \cos(x)-1            &  \leq   x
\end{alignat*}
\end{document}


which yields

Here, of course, the middle column is not centered.

For a centred middle column, use a regular align* and set the middle column content in similarly-sized boxes (using eqparbox's \eqmakebox):

\documentclass{article}

\usepackage{amsmath,eqparbox}

\newcommand{\dt}{\,\mathrm{d}t}
\newcommand{\dint}{\displaystyle\int}

\begin{document}

\begin{align*}
-1 &\leq \eqmakebox[box]{$\sin(t)$} \leq 1                 \\
\dint_0^x (-1) \dt &\leq \eqmakebox[box]{$\dint_0^x \cos(t) \dt$} \leq \dint_0^x (1) \dt \\
-x &\leq \eqmakebox[box]{$\cos(x) - 1$} \leq x
\end{align*}

$\renewcommand{\arraystretch}{1.2} \setlength{\arraycolsep}{0pt} \begin{array}{ r c l } -1 \leq {} & \sin(t) & {} \leq 1 \\ \dint_0^x (-1) \dt \leq {} & \dint_0^x \cos(t) \dt & {} \leq \dint_0^x (1) \dt \\ -x \leq {} & \cos(x) - 1 & {} \leq x \end{array}$

$\renewcommand{\arraystretch}{1.2} \setlength{\arraycolsep}{0pt} \begin{array}{ r } -1 \leq {} \\ \dint_0^x (-1) \dt \leq {} \\ -x \leq {} \end{array} \begin{array}{ c } \sin(t) \\ \dint_0^x \cos(t) \dt \\ \cos(x) - 1 \end{array} \begin{array}{ l } {} \leq 1 \\ {} \leq \dint_0^x (1) \dt \\ {} \leq x \end{array}$

\end{document}


The second and third option provides additional options using arrays for stacking content, but is not really preferred over the spacing (and numbering, if needed) provided by the amsmath displays.

You might also consider lining up certain items within each of the three columns, for example, the -1, -1 and -x in the first column. This can be done using \phantom commands.

You could adapt this strategy to any of the other solutions, or use \lefteqn and additional \phantom commands to align the second column of \leqs as in the following code.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{align*}
\phantom{\int_0^x (}{-1}\phantom{)\,\mathrm{d}t} & %
\leq \lefteqn{\phantom{\int_0^x} \sin(t)\phantom{\, \mathrm{d}t}}\phantom{\int_0^x 1-\cos(x)}%
\leq \phantom{\int_0^x (}1 \\
\int_0^x (-1)\,\mathrm{d}t &%
\leq \lefteqn{\int_0^x \sin(t)\, \mathrm{d}t}\phantom{\int_0^x 1-\cos(x)}%
\leq \int_0^x (1)\,\mathrm{d}t \\
\phantom{\int_0^x (}{-x}\phantom{)\,\mathrm{d}t} &%
\leq \phantom{\int_0^x}\,1-\cos(x)%
\leq \phantom{\int_0^x (}x \\
\end{align*}

\end{document}


Lastly, there is some consensus that a thin space (\,) should be inserted between the integrand and the differential, and (perhaps less consensus) that the d in the differential should be typeset in roman (upright) style.

You can code it with minimal markup. And fixed some math, but note that this proof only works for x ≥ 0. ;-)

\documentclass{article}
\usepackage{amsmath} % always needed
\usepackage{array} % for multialigned
\usepackage{amsthm} % for statements and proofs

\newenvironment{multialigned}[1][1.2]
{%
\renewcommand{\arraystretch}{#1}%
\setlength{\arraycolsep}{0pt}%
\begin{array}{
>{\displaystyle}r
>{\displaystyle{}}c<{{}}
>{\displaystyle}c
>{\displaystyle{}}c<{{}}
>{\displaystyle}l
}
}
{\end{array}}

\begin{document}

\begin{equation*}
\begin{multialigned}[1.5]
-1                & \leq & \sin(t)              & \leq & 1 \\
\int_0^x (-1)\,dt & \leq & \int_0^x \sin(t)\,dt & \leq & \int_0^x (1)\,dt \\
-x                & \leq & 1-\cos(x)            & \leq & x
\end{multialigned}
\end{equation*}

\end{document}


Here's the best I can do:

\usepackage{array}                  % Provides for a more flexible array and tabular environment
\usepackage{booktabs}               % For fancy stuff in arrays and tables. Like the following column definitions
\newcolumntype{L}{>{\begin{math}}l<{\end{math}}}%
\newcolumntype{C}{>{\begin{math}}c<{\end{math}}}%
\newcolumntype{R}{>{\begin{math}}r<{\end{math}}}%
\usepackage{multicol,multirow}

\parindent0pt
\setlength{\parskip}{0.5\baselineskip}
\everymath{\displaystyle}


Then the table in the body

{
\setlength{\tabcolsep}{01pt} % Default value: 6pt     %Need to find how I set this as a universal constant
\renewcommand{\arraystretch}{2.3} % Default value: 1  %Need to find how I set this for each row
\begin{tabular}{RCCCL}
\sin(t)                 &\leq& t           \\
\int_0^x \sin(t) \dif t &\leq& \int_0^x t \dif t \\
-\cos(x) + \cos(0)      &\leq& \frac{x^2}{2} - 0 \\
-\cos(x) + 1            &\leq& \frac{x^2}{2} \\
1-\frac{x^2}{2}         &\leq& \cos(x)
\end{tabular}
}