对于我的工作结构,我需要在文档中有一个未编号的章节。我发现可以用
\chapter*{chapter1} %or with
\addchap{chapter1}
但现在我需要从另一章中引用本章的文本和图片。超链接工作正常,但由于我没有编号,因此使用前一章的编号(甚至在我的图片列表中)。
为了更清楚地说明我的问题是什么,这里有一个简单的例子:
\documentclass{scrreprt}
\begin{document}
\tableofcontents
\chapter{Chapter 1}
\section{Something}
\subsection{Subsection 1}
At this point I'd like to refer to an Image and a short text in the
attachment. See here: \ref{my_reference}.
\chapter{Chapter 2}
\section{\ldots}
\chapter{Chapter 3}
\chapter{Chapter 4}
\chapter{Chapter 5}
\addchap{Attachment}
\section*{First Attachment}
\addcontentsline{toc}{section}{First Attachment}
\subsection*{This is very important stuff}
\addcontentsline{toc}{subsection}{This is very important stuff}
\label{my_reference}
Yeah this stuff is so important, that i definitly want to refer this text in
the first chapter.
\end{document}
我得到的结果是:“看这里:5.“但我想要一个
“看这里:6.1.1.“
但我不想让我的“附件”章节在目录中有编号。这可能吗?我考虑过用自定义“标签”命令自己给它编号。但问题仍然存在,因为我的“图表列表”问题。
提前致谢
答案1
\documentclass{scrreprt}
\begin{document}
\tableofcontents
\chapter{Chapter 1}
\section{Something}
\subsection{Subsection 1}
At this point I'd like to refer to an Image and a short text in the
attachment. See here: \ref{my_reference}.
\chapter{Chapter 2}
\section{\ldots}
\chapter{Chapter 3}
\chapter{Chapter 4}
\chapter{Chapter 5}
\addchap{Attachment}\refstepcounter{chapter}
\section*{First Attachment}\refstepcounter{section}
\addcontentsline{toc}{section}{First Attachment}
\subsection*{This is very important stuff}\refstepcounter{subsection}
\addcontentsline{toc}{subsection}{This is very important stuff}
\label{my_reference}
Yeah this stuff is so important, that i definitly want to refer this text in
the first chapter.
\end{document}
答案2
我怀疑许多读者在遇到对编号为“6.1.1”的对象的交叉引用时会感到困惑,尽管文档中实际上没有单个对象的编号为“6.1.1”。是否可以合理地假设读者会发现被交叉引用的对象是未编号的子节?
我知道hyperref
将会加载(尽管目前您的示例代码中并非如此)。如果这个假设是正确的,那么有一个解决方案可用,它不依赖于创建实际上不会出现在任何地方的虚拟节和子节编号。我建议您 (a) 在未编号子节的开头插入一个“\hypertarget”,例如通过
\addchap{Attachment}
\section*{First Attachment}
\addcontentsline{toc}{section}{First Attachment}
\hypertarget{my_ref}{} %% <- this is the crucial addition
\subsection*{This is very important stuff}
\addcontentsline{toc}{subsection}{This is very important stuff}
(b)\hyperlink
在文档的其他地方插入一条指令,鼓励读者“跳转”到附件:
\subsection{Subsection 1}
At this point I'd like to refer to an Image and a short text in the
attachment: \hyperlink{my_ref}{See here}.
通过此设置,“参见此处”字符串是可点击的,并且如果读者点击此字符串,他/她将直接带到感兴趣的附件。