# Vertical alignment of equations

I'm trying to put three equations in the same line.

I used the tabularx package as was advised by this post: How to place and number 3 short equations in one line?.

However since I am using equation with different heights, they do not align well vertically.

I manage to solve this using \vspace but I would like to know if there is a more elegant solution. Here is the code I used:

\documentclass[11pt,a4paper]{article}
\usepackage{amsmath}
\usepackage{tabularx}
\usepackage[margin=0.25in]{geometry}
\begin{document}

\noindent\begin{tabularx}{\textwidth}{@{}XXX@{}}
\vspace{0.1mm}
$$Euc(P,Q)= \left( \sum_{i=1}^n \left| p_i - q_i \right|^2 \right)^{1/2} \label{eqn:1}$$ &
\vspace{1.5mm}
$$Canb(P,Q)=\sum_{i=1}^n \frac{|p_i-q_i|}{|p_i|+|q_i|} \label{eqn:2}$$ &
\vspace{5.8mm}
$$Man(P,Q)=\sum_{i=1}^n |p_i-q_i| \label{eqn:3}$$
\end{tabularx}
\end{document}


• Two equation numbers in the same row are bad style; three are … ;-) The line is very cluttered and makes it difficult to see the numbers themselves. Feb 16, 2014 at 22:28

To place three numbered equations next to one another, you could use the multicols environment, which is provided by the multicol package. In the example below, using this environment makes it unnecessary to fiddle with various tabular-like environments or experiment with \vspace adjustments.

Incidentally, using \left( ... \right) to enclose a summation symbol with limits tends to generate parentheses that are far too large, typographically speaking. Better to use \biggl( ... \biggr) in such cases. (This is not only my prescription; you may find it in the TeXbook as well.)

\documentclass[11pt,a4paper]{article}
\usepackage{mathtools,multicol}
\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}
\DeclareMathOperator{\Euc}{Euc}
\DeclareMathOperator{\Canb}{Canb}
\DeclareMathOperator{\Man}{Man}
\usepackage[margin=0.4in]{geometry}
\begin{document}
\begin{multicols}{3}
$$\Euc(P,Q)= \biggl( \sum_{i=1}^n \abs{ p_i - q_i }^2 \biggr)^{1/2} \label{eqn:1}$$

$$\Canb(P,Q)=\sum_{i=1}^n \frac{\abs{p_i-q_i}}{\abs{p_i}+\abs{q_i}} \label{eqn:2}$$

$$\Man(P,Q)=\sum_{i=1}^n \abs{p_i-q_i} \label{eqn:3}$$
\end{multicols}
\end{document}

• Wow, didn't know about the multicol package. Thank you for the parenthesis tip as well! Feb 15, 2014 at 14:31

What you are trying to do doesn't look nice IMHO; I would just use

\documentclass{scrbook}

\usepackage{mathtools}

\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}
\DeclareMathOperator*{\Euc}{Euc}
\DeclareMathOperator*{\Canb}{Canb}
\DeclareMathOperator*{\Man}{Man}

\begin{document}

\begin{align}
\label{eqn:1}
\Euc(P,Q)  &= {\mkern -6mu}\left(\sum_{i = 1}^n \abs*{p_i - q_i}^2\right)^{\mkern -6mu 1/2},\\
\label{eqn:2}
\Canb(P,Q) &= \sum_{i = 1}^n \frac{\abs*{p_i - q_i}}{\abs*{p_i} + \abs*{q_i}},\\
\label{eqn:3}
\Man(P,Q)  &= \sum_{i = 1}^n \abs*{p_i - q_i}.
\end{align}

\end{document}


• Sorry, but the first code example that I posted was wrong, so you would get a very ugly layout indeed. Please see the corrected example. Feb 15, 2014 at 14:13