如何抑制单个附录章节的编号?

如何抑制单个附录章节的编号?

考虑文件中保存的以下 LaTeX 代码Thesis.tex

% arara: lualatex
% arara: lualatex
\documentclass[openany]{scrbook}

\usepackage{xr-hyper, hyperref}
\hypersetup{colorlinks=true}
\usepackage[nameinlink]{cleveref}

\title{}
\author{}
\date{}

\begin{document}

\tableofcontents

\chapter{The Beginning}\label{ch1}
In \cref{ch2} everything will become clear, but only with the help of \cref{app}, and specifically the results of \cref{ap1}.

\chapter{The End}\label{ch2}
That's all, folks!

\appendix

\chapter{Appendix}\label{app}

\section{Helpful Stuff}\label{ap1}
Help thy brother’s boat across, and --- lo! --- thine own has reached the shore.

\section{Hints for Further Reading}\label{ap2}
A reader lives a thousand lives before he dies. The man who never reads lives only one.

\end{document}

在命令提示符下执行arara Thesis成功终止,并产生以下输出:

实际输出

我希望目录中以及第 4 页上的A旁边的字母被隐藏,但附录的两个部分不隐藏。此外,我希望第 2 页上的附录链接显示为:而不是。希望下图能清楚地说明我的意图。Appendixthe appendixappendix A

期望的输出

注意:由于某些神秘的原因,我的屏幕捕获应用程序无法正确捕获第 3 页,在这两种情况下,该页面都应该如下所示:

第3页

答案1

您可以为附录定义新的参考格式:

\crefname{appendixwithoutnumber}{appendix}{appendices}
\crefformat{appendixwithoutnumber}{#2\MakeLowercase{\appendixname}#3}
\Crefformat{appendixwithoutnumber}{#2\appendixname#3}

然后,您可以使用以下格式作为附录标签:

\label[appendixwithoutnumber]{app}

要获取带有目录和标题条目的未编号附录章节,请使用\addchap

\AddtoOneTimeDoHook{heading/begingroup}{\refstepcounter}
\addchap{Appendix}\label[appendixwithoutnumber]{app}

例子:

% arara: lualatex
% arara: lualatex
\documentclass[open=any]{scrbook}
\usepackage{xr-hyper, hyperref}
\hypersetup{colorlinks=true}
\usepackage[nameinlink]{cleveref}

\crefname{appendixwithoutnumber}{appendix}{appendices}
\crefformat{appendixwithoutnumber}{#2\MakeLowercase{\appendixname}#3}
\Crefformat{appendixwithoutnumber}{#2\appendixname#3}

\title{}
\author{}
\date{}

\begin{document}

\tableofcontents

\chapter{The Beginning}\label{ch1}
In \cref{ch2} everything will become clear, but only with the help of \cref{app}, and specifically the results of \cref{ap1}.

\chapter{The End}\label{ch2}
That's all, folks!

\appendix

\AddtoOneTimeDoHook{heading/begingroup}{\refstepcounter}
\addchap{Appendix}\label[appendixwithoutnumber]{app}

\section{Helpful Stuff}\label{ap1}
Help thy brother’s boat across, and --- lo! --- thine own has reached the shore.

\section{Hints for Further Reading}\label{ap2}
A reader lives a thousand lives before he dies. The man who never reads lives only one.

\end{document}

在此处输入图片描述


如果对附录的引用实际上应该是“附录”,则使用

\crefname{appendixwithoutnumber}{appendix}{appendices}
\crefformat{appendixwithoutnumber}{#2the \MakeLowercase{\appendixname}#3}
\Crefformat{appendixwithoutnumber}{#2The \MakeLowercase{\appendixname}#3}

如果 »the« 或 »The« 应打印但不是链接的一部分,请使用

\crefname{appendixwithoutnumber}{appendix}{appendices}
\crefformat{appendixwithoutnumber}{the #2\MakeLowercase{\appendixname}#3}
\Crefformat{appendixwithoutnumber}{The #2\MakeLowercase{\appendixname}#3}

答案2

我会选择以下方式:

\chapter*{Appendix}
\addcontentsline{toc}{chapter}{Appendix}
\refstepcounter{chapter}
\label{app}

在全:

% arara: lualatex
% arara: lualatex
\documentclass[openany]{scrbook}

\usepackage{xr-hyper, hyperref}
\hypersetup{colorlinks=true}
\usepackage[nameinlink]{cleveref}

\title{}
\author{}
\date{}

\begin{document}

\tableofcontents

\chapter{The Beginning}\label{ch1}
In \cref{ch2} everything will become clear, but only with the help of the \nameref{app}, and specifically the results of \cref{ap1}.

\chapter{The End}\label{ch2}
That's all, folks!

\appendix

\chapter*{Appendix}
\addcontentsline{toc}{chapter}{Appendix}
\refstepcounter{chapter}
\label{app}

\section{Helpful Stuff}\label{ap1}
Help thy brother’s boat across, and --- lo! --- thine own has reached the shore.

\section{Hints for Further Reading}\label{ap2}
A reader lives a thousand lives before he dies. The man who never reads lives only one.

\end{document}

在此处输入图片描述

在此处输入图片描述

在此处输入图片描述

相关内容