[Tex/LaTex] How to show symbol § when I refer a chapter

symbols

I'm writing my thesis and I would like that the reference of the chapters, sections, etc… appears with symbol §, e.g.:

…as can be seen in §4.1.1

What package or reference/label combination do I need to use?
Thanks

Best Answer

You can get automatically the § symbol (which I don't recommend, though) with cleveref and its \cref command.

It's better to have a different command than \ref, because you might need the latter for referring the section without the § prefix. The § symbol is obtained with \S.

\documentclass{article}

%\usepackage{hyperref} % not needed; should go before cleveref if loaded
\usepackage{cleveref}

\crefformat{section}{\S#2#1#3} % see manual of cleveref, section 8.2.1
\crefformat{subsection}{\S#2#1#3}
\crefformat{subsubsection}{\S#2#1#3}

\begin{document}

\section{A section}\label{sec:section}

\subsection{A subsection}\label{sec:subsection}

\subsubsection{A subsubsection}\label{sec:subsubsection}

See \cref{sec:section}, \cref{sec:subsection} or \cref{sec:subsubsection}.

\end{document}

enter image description here

You can also format multiple references; here's a starting point.

\documentclass{article}

%\usepackage{hyperref} % not needed; should go before cleveref if loaded
\usepackage{cleveref}

\crefformat{section}{\S#2#1#3}
\crefformat{subsection}{\S#2#1#3}
\crefformat{subsubsection}{\S#2#1#3}
\crefrangeformat{section}{\S\S#3#1#4 to~#5#2#6}
\crefmultiformat{section}{\S\S#2#1#3}{ and~#2#1#3}{, #2#1#3}{ and~#2#1#3}

\begin{document}

\section{A section}\label{sec:section}

\subsection{A subsection}\label{sec:subsection}

\subsubsection{A subsubsection}\label{sec:subsubsection}

\section{Another}\label{sec:another}

\section{Again}\label{sec:again}

See \cref{sec:section}, \cref{sec:subsection} or \cref{sec:subsubsection}.

See \cref{sec:section,sec:another,sec:again}

See \cref{sec:again,sec:section}

See \cref{sec:again,sec:subsection}

See \cref{sec:subsection,sec:subsubsection}

\end{document}

enter image description here