Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I often need a display environment which would let me easily present equally-spaced expressions in the same line, with content on successive lines appearing centred at the same x-coordinate as content on the first line. I can sort of get the effect I want like this:

\begin{align*}
x+y && e^{2 \pi i} && \sigma
\\
\text{First} && \text{Second} && \text{Third}
\end{align*}

But it's not quite perfect, as the 'columns' appear right-aligned, not centred.

Of course I can achieve this easily enough using an array. But then I have to set the spacing between the columns myself, which the align environment does for me automatically. I just wonder if any of the standard math environments can do this already. I would like to be able to code it like this:

\begin{myenvironment*}
x+y & e^{2 \pi i} & \sigma
\\
\text{First} & \text{Second} & \text{Third}
\end{myenvironment*}
share|improve this question
add comment

1 Answer

For equally-spaced columns (different from equal-width columns), you could put your contents in a fixed-width tabular* environment:

\documentclass{article}
\usepackage{lipsum,array,amsmath}
\begin{document}
​​​​​​​​​​​​​​​​​​​​​​​​\lipsum[1]
\newcolumntype{E}{@{}c@{}}% begin-/end-column definitions
\noindent\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}E*{3}{>{$}c<{$}}E}
  & x+y & e^{2 \pi i} & \sigma & \\
  & \text{First} & \text{Second} & \text{Third} &
\end{tabular*}
\lipsum[2]
\end{document}
​

I define a new columntype E used merely as a spacer for the first/last columns. Also, the addition of @{\extracolsep{\fill}} adds stretch before/after each column to space things out evenly across \textwidth. Using *{3}{>{$}c<{$}} allows for 3 similarly defined columns (centered c and typeset in math mode $...$).

Equal-spaced columns in tabular*

Of course, this requires you to know how many columns you want to typeset, since you're using the tabular* environment. Although this is not as noticeable, you might want to add \renewcommand{\tabcolsep}{0pt} and scope {...} it around your tabular* environment in order to remove the spacing caused by the E column type. For example the code

\newcolumntype{E}{@{}c@{}}% begin-/end-column definitions

{\renewcommand{\tabcolsep}{0pt}% No \tabcolsep
\noindent\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}E*{3}{>{$}c<{$}}E}
  & x+y & e^{2 \pi i} & \sigma & \\
  & \text{First} & \text{Second} & \text{Third} &
\end{tabular*}}

\noindent\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}E*{3}{>{$}c<{$}}E}
  & x+y & e^{2 \pi i} & \sigma & \\
  & \text{First} & \text{Second} & \text{Third} &
\end{tabular*}

produces this marginal difference

Small adjustments to tabular* environment columns via \tabcolsep

share|improve this answer
    
Thanks Werner, that's a clever solution -- although it's still a bit clunky. I don't see why functionality like this isn't built into the gather environment, for example. Anyway, thanks for the answer! –  Jamie Vicary Aug 3 '11 at 10:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.