scrlayer-scrpage
在与 结合使用时,我很难让页眉正常工作enotez
。我已经发现目前不可能为编号和未编号的章节添加尾注(请参阅:这里和这里)因此,很遗憾,我删除了未编号章节中的尾注。
\printendnotes
但是,当与 koma-script 结合使用时,我仍然会得到最后一章的错误标题标签scrlayer-scrpage
。
这是我的 MWE:
\documentclass[paper = 155mm:220mm]{scrbook}
\usepackage{blindtext}
\usepackage{libertine}
\usepackage{scrlayer-scrpage}% sets pagestyle scrheadings automatically
\automark{chapter}
\renewcommand*\chaptermark[1]{%
\markboth{\ifnumbered{chapter}{\chaptermarkformat}{#1}}{#1}%
}
% enotez
\usepackage{enotez}
\setenotez{
list-heading = \addchap{#1},
list-name = {Supplemental material by chapter},
backref,
split=chapter,
reset=true,
split-title={\chaptername\ <ref>: <title>}
}
\DeclareInstance{enotez-list}{chapter}{paragraph}{heading=\chapter{#1}}
\NewSplitTitleTag{title}{\nameref{ch:<split-level-id>}}
\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}}}%
}%
}
\usepackage{hyperref}
\begin{document}
\tableofcontents
\addchap{Prologue}
The first unnumberd chapter is the prologue.
\Blindtext[7]
\chapter{The First Day}
The first numbered chapter. This is something\endnote{That is the first day’s endnote. Something is a word.} you should consider.
\Blindtext[7]
\chapter{The Second Day}
The second numbered chapter. This is another\endnote{That is the second day’s endnote. Another is a word.} thing you should consider.
\Blindtext[7]
\chapter{The Third Day}
The third numbered chapter. I have no\endnote{That is the third day’s endnote. No means no yet.} idea what to talk about.
\Blindtext[7]
\addchap{Epilogue}
The last unnumberd chapter is the epilogue.
\Blindtext[7]
\printendnotes
\Blindtext[7]
\addchap{References}
\Blindtext[7]
\addchap{Literature}
\Blindtext[7]
\end{document}
要求
解决方案不应该破坏运行头
- 编号章节的页眉:
- 左侧(偶数):第 n 章
- 右侧(奇数):章节标题
- 无编号章节的页眉:两侧均有标题
我是否应该放弃scrlayer-scrpage
,然后去碰碰运气fancyhdr
呢?
编辑
请注意,如果我切换到使用chapter*{}
,它会破坏我的运行头,但如果修复了列表\printendnotes
答案1
日志文件会非常明确地警告您:您定义了多个标签,因为 \addchap 在内部使用 \chapter,因此在重新定义后也会发出标签。对编号章节进行测试,就像对 \chaptermark 进行测试一样。
您还应该定义 \theHendnote 以获取唯一的目的地。
\documentclass[paper = 155mm:220mm]{scrbook}
\usepackage{blindtext}
\usepackage{libertine}
\usepackage{scrlayer-scrpage}% sets pagestyle scrheadings automatically
\automark{chapter}
\renewcommand*\chaptermark[1]{%
\markboth{\Ifnumbered{chapter}{\chaptermarkformat}{#1}}{#1}%
}
% enotez
\usepackage{enotez}
\setenotez{
list-heading = \addchap{#1},
list-name = {Supplemental material by chapter},
backref,
split=chapter,
reset=true,
split-title={\chaptername\ <ref>: <title>}
}
\DeclareInstance{enotez-list}{chapter}{paragraph}{heading=\chapter{#1}}
\NewSplitTitleTag{title}{\nameref{ch:<split-level-id>}}
\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}}%
\Ifnumbered{chapter}{\label{ch:\arabic{chapter}}}{}% %<--- only labels for numbered chapters
}%
}
\usepackage{hyperref}
\newcommand\theHendnote{\arabic{chapter}.\theendnote} %<--- for hyperref
\begin{document}
\tableofcontents
\addchap{Prologue}
The first unnumberd chapter is the prologue.
\Blindtext[7]
\chapter{The First Day}
The first numbered chapter. This is something\endnote{That is the first day’s endnote. Something is a word.} you should consider.
\Blindtext[7]
\chapter{The Second Day}
The second numbered chapter. This is another\endnote{That is the second day’s endnote. Another is a word.} thing you should consider.
\Blindtext[7]
\chapter{The Third Day}
The third numbered chapter. I have no\endnote{That is the third day’s endnote. No means no yet.} idea what to talk about.
\Blindtext[7]
\addchap{Epilogue}
The last unnumberd chapter is the epilogue.
\Blindtext[7]
\printendnotes
\Blindtext[7]
\addchap{References}
\Blindtext[7]
\addchap{Literature}
\Blindtext[7]
\end{document}