
ドキュメントの一部について、付録セクションの参照方法を変更したいと思います。メインテキストでは「付録 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}