smartef: personalize a saída \cref

smartef: personalize a saída \cref

Estou usando o cleverefpacote. Meu documento é mais ou menos assim:

\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}

Eu tenho que usar subseções e subseções dessa maneira, porque o próprio apêndice deve ter sua própria entrada e número de seção no arquivo ToC.

Agora quero que minha saída seja algo como

Seção a

Consulte o Apêndice A, Seção I para obter mais detalhes.

Já tentei usar \crefnamepara customizar a saída:

\crefname{secapp}{Anhang \Alph{subsection}, Section}{Appendix \Alph{subsection}, Section}

%Stuff here
\subsubsection{Detailed Explanation} \label[secapp]{append}

mas definir secappassim faz com que cleverefimprima o número da subseção em que \creffoi chamado.

Existe uma maneira de formatar a saída conforme descrito acima usando cleveref?

Obrigado!

Responder1

O esquema de nomenclatura/numeração é confuso, no meu ponto de vista, mas usar xassoccnte sua \RegisterPostLabelHook{\zlabel}macro define automaticamente rótulos extras, armazenando os \thesubsectionpara a 'seção' do apêndice relevante, que é extraído posteriormente \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}

insira a descrição da imagem aqui

informação relacionada