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}
2
  • 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, 2019 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 OT
    Jul 25, 2019 at 20:57

1 Answer 1

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}

You must log in to answer this question.

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