It's a bit of a long story as to why I need to do this, but please bear with me. I have a fairly complicated custom class which expects documents to begin with a command:
\coverandabstract{Abstract text goes here}
What this does is lay out a (one column) cover page, basically a custom maketitle, then switches to two column layout with different page dimensions on page two, beginning with an abstract that spans both columns.
Now, I want to be able to draft the document in Markdown and convert to this class (and other formats) via Pandoc. The most cross-format way of representing the abstract is as a blockquote, which gets converted to a quote environment.
\begin{quote}
Abstract text goes here
\end{quote}
So what I need to do is find a way of converting the first, and only the first, quote environment into the \coverandabstract
command.
Now one way of doing this would be to use the environ package:
\usepackage{environ}
\let\oldquote=\quote
\let\endoldquote=\endquote
\makeatletter
\renewenvironment{quote}%
{\Collect@Body\coverandabstract}%
{\let\quote=\oldquote
\let\endquote=\endoldquote}
\makeatother
The problem is that the class is based on memoir, and changing the page layout means using \checkandfixthelayout
. This doesn't work properly if called within an environment, probably as a result of the grouping. This means the above technique ruins the layout for the remainder of the document.
So is there a way of passing the contents of an environment to a command without having it wrapped in a TeX group?