引用页面的特定行

引用页面的特定行

我是 LaTeX 的新手,所以我可能很天真地认为我会得到一个现成的答案,但令我惊讶的是,我找不到这个问题的答案。

我只想引用特定页面的特定行。这样我就可以说“参见第 56 页第 2 行”,并且它会在文档更改时自动更改。

任何建议都将受到高度赞赏!

答案1

不确定这里是否有任何隐藏的警告,但你可以使用这个lineno包来实现这一点。我借用并修改了 egreg 对的回答中的 MWE引用(新)单词首次出现的行号

lineno让您使用 开始在每页上从 1 开始行号\pagewiselinenumbers。我假设您不想显示数字本身,因此我通过将其颜色更改为白色来隐藏它们。

请注意,\pagewiselinenumbers至少需要运行两次编译。

\documentclass[a4paper]{article}
\usepackage{xcolor}
\usepackage{lineno}
\pagewiselinenumbers
\renewcommand\linenumberfont{\color{white}}
\begin{document}
In the traffic court of a large mid-western city, a young
lady was brought before the judge to answer a ticket given
her for driving through a red light. She explained to his
honor that she was a school teacher and requested an immediate
disposal\linelabel{disposal} of her case in order that she might hasten
on to her classes. A wild gleam came into the judge's eye.
"You are a school teacher, eh?" said he. "Madam, I shall
realize my lifelong ambition. Sit down at that table and
write 'I went through a red light' five hundred times."


Line \ref{disposal} on page \pageref{disposal}.

Line \ref{thing} on page \pageref{thing}.

\newpage

In the traffic court of a large mid-western city, a young
lady was brought before the judge to answer a ticket given
her for\linelabel{thing} driving through a red light. She explained to his
honor that she was a school teacher and requested an immediate
disposal of her case in order that she might hasten
on to her classes. A wild gleam came into the judge's eye.
"You are a school teacher, eh?" said he. "Madam, I shall
realize my lifelong ambition. Sit down at that table and
write 'I went through a red light' five hundred times."


\end{document}

相关内容