# Centering column in alignat environment?

How do I center the contents of each cell in the middle column? I am approximating it with \phantom, but there's got to be a better way.

\begin{alignat*}{3}
\end{alignat*}


thanks

At its heart the alignat environment is built on TeX's \halign. In that environment you can ignore the formatting specifications for a given column by issuing \omit. Thus writing

\omit\hfill text \hfill


will give you a centered column of text, since the column specification not only included the left/right alignment but also that the meterial is set as mathematics. It is probably best to create a separate command to provide this construction, which may then be used anywhere in an alignat, align or similar enviroment, at the beginning of a cell:

\documentclass{article}

\usepackage{amsmath}

\newcommand{\ditto}{{''}}
\newcommand{\ccol}[1]{\omit\hfill #1\hfill}

\begin{document}

\begin{alignat*}{3}
&\Psi&&\ccol{\ditto}&&\frac{\epsilon V}{1+4\pi\epsilon F},\\
&\Psi&&\ccol{\ditto}&&\frac{(1+4\pi\epsilon F)^2}{\epsilon}.
\end{alignat*}

\begin{align}
E &= mc^2\\
F &\ccol{is another quantity}\\
G &= u^2 + v^2 - w^2 + x^2 - y^2 + z^2
\end{align}

\end{document}


Sould you wish to span multiple columns the relevant command is \multispan, e.g. \multispan{3}\hfill text \hfill will place text spread over three columns and centered.

Alternatively, as Harish Kumar suggests you can use array or tabular:

\documentclass{article}

\usepackage{amsmath}

\newcommand{\ditto}{{''}}

\begin{document}

\begin{equation*}
E&\mathrm{par}&\Sigma,\\
\Psi&\mathrm{\ditto}&\displaystyle\frac{\epsilon V}{1+4\pi\epsilon F},\\
\Psi&\mathrm{\ditto}&\displaystyle\frac{(1+4\pi\epsilon F)^2}{\epsilon}.
\end{array}
\end{equation*}

\begin{center}
$$E$$&par&$$\Sigma,$$\\
$$\Psi$$&\ditto&$$\displaystyle\frac{\epsilon V}{1+4\pi\epsilon F},$$\\
$$\Psi$$&\ditto&$$\displaystyle\frac{(1+4\pi\epsilon F)^2}{\epsilon}.$$

However, the default line spacing from alignat is better and you don't need to worry about adjusting the math styles.
• The problem arises when multiple \ccols are used on one line. overleaf.com/read/mvryrbzzgmkw – ominug Sep 14 '15 at 21:57