
我想更改文件中附錄部分的引用方式:我希望正文中包含“附錄 A.1”,附錄中包含“A.1 節”。
我嘗試了以下方法:
\documentclass{scrartcl}
\usepackage{cleveref}
\begin{document}
\cref{foo} and \cref{bar}
\appendix
\crefname{subappendix}{section}{sections}
\section{Foo}\label{foo}
\cref{foo} and \cref{bar}
\subsection{Bar}\label{bar}
\end{document}
我期望的輸出如下:
附錄 A 及附錄 A.1
阿福
附錄 A 和A.1 節
A.1 酒吧
但我還在附錄中得到了「附錄A.1」。
看來我只能\crefname
在序言中使用並影響整個文件。有沒有辦法只更改附錄的參考名稱?
答案1
該apptools
包引入了相關條件\IfAppendix
和\ifappendix
:
\documentclass{scrartcl}
\usepackage{cleveref}
\usepackage{apptools}
\crefname{subappendix}{\IfAppendix{section}{appendix}}{\IfAppendix{sections}{appendices}s}
\begin{document}
\cref{foo} and \cref{bar}
\appendix
\section{Foo}\label{foo}
\cref{foo} and \cref{bar}
\subsection{Bar}\label{bar}
\end{document}