文章目录
对过时宏包及命令的检测
nag
宏包用于检测文档中是否使用已经被淘汰了的宏包以及过时的命令,如果你的代码没问题,这个宏包将不会做任何事情。
注意: 需要把这个宏包放在你的导言区的第一行(甚至在 \documentclass 之前)。
如:
\RequirePackage[l2tabu, orthodox]{nag}
\documentclass{ctexart}
关于nag宏包的细节,请在命令行使用texdoc nag或访问 https://ctan.org/pkg/nag 查看其使用说明。
显示行号
在使用lineno
宏包来显示文档的行号时,会发现默认情况下,gather
align
等公式环境中的公式不会显示行号。
但是可以通过重新定义命令使这两个宏包进行 patch, 在导言区添加下面这段代码
%%%%%%%%%%%%%%%%%%%%
\usepackage{etoolbox} %% <- for \pretocmd, \apptocmd and \patchcmd
%% Patch 'normal' math environment: (currently unused, but good to have)
% \newcommand*\linenomathpatch[1]{%
% \expandafter\pretocmd\csname #1\endcsname {\linenomath}{}{}%
% \expandafter\pretocmd\csname #1*\endcsname{\linenomath}{}{}%
% \expandafter\apptocmd\csname end#1\endcsname {\endlinenomath}{}{}%
% \expandafter\apptocmd\csname end#1*\endcsname{\endlinenomath}{}{}%
% }
%% Patch AMS math environment:
\newcommand*\linenomathpatchAMS[1]{%
\expandafter\pretocmd\csname #1\endcsname {\linenomathAMS}{}{}%
\expandafter\pretocmd\csname #1*\endcsname{\linenomathAMS}{}{}%
\expandafter\apptocmd\csname end#1\endcsname {\endlinenomath}{}{}%
\expandafter\apptocmd\csname end#1*\endcsname{\endlinenomath}{}{}%
}
%% Definition of \linenomathAMS depends on whether the mathlines option is provided
\expandafter\ifx\linenomath\linenomathWithnumbers
\let\linenomathAMS\linenomathWithnumbers
%% The following line gets rid of an extra line numbers at the bottom:
\patchcmd\linenomathAMS{\advance\postdisplaypenalty\linenopenalty}{}{}{}
\else
\let\linenomathAMS\linenomathNonumbers
\fi
% \linenomathpatch{equation} %% <- unnecessary, equation is already patched
\linenomathpatchAMS{gather}
\linenomathpatchAMS{multline}
\linenomathpatchAMS{align}
\linenomathpatchAMS{alignat}
\linenomathpatchAMS{flalign}
%%%%%%%%%%%%%%%%%%%%