我正在使用tufte-book
并想定义和环境,fullwidth
但也是align
-ed(来自amsmath
)。
我试过这样做
\newenvironment{walign}{
\begin{fullwidth}\begin{align}
}{
\end{align}\end{fullwidth}
}
从视觉上看这似乎可行,但编译器会抛出编译错误;
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.
最小工作示例;
\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}
该命令的正确语法/用法是什么\newenvironment{}{}
?
答案1
谢谢@muzimhuzhi!你发布的相关问题让我找到了答案;
\NewEnviron{walign}{%
\begin{fullwidth}\begin{align}
\BODY
\end{align}\end{fullwidth}%
}
\NewEnviron{walign*}{%
\begin{fullwidth}\begin{align*}
\BODY
\end{align*}\end{fullwidth}%
}