Eu tenho uma seção de apêndices personalizados, que inclui vários apêndices diferentes, por exemplo, Apêndice A, Apêndice B e assim por diante. Dentro de cada apêndice, tenho tabelas, figuras e às vezes também páginas retiradas de um PDF (que não são figuras) e, portanto, não as coloco como tal, mas dou-lhes um título de seção personalizado que não aparece no índice analítico . Aqui está um MWE.
\documentclass[12pt, a4paper]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[dvips]{graphicx} % to include images
\usepackage[bookmarksnumbered, breaklinks=true,colorlinks=true, linkcolor=black, urlcolor=blue, citecolor=blue, bookmarks=true]{hyperref}
\usepackage[nameinlink,noabbrev]{cleveref}
\crefname{page}{p.}{pp.}
\crefname{figure}{figure}{figures}
\settypeblocksize{237mm}{150mm}{*} % size of text block on page
\setulmargins{3.5cm}{*}{*} % sets start of text on page after ruled header
\setheadfoot{\onelineskip}{2\onelineskip}
\setheaderspaces{2cm}{*}{*} % start of rule header line on page
\setlrmarginsandblock{3.5cm}{2.5cm}{*} % left and right margins
\checkandfixthelayout
%%% MAKE CHAPTER IN APPENDIX LOOK LIKE SECTIONS
\cftinsertcode{APP}{
\setlength\cftchapterindent{\cftsectionindent}
\setlength\cftbeforechapterskip{0pt}
\renewcommand*{\cftappendixname}{\appendixname\space}
\renewcommand{\cftchapteraftersnum}{:}
\renewcommand\cftchapterdotsep{\cftdotsep} % Chapters should use dots in ToC
\renewcommand\cftchapterfont{\normalfont}
\renewcommand\cftchapterpagefont{\normalfont}
}
%%% PREVENT APPENDIX SECTIONS TO BE ADDED TO TOC
\newcommand{\nocontentsline}[3]{}
\newcommand{\tocless}[2]{\bgroup\let\addcontentsline=\nocontentsline#1{#2}\egroup}
%%% CUSTOM CHAPTER STYLE FOR APPENDICES
\makechapterstyle{appendix}{%
\chapterstyle{default}
\setlength{\beforechapskip}{3.5ex}
\renewcommand*{\chapterheadstart}{\vspace{\beforechapskip}}
\setlength{\afterchapskip}{2.3ex}
\renewcommand{\chapnumfont}{\normalfont\bfseries\Large}
\renewcommand{\chapnamefont}{\normalfont\bfseries\Large}
\renewcommand{\chaptitlefont}{\normalfont\bfseries\Large}
\renewcommand{\printchapternum}{\chapnumfont~\thechapter}
\renewcommand{\afterchapternum}{:\space}
}
\renewcommand{\contentsname}{Table of Contents}
\maxsecnumdepth{subsubsection} % chapters, sections, subsections numbered
\maxtocdepth{subsection}
\begin{document}
% TABLE OF CONTENTS
\SingleSpacing
\tableofcontents*
\clearpage % Force a break to new page
\chapter{Chapter title}
\section{A first section title}
\section{A second section title}
Just some text. I'd like to reference Appendix A2 here by doing (see \Cref{appendix:A2}, \cpageref{appendix:A2}), but it only references to A not to A2.
\appendix
\appendixpage % cover page appendix
\cftinserthook{toc}{APP}
\chapterstyle{appendix}
%appendix A content
\chapter{Some title for first appendix}
\label{appendix:A}
\tocless\section{Information Form - Page 1/2}
\begin{figure}[!htb]
\label{appendix:A1}
\fbox{\includegraphics[page=1,width=14.5cm]{info.pdf}}
\end{figure}
\tocless\section{Information Form - Page 2/2}
\begin{figure}[!htb]
\label{appendix:A2}
\fbox{\includegraphics[page=2,width=14.5cm]{info.pdf}}
\end{figure}
\chapter{Some title for next appendix}
\label{appendix:B}
Nothing here yet.
\end{document}
Aqui está o que parece depois de compiladoExemplo de PDF... Meu problema é que gostaria de fazer referência ao Apêndice A2 no texto. No momento a referência é o Apêndice A, mas deveria ser o Apêndice A2. Alguma sugestão de como isso pode ser alcançado? Obrigado.
Responder1
Usar \label
sem \caption
é inútil aí, pois precisa de um \refstepcounter
comando com antecedência, que é feito internamente por \caption, ou seja, um manual \refstepcounter{figure}\label{...}
deve resolver seu problema para ambos os exemplos, mas isso pode se tornar tedioso se você tiver mais seções 'falsas' sem legenda .
\documentclass[12pt, a4paper]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[demo]{graphicx} % to include images
\usepackage[bookmarksnumbered, breaklinks=true,colorlinks=true, linkcolor=black, urlcolor=blue, citecolor=blue, bookmarks=true]{hyperref}
\usepackage[nameinlink,noabbrev]{cleveref}
\crefname{page}{p.}{pp.}
\crefname{figure}{figure}{figures}
\settypeblocksize{237mm}{150mm}{*} % size of text block on page
\setulmargins{3.5cm}{*}{*} % sets start of text on page after ruled header
\setheadfoot{\onelineskip}{2\onelineskip}
\setheaderspaces{2cm}{*}{*} % start of rule header line on page
\setlrmarginsandblock{3.5cm}{2.5cm}{*} % left and right margins
\checkandfixthelayout
%%% MAKE CHAPTER IN APPENDIX LOOK LIKE SECTIONS
\cftinsertcode{APP}{
\setlength\cftchapterindent{\cftsectionindent}
\setlength\cftbeforechapterskip{0pt}
\renewcommand*{\cftappendixname}{\appendixname\space}
\renewcommand{\cftchapteraftersnum}{:}
\renewcommand\cftchapterdotsep{\cftdotsep} % Chapters should use dots in ToC
\renewcommand\cftchapterfont{\normalfont}
\renewcommand\cftchapterpagefont{\normalfont}
}
%%% PREVENT APPENDIX SECTIONS TO BE ADDED TO TOC
\newcommand{\nocontentsline}[3]{}
\newcommand{\tocless}[2]{\bgroup\let\addcontentsline=\nocontentsline#1{#2}\egroup}
%%% CUSTOM CHAPTER STYLE FOR APPENDICES
\makechapterstyle{appendix}{%
\chapterstyle{default}
\setlength{\beforechapskip}{3.5ex}
\renewcommand*{\chapterheadstart}{\vspace{\beforechapskip}}
\setlength{\afterchapskip}{2.3ex}
\renewcommand{\chapnumfont}{\normalfont\bfseries\Large}
\renewcommand{\chapnamefont}{\normalfont\bfseries\Large}
\renewcommand{\chaptitlefont}{\normalfont\bfseries\Large}
\renewcommand{\printchapternum}{\chapnumfont~\thechapter}
\renewcommand{\afterchapternum}{:\space}
}
\renewcommand{\contentsname}{Table of Contents}
\maxsecnumdepth{subsubsection} % chapters, sections, subsections numbered
\maxtocdepth{subsection}
\begin{document}
% TABLE OF CONTENTS
\SingleSpacing
\tableofcontents*
\clearpage % Force a break to new page
\chapter{Chapter title}
\section{A first section title}
\section{A second section title}
Just some text. I'd like to reference Appendix A2 here by doing (see \Cref{appendix:A2}, \cpageref{appendix:A2}), but it only references to A not to A2.
\appendix
\appendixpage % cover page appendix
\cftinserthook{toc}{APP}
\chapterstyle{appendix}
%appendix A content
\chapter{Some title for first appendix}
\label{appendix:A}
\tocless\section{Information Form - Page 1/2}
\begin{figure}[!htb]
\refstepcounter{figure}%
\label{appendix:A1}
\fbox{\includegraphics[page=1,width=14.5cm]{info.pdf}}
\end{figure}
\tocless\section{Information Form - Page 2/2}
\begin{figure}[!htb]
\refstepcounter{figure}%
\label{appendix:A2}
\fbox{\includegraphics[page=2,width=14.5cm]{info.pdf}}
\end{figure}
\chapter{Some title for next appendix}
\label{appendix:B}
Nothing here yet.
\end{document}