我想对文档的所有行进行编号,以便于审阅。除了我在对齐方程之间使用的段落lineno
外,该程序包运行良好。\intertext{...}
\documentclass{article}
\usepackage{amsmath}
\usepackage[mathlines]{lineno}
\linenumbers
\thispagestyle{empty}
\begin{document}
Some text.
\begin{linenomath}
\begin{align}
x&=1\\
\intertext{More text. More text. More text. More text.
More text. More text. More text. More text. More text.
More text. More text. More text. More text. More text.
More text. More text. More text. More text. More text.}
y&=2
\end{align}
\end{linenomath}
Last line.
\end{document}
有什么方法可以解决这个问题,以便我的文本间段落的三行能够正确编号?(我在环境\intertext
之外使用它而不是常规段落的唯一原因align
是我想保持方程式对齐。)
答案1
这是一种远距离对齐方程的方法。
\documentclass{article}
\usepackage{mathtools}
\usepackage[mathlines]{lineno}
\linenumbers
\thispagestyle{empty}
\newlength{\SplitLeft} \setlength{\SplitLeft}{0pt}
\newlength{\SplitRight} \setlength{\SplitRight}{0pt}
\newlength{\SplitLen}
\newcounter{SplitSet}
\newcounter{SplitUsed}
\newcommand{\Split}[3] % #1 = command, #2 = counter, #3 = argument (if any)
{\csname #1\expandafter\endcsname\csname Split\Alph{#2}\endcsname{#3}}
\newcommand{\splitalign}[2]{ % #1 = left of alignmnet, #2 = right of alignment
\stepcounter{SplitSet}
\Split{newsavebox}{SplitSet}{}
\Split{savebox}{SplitSet}{$\displaystyle{#1}$}
\settowidth{\SplitLen}{\Split{usebox}{SplitSet}{}}
\ifdim\SplitLeft<\SplitLen\setlength{\SplitLeft}{\SplitLen}\fi
\stepcounter{SplitSet}
\Split{newsavebox}{SplitSet}{}
\Split{savebox}{SplitSet}{$\displaystyle{#2}$}
\settowidth{\SplitLen}{\Split{usebox}{SplitSet}{}}
\ifdim\SplitRight<\SplitLen\setlength{\SplitRight}{\SplitLen}\fi
}
\newcommand{\splitdisplay}[0]{
\stepcounter{SplitUsed}
\makebox[\SplitLeft][r]{\Split{usebox}{SplitUsed}{}}\,
\Split{savebox}{SplitUsed}{}
\stepcounter{SplitUsed}
\makebox[\SplitRight][l]{\Split{usebox}{SplitUsed}{}}\,
\Split{savebox}{SplitUsed}{}
\ifnum\value{SplitUsed}=\value{SplitSet}\setcounter{SplitSet}{0}
\setcounter{SplitUsed}{0} \setlength{\SplitLeft}{0pt}
\setlength{\SplitRight}{0pt}\fi
}
\begin{document}
Some text.
\begin{linenomath}
\splitalign{x}{=1}
\splitalign{y}{=2}
\begin{equation}
\splitdisplay
\end{equation}
More text. More text. More text. More text.
More text. More text. More text. More text. More text.
More text. More text. More text. More text. More text.
More text. More text. More text. More text. More text.\\
\begin{equation}
\splitdisplay
\end{equation}
\end{linenomath}
Last line.
\end{document}