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

Stephen Tucker brown_emu at yahoo.com
Fri Apr 10 16:30:51 CEST 2009


Hi Barbara,

Thanks very much for your response! (again). I did indeed miss your post earlier... I would not have deliberately ignored such useful advice as this totally solved my problem!

So regarding your statement:
the align environment works only at "outer" level
(which can be directly within a minipage)

So align can be used within minipage but not if the minipage is within tabular? I had thought minipage provided its own [outer-level-like] environment...

In the AMS doc though I never would have guessed aligned could be the solution (so thanks for being so kind as to even pointing out the exact page number) - its main usage is suggested to be for controlling the spacing around the contents, in my interpretation of that section, unless I am missing something. Is it a width limitation which causes align to be picky about which environment it's in?

But in any case, thanks again very much! I am very grateful for your solution.

Stephen





----- Original Message ----
From: Barbara Beeton <bnb at ams.org>
To: Stephen Tucker <brown_emu at yahoo.com>
Cc: texhax at tug.org
Sent: Thursday, April 9, 2009 8:25:26 AM
Subject: Re: [texhax] using align, array, eqnarry within tabular environment

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