0

I wish to reference-call my sections in the style "(curly-S)2.1". Looking at the documentation, Section 8.2.1, I can achieve this as \Crefformat{section}{\S#2#1#3}. However, this doesn't work when the section is an appendix. There are lots of questions on cleveref+appendix, but I haven't been able to find a solution in them.

I can, of course, simply use \renewcommand{\thesection}{\Alph{section}} and reset the counter. It feels like there should be a much better way...


Currently everything is set up as default for article. The following is a simple MWE.

\documentclass[]{article}

\usepackage{cleveref}
\Crefformat{section}{\S#2#1#3}

\begin{document}

\section{Main Section}
\label{main}
\appendix
\section{Appendix Section}
\label{app}

\Cref{main}

\Cref{app}

\end{document}
  • How are the section headers displayed at present? As 1 [title], 2 [title], ... A [title], B [title]? Do you prefix the \S symbol to the section-level headers? ? Which document class do you employ? Please be specific. – Mico Jul 25 at 16:31
  • Everything is default, other than the one \Crefformat{...}{...} that I describe. I actually solved it anyway with a guess! (and answered below) – Sam T Jul 25 at 20:57
0

Although I couldn't find this answer, I actually managed to guess it! Simply add \Crefformat{appendix}{\S#2#1#3}. Basically, the counter is just called appendix instead of section. See below.

\documentclass[]{article}

\usepackage{cleveref}
\Crefformat{section}{\S#2#1#3}
\Crefformat{appendix}{\S#2#1#3}

\begin{document}

\section{Main Section}
\label{main}
\subsection{Main Subsectino}
\label{submain}

\appendix
\section{Appendix Section}
\label{app}
\subsection{Appendix Subsection}
\label{subapp}

\Cref{main}

\Cref{submain}

\Cref{app}

\Cref{subapp}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.