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.

In an attempt to show the code and the output side by side, I have used a table inside a minipage. The table entries are two minipages and one contains an align environment. Having the align environment in the given setting causes problems.

I get a meaningless error message

Argument \flalign* has an extra }.

as a result.

If I put the minipage that contains the align environment inside an fbox the problem disappears. For some reason, I thought I saw the answer to this problem in SX sometime ago, but now I cannot find it. Why do I get this error message?

The following is the working example. I have commented out the \fbox so that you can see the effect.

\documentclass[11pt]{amsart}  
\begin{document}

\begin{minipage}{1\textwidth}
\begin{tabular}{l r}
\begin{minipage}[t]{.65\textwidth}
\begin{verbatim}
\begin{flalign*}
P &=x^2+y^+2xy &\\
&=(x+y)^2
\end{flalign*}
\end{verbatim}
\end{minipage}
&
%\fbox{
\begin{minipage}[t]{.35\textwidth} 
\begin{flalign*}
P &=x^2+y^2+2xy &\\
&=(x+y)^2
\end{flalign*}
\end{minipage}
%}
\end{tabular}
\end{minipage}

\end{document}

enter image description here

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

The tabular environment "gets confused" by the & characters of flalign* environment, so you need to hide them using, for example, a pair of braces (or a box, like you found out with \fbox):

\documentclass[11pt]{amsart}  
\begin{document}

\noindent\begin{minipage}{1\textwidth}
\begin{tabular}{@{}l@{}r@{}}
\begin{minipage}[t]{.65\textwidth}
\begin{verbatim}
\begin{flalign*}
P &=x^2+y^+2xy &\\
&=(x+y)^2
\end{flalign*}
\end{verbatim}
\end{minipage}%
&
{%
\begin{minipage}[t]{.35\textwidth} 
\begin{flalign*}
P &=x^2+y^2+2xy &\\
&=(x+y)^2
\end{flalign*}
\end{minipage}%
}
\end{tabular}
\end{minipage}

\end{document}

enter image description here

I did some modifications (removed spurious blank spaces, removed inter-column space) to your code to prevent overfull boxes. Do you really need that somehow complicated nesting structure? At least in this example you can get the same result just with

\documentclass[11pt]{amsart}  
\begin{document}

\noindent\begin{minipage}{\textwidth}
\begin{minipage}[t]{.65\textwidth}
\begin{verbatim}
\begin{flalign*}
P &=x^2+y^+2xy &\\
&=(x+y)^2
\end{flalign*}
\end{verbatim}
\end{minipage}%
\begin{minipage}[t]{.35\textwidth} 
\begin{flalign*}
P &=x^2+y^2+2xy &\\
&=(x+y)^2
\end{flalign*}
\end{minipage}
\end{minipage}

\end{document}

If you're interested in showing code and output side-by-side, perhaps the showexpl package could be of interest to you.

share|improve this answer
    
Very nice answer. I was making it difficult as I have forgotten (getting old) about the power of the % sign. –  Sony May 22 '12 at 16:09
    
showexpl is, perhaps, the way I am going to go. Nice package. Thanks. –  Sony May 22 '12 at 16:20
    
btw, it might be better to use \linewidth instead of \textwidth in these constructs, just in case you move it inside itemize or other environment that changes the line width. –  tohecz May 24 '12 at 8:33
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.