I'm using tufte-book and would like to define and environment that is fullwidth but also align-ed (from amsmath).
I've tried doing this with
\newenvironment{walign}{
\begin{fullwidth}\begin{align}
}{
\end{align}\end{fullwidth}
}
and this visually seems to work, but the compiler throws compilation errors;
LaTeX Error: \begin{align} on input line 35 ended by \end{walign}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.37 \end{walign}
Your command was ignored.
Type I <command> <return> to replace it with another command,
or <return> to continue without it.
main.tex, line 39
LaTeX Error: \begin{list} on input line 35 ended by \end{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.39 \end{document}
Your command was ignored.
Type I <command> <return> to replace it with another command,
or <return> to continue without it.
Minimal working example;
\documentclass[
a4paper,
nofonts,
justified
]{tufte-book}
\usepackage{amsmath}
\newenvironment{walign}{
\begin{fullwidth}\begin{align}
}{
\end{align}\end{fullwidth}
}
\begin{document}
This paragraph and the below \texttt{align} environment are regular-width, and leave space for a margin notes column to the right.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Vel facilisis volutpat est velit egestas dui id. Tempor nec feugiat nisl pretium fusce id. Venenatis tellus in metus vulputate eu. Quam elementum pulvinar etiam non quam lacus. Facilisi cras fermentum odio eu feugiat pretium nibh ipsum consequat. Sed lectus vestibulum mattis ullamcorper velit sed ullamcorper.
\begin{align}
Z_\theta &= \sum_{\tau \in T} q(\tau) e^{R(\tau)}
\end{align}
\begin{fullwidth}
This paragraph and the below \texttt{align} environment are full-width, and bleed into the margin notes column.
Magna eget est lorem ipsum dolor sit amet. Enim eu turpis egestas pretium aenean pharetra magna. Massa placerat duis ultricies lacus. Cras ornare arcu dui vivamus arcu. Urna molestie at elementum eu facilisis sed odio morbi. Odio ut sem nulla pharetra diam sit amet nisl. Eu facilisis sed odio morbi quis commodo odio aenean. Mi tempus imperdiet nulla malesuada pellentesque elit. Id aliquet lectus proin nibh. Pulvinar sapien et ligula ullamcorper malesuada proin.
\begin{align}
Z_\theta &= \sum_{\tau \in T} q(\tau) e^{R(\tau)}
\end{align}
\end{fullwidth}
I would like to define a custom environment `\texttt{walign}' that creates a \texttt{fullwidth}, \texttt{align}-ed environment, but doing so with \verb+\newenvironment{}{}+ gives compilation errors whenever I use the environment;
\begin{walign}
Z_\theta &= \sum_{\tau \in T} q(\tau) e^{R(\tau)}
\end{walign}
\end{document}
What is the correct syntax / usage of the \newenvironment{}{} command?
environorxparsepacakge works in your situation. – muzimuzhi Z Jun 10 '20 at 05:54\newenvironmentin the right way. What special here is thealignenvironment. Manyamsmathenvironments, includingalign, collects the environment contents using corresponding\end{<envname>}as a delimiter. Hence when\begin{align}is expanded, there must be a corresponding\end{align}in the input stream. In the above linked question, contents of new envwalignis firstly collected, then fed to\begin{align} ... \end{align}. – muzimuzhi Z Jun 10 '20 at 10:23