来自这样的 MWE:
\documentclass{report}
\usepackage[backref,totoc=chapter,counter-format=Roman,split=chapter]{enotez}
\setenotez{split-title={\chaptername\ <ref>}}
\begin{document}
\chapter{Introduction}
Some text with an endnote.\endnote{Once upon a time\dots}
\printendnotes
\end{document}
我得到以下信息:
有没有办法也可以获取章节名称?例如:Chapter 1 -- Introduction
。我发现这个答案,但它只在当前章节或部分内有效......enotez 手册也没有提供太多帮助......
先感谢您。
答案1
这是一个不太明显的解决方案,它依赖于nameref
并重新定义,\chapter
以便自动在其后放置一个标签,然后可以使用。请注意,这仅在您的所有尾注都处于编号章节…
\documentclass{report}
\usepackage{enotez}
\setenotez{
backref,
totoc=chapter,
counter-format=Roman,
split=chapter,
split-title={\chaptername\ <ref> -- <title>}
}
\NewSplitTitleTag{title}{\nameref{ch:<split-level-id>}}
\usepackage{nameref}% automatically loaded if you use hyperref
\usepackage{letltxmacro}
\LetLtxMacro\origchapter\chapter
\RenewDocumentCommand\chapter{som}{%
\IfBooleanTF{#1}
{% starred chapter, no label then
\origchapter*{#3}%
}
{% else add a label
\IfNoValueTF{#2}
{\origchapter{#3}}
{\origchapter[#2]{#3}}%
\expanded{\noexpand\label{ch:\arabic{chapter}}}%
}%
}
\begin{document}
\chapter{Introduction}
Some text with an endnote.\endnote{Once upon a time\dots}
\chapter{Second Chapter}
Some text with an endnote.\endnote{Twice upon a time\dots}
\chapter{And another one}
Some text with an endnote.\endnote{Another endnote\dots}
\printendnotes
\end{document}