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.

At the moment I'm trying to figure out how I could interrupt an environment. What I did so far...

\documentclass{article}
\usepackage{amsmath}

\newenvironment{envnew}
{
    \begingroup
    \csname align*\endcsname
}{
    \csname endalign*\endcsname
    \endgroup
}
\newcommand{\last}[1]{%
    \end{envnew}\begin{envnew}#1%
}

\begin{document}
\begin{envnew}
a &= b + c\\
x &= y + z\\
a &= b + c\\
x &= y + z
\last{\text{content}}
\end{envnew}
\end{document}

I think most of it should be self-explaining, I'm just trying to append a second environment at the end - background should be unimportant. Most of the given code works, but it breaks with the error...

! Missing $ inserted.
<inserted text>
                $
l.24 \end{envnew}

...any idea what I'm doing wrong?

share|improve this question
2  
If you only want to interrupt aligned equations display, you should check out the \intertext commands from amsmath and mathtools packages, maybe it'll be enough for that purpose. –  T. Verron Nov 10 '12 at 14:24
    
Sadly, it isn't an alternative. I already tried to redefine intertext (centered, math, no spacing / baselineskips) without success. The \noalign command in intertext makes too much troubles... –  triton Nov 10 '12 at 14:27
    
@triton -- if you just want a centered line of text in the middle of a multiline display, treat it as an ordinary line, but wrap the contents in \text{...}. that is, \begin{align*} ... xxx\\ \text{some text}\\ yyy ... \end{align*}. that's what \text is for. it doesn't need a separate environment. –  barbara beeton Nov 10 '12 at 14:39
    
@barbarabeeton For me, it doesn't look like to be centered. Even without any & in a line, it gets affected. –  triton Nov 10 '12 at 14:53
    
@Stephen I dont think so... but I'm open for any solution. –  triton Nov 10 '12 at 14:53
show 1 more comment

1 Answer

amsmath has more than one multi-line math environment, and it's possible to use more than one for a single display to obtain the desired results. sometimes it's also necessary to be devious if material above and below the line of "text" has expressions of different widths on the left and right of the alignment point. here's a contrived example.

output of code example

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{gather*}
\begin{aligned}
\phantom{a + b}\llap{$a$} &= b + c\\
x &= y + z\\
a &= b + c\\
x &= y + z
\end{aligned}\\
\text{content}\\
\begin{aligned}
a + b &= c\\
x &= y + z
\end{aligned}
\end{gather*}
\end{document}

the \llapis used with a phantom of the longest segment in the aligned portions of the composite display to ensure mutual alignment of the separated components. (if a longer segment were present on the right side, an \rlap would be used, placed just after the sign of relation.)

share|improve this answer
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.