我的代码:
\documentclass{article}
\usepackage{amsmath}
\usepackage{verbatim}
\begin{document}
\begin{align}
1 + 1 & = 2 \\
e^{i \pi} + 1 & = 0
\begin{comment}
comment
\end{comment}
\end{align}
\end{document}
我收到错误:
$ pdflatex foo.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
(./foo.tex
LaTeX2e <2020-02-02> patch level 5
L3 programming layer <2020-03-06>
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/base/article.cls
Document Class: article 2019/12/20 v1.4l Standard LaTeX document class
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/tools/verbatim.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/l3backend/l3backend-pdfmode.
def) (./foo.aux)
! Argument of \verbatim@ has an extra }.
<inserted text>
\par
l.11 \end{align}
?
- 为什么我不能使用
comment
环境中的环境align
? - 如何在
align
环境中放置多行注释块?
答案1
答案2
放弃comment
环境并使用伪造的条件\iffalse
......\fi
就像这个答案
\documentclass{article}
\usepackage{amsmath}
%\usepackage{verbatim} %for the MWE no more 'verbatim' needed
\begin{document}
\begin{align}
1 + 1 & = 2 \\
e^{i \pi} + 1 & = 0
\iffalse
comment
comment
\fi
\end{align}
\end{document}
答案3
要在环境中放置多行注释align
,一种方法是使用\intertext
(或\shortintertext
,用于更短的垂直间距)中的mathtools
。
\documentclass{article}
\usepackage{amsmath}
\usepackage{mathtools}
\begin{document}
\begin{align}
1 + 1 &= 2 \\
e^{i \pi} + 1 &= 0 \\
\intertext{This is a multiple line comment so it is not short. This is a multiple line comment so it is not short. This is a multiple line comment so it is not short. This is a multiple line comment so it is not short.}
\sin x &= 1
\end{align}
\end{document}