1

I have a customised appendices section, which includes several different appendix, e.g., Appendix A, Appendix B and so on. Within each appendix, I have tables, figures and sometimes also Pages taken from a PDF (which are not figures) and thus I don't caption them as such, but give them a custom section heading which does not appear in the table of contents. Here is a 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}

Here is what it looks like once compiled Example PDF... My problem is, that I would like to reference Appendix A2 in-text. At the moment the reference reads Appendix A, but it should read Appendix A2. Any suggestions how this can be achieved? Thanks.

4
  • The example is not complete yet.
    – user31729
    Apr 16, 2017 at 23:42
  • 1
    Using \label without \caption is useless there, since it needs a \refstepcounter command in advance, which is done internally by \caption, i.e. a manual \refstepcounter{figure}\label{...} should solve your problem for both examples, but this might get tedious if you have more of such captionless 'fake' - sections
    – user31729
    Apr 16, 2017 at 23:44
  • @ChristianHupfer, yes that works nicely. Thank you. As you say though, it will probably get tedious, and I may have to rethink the way I am handling this in general. If anyone has suggestions/thoughts/opinions on handling captions for non-figures, I'd appreciate it. Ps. Christian, if you'd like to add your comment as an answer?
    – Tina
    Apr 16, 2017 at 23:54
  • 1
    Doneeeeeeeeeeeeeeeeee! ;-) I will think about a better approach to simplify this manual increment of the counter
    – user31729
    Apr 16, 2017 at 23:56

1 Answer 1

1

Using \label without \caption is useless there, since it needs a \refstepcounter command in advance, which is done internally by \caption, i.e. a manual \refstepcounter{figure}\label{...} should solve your problem for both examples, but this might get tedious if you have more of such captionless 'fake' - sections.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .