[texhax] using align, array, eqnarry within tabular environment

Barbara Beeton bnb at ams.org
Thu Apr 9 17:25:26 CEST 2009


On Thu, 9 Apr 2009, Stephen Tucker wrote:

    I have a question regarding the use of align, array, or eqnarray within a table created by tabular. Align works fine by itself, or within a minipage. For example:
    
    ===================================
    \documentclass{article}
    \usepackage{amsmath}
    \begin{document}
    
     \begin{align*}
          x \protect & = y+1  \\
          z \protect & = 2 x
       \end{align*} 
    
    \end{document}
    ===================================
    
    However, the following (- align nested within tabular -) gives
    ! LaTeX Error: \begin{document} ended by \end{tabular}.
    ! Missing $ inserted.
    and so on...
    ===================================
    \documentclass{article}
    \usepackage{amsmath}
    \begin{document}
      \begin{tabular}{cc}
       \begin{minipage}{2in}
         \flushleft text
       \end{minipage} &
         \begin{align*}
           x & = y+1  \\
           z & = 2 x
       \end{align*} 
     \end{tabular}
     
    \end{document}
    ==================================
    
    Even if I try to put \protect in front of & and \\, it still has problems, and putting 
    \protect{\begin{align*}...\end{align*}}
    will put the statement on the next line rather than in the second column of the table, as I desire.

    Does anyone know how to get around this behavior? Thanks very much in advance,

the align environment works only at "outer" level
(which can be directly within a minipage); it
cannot be used within any other environment,
particularly within another display environment.
instead, use the aligned environment:

    ===================================
    \documentclass{article}
    \usepackage{amsmath}
    \begin{document}
      \begin{tabular}{cc}
       \begin{minipage}{2in}
         \flushleft text
       \end{minipage} &
         $\begin{aligned}
           x & = y+1  \\
           z & = 2 x
       \end{aligned}$
     \end{tabular}
     
    \end{document}
    ==================================

see the section on "alignment building blocks" in
the amsmath user's guide (amsldoc.pdf), p.7.
  
any of these subsidiary environments must be
in math mode.
							-- bb


More information about the texhax mailing list