5

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

1 Answer 1

5

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.

3
  • Very nice answer. I was making it difficult as I have forgotten (getting old) about the power of the % sign.
    – Sony
    Commented May 22, 2012 at 16:09
  • showexpl is, perhaps, the way I am going to go. Nice package. Thanks.
    – Sony
    Commented May 22, 2012 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.
    – yo'
    Commented May 24, 2012 at 8:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .