I'm trying to create an environment that will close a multicols
group, do a thing, then start a new multicols
.
Something like
\newcount{\colcount}
\newenvironment{balancedbreak}{%
\let\colcount\col@number
\end{multicols}\newpage\begin{multicols}{\colcount}
}{
}
This does not work, I get the error message
! LaTeX Error: \begin{balancedbreak} on input line 38 ended by \end{multicols}
MWE
This builds.
\documentclass{article}
\usepackage{multicol}
\usepackage{lipsum}
\newcount{\colcount}
\newenvironment{balancedbreak}{%
\let\colcount\col@number%
%\end{multicols}\newpage\begin{multicols}{\colcount}%
\newpage
}{%
}
\begin{document}
\begin{multicols}{2}
\lipsum[1]
\lipsum[2]
\begin{balancedbreak}
\textbf{Testing here}
\end{balancedbreak}
\lipsum[3]
\lipsum[4]
\end{multicols}
\end{document}
I get one long unbalanced column, then a new page and balanced columns. If I uncomment the line starting \end{multicols}
in the new environment and comment out the next one I get the error message above.
I'm curious about the general case: "how do I end an environment in the 'before' section of a \newenvironment
?
(My immediate need is "how can I better achieve the goal of ending a multicols
page so it balances and move to the next page?". I could simply not do it at all the way I am now, but I'd like to use an environment for other reasons.)