article
我正在尝试使用包为正在编写的添加行号lineno
。大多数情况下,这种方法效果很好,但表格除外(使用tabulary
):将整个表格计为一行是可行的,但当我使用edtable.sty
(部分lineno
)时,它似乎跳过了几行:
\documentclass{article}
\usepackage{tabulary}
\usepackage[edtable]{lineno}
\begin{document}
\linenumbers
Lorem ipsum dolor sit amet. \verb+\lineno+ will skip 2 lines:
\vspace{2em}\begin{edtable}{tabulary}{\linewidth}{LR}
This sentence no verb. & \\\hline
I would like to know: & Where are the missing two lines? \\\hline
\end{edtable}\vspace{2em}
And now without \verb+edtable+:
\vspace{2em}\begin{tabulary}{\linewidth}{RL}
The table will be counted & as a single line. \\\hline
Regardless & of \\\hline
actual & length \\\hline
\end{tabulary}\vspace{2em}
This concludes our demonstration.
\end{document}
我可以手动减少行数吗?我使用此pagewise
选项,并且只有几个表,因此这是一个可接受的解决方法。或者其他软件包?
编辑:
根据 David 的建议,我尝试将电流存储linenumber
在计数器中,并在内重置为该计数器tabulary
,如下所示:
\documentclass{article}
\usepackage{tabulary}
\usepackage[edtable]{lineno}
\begin{document}
\linenumbers
Lorem ipsum dolor sit amet.
\newcounter{myfoo}\setcounter{myfoo}{\value{linenumber}}
\begin{edtable}{tabulary}{\linewidth}{LR}
\setcounter{linenumber}{\value{myfoo}}
The counter reset kicks in & too late, though. \\\hline
Notice line numbers & 1-4-reset-3\\\hline
\end{edtable}
\end{document}
但此时已经太迟了,已经写入了错误的行号。有没有办法在 内更早地重置tabularray
?我尝试过,但\AtBeginEnvironment
没有成功。
答案1
您可以在试运行结束时将计数器重新设置(您可以检测到,因为显示数学在试验中是内联的)
\documentclass{article}
\usepackage{tabulary}
\usepackage[edtable]{lineno}
\begin{document}
\linenumbers
Lorem ipsum dolor sit amet.
\newcounter{myfoo}\setcounter{myfoo}{\numexpr\value{linenumber}-1}
\begin{edtable}{tabulary}{\linewidth}{LR}
The counter reset kicks in & too late, though. \\\hline
Notice line numbers & 1-4-reset-3%
\ifx\equation$\setcounter{linenumber}{\value{myfoo}}\fi
\\\hline
\end{edtable}
Lorem ipsum dolor sit amet.
\end{document}