0

Is it possible to use \autoref to reference a range of sections? I would like to replace

In Sections \ref{section1} -- \ref{section3} ...

with something like

In \autoref{section1, section2, section3} ...

As far as I know this is possible for citations, but does any package also offer this feature for references?

1 Answer 1

4

I don't know about autoref, but you did ask for package alternatives. The package cleveref provides this. With cleveref you would need to encode your section lables with the preceeding sec:. Writing the appended code produces

... sections 1 to 3.

We didn't even need to provide the sections in order! If you want

... sections 1 - 3

then use the simple answer to this post.

\documentclass{article}
\usepackage{cleveref}

\begin{document}
    
\section{Name A}
\label{sec:a}
Blah Blah Blah.

\section{Name B}
\label{sec:b}
Blah Blah Blah.

\section{Name C}
\label{sec:c}
Blah Blah Blah.

\section{Conclusion}
\label{sec:conclusion}

We draw this conclusion from the discussion in \cref{sec:a,sec:c,sec:b}.
Alternatively, may write \crefrange{sec:a}{sec:c}.

\end{document}

Output generated by the above code.

2
  • Also, I'm sorry that I don't know how to add pdf output to my answer.
    – Sveiaam
    Jun 22, 2021 at 14:38
  • Simply make a screenshot and add the output as a picture:-) Jun 22, 2021 at 14:48

You must log in to answer this question.

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