패키지를 사용하고 있습니다 cleveref
. 내 문서는 다음과 같습니다.
\documentclass{article}
\usepackage{cleveref}
\begin{document}
\tableofcontents
\section{Section A}
Refer to \cref{append} for more details.
\appendix
\renewcommand{\thesection}{\Roman{section}}
\renewcommand{\thesubsection}{\Alph{subsection}}
\renewcommand{\thesubsubsection}{\Roman{subsubsection}}
\section{Appendix}
\subsection{Appendix A}
\subsubsection{Detailed Explanation} \label{append}
blah
\subsection{Appendix B}
\end{document}
부록 자체에는 ToC
.
이제 내 출력이 다음과 같은 내용이기를 원합니다.
섹션 A
자세한 내용은 부록 A, 섹션 I을 참조하십시오.
\crefname
나는 이미 출력을 사용자 정의하는 데 사용하려고 시도했습니다 .
\crefname{secapp}{Anhang \Alph{subsection}, Section}{Appendix \Alph{subsection}, Section}
%Stuff here
\subsubsection{Detailed Explanation} \label[secapp]{append}
그러나 secapp
이렇게 정의하면 호출 cleveref
된 하위 섹션의 번호가 인쇄 됩니다 \cref
.
위에서 설명한 것처럼 출력 형식을 지정하는 방법이 있습니까 cleveref
?
감사해요!
답변1
내 관점에서는 이름 지정/번호 지정 체계가 혼란스럽습니다. 그러나 사용 xassoccnt
및 해당 매크로는 나중에 추출되는 관련 부록 '섹션'에 대해 \RegisterPostLabelHook{\zlabel}
저장하는 추가 레이블을 자동으로 정의합니다 .\thesubsection
\parentCref
\documentclass{article}
\usepackage{lipsum}
\usepackage{xassoccnt}
\usepackage{xpatch}
\usepackage{hyperref}
\usepackage[user,counter,hyperref]{zref}
\usepackage{cleveref}
\makeatletter
\AtEndPreamble{
\newif\if@hyperrefloaded
\@ifpackageloaded{hyperref}{
\@hyperrefloadedtrue
}{
\@hyperrefloadedfalse
}
}
\makeatother
\usepackage{xparse}
% Define a new property named 'appendix'
\makeatletter
\zref@newprop{appendix}{\thesubsection}
% Add the new property to the main property list stored with \zlabel, but for \appendix only
\g@addto@macro{\appendix}{%
\zref@addprops{main}{appendix}%
}
% Command for uppercase output
\NewDocumentCommand{\parentCref}{m}{%
\zref@ifrefundefined{#1}{%
\Cref{#1}%
}{%
\if@hyperrefloaded
\hyperlink{\zref@extract{#1}{anchor}}{\appendixname\ \zref@extract{#1}{appendix}, Section \zref@extract{#1}{default}}%
\else
\appendixname\ \zref@extract{#1}{appendix}, Section \zref@extract{#1}{default}%
\fi
}%
}
\makeatother
\AtBeginDocument{%
\RegisterPostLabelHook{\zlabel}
}
\begin{document}
\section{Normal section} \label{firstsection}
Refer to \parentCref{append} for more details, but don't forget \parentCref{append:b}.
\appendix
\renewcommand{\thesection}{\Roman{section}}
\renewcommand{\thesubsection}{\Alph{subsection}}
\renewcommand{\thesubsubsection}{\Roman{subsubsection}}
\clearpage
\section{Appendix}
\subsection{Appendix A}
\subsubsection{Detailed Explanation} \label{append}
blah
\subsection{Appendix B} \label{appendix:B}
\subsubsection{Even more detailed explanations} \label{append:b}
\end{document}
%\crefname{subsubappendix}{\appendixname \Alph{subsection}, Section}{\appendixname \Alph{subsection}, Section}
\crefformat{subsubappendix}{#2\appendixname\ thesubappendix, Section #1#3}
\Crefformat{subsubappendix}{#2\appendixname\ thesubappendix, Section #1#3}
\begin{document}
\tableofcontents
\section{Section A} \label{firstsection}
Refer to \cref{append} for more details, but don't forget \Cref{append:b}.
\appendix
\renewcommand{\thesection}{\Roman{section}}
\renewcommand{\thesubsection}{\Alph{subsection}}
\renewcommand{\thesubsubsection}{\Roman{subsubsection}}
\section{Appendix}
\subsection{Appendix A}
\subsubsection{Detailed Explanation} \label{append}
blah
\subsection{Appendix B} \label{appendix:B}
\subsubsection{Even more detailed explanations} \label{append:b}
\end{document}