0

Suppose I have a document structure like this and I am using hyperref:

Chapter 1 \label{chapter:one}
  Section 1 \label{sec:one}
Chapter 2
...

If I input

\ref{chapter:one}, \ref{sec:one}

I get

1, 1.1

I want to get instead:

Chapter 1, Section 1.1

Can I get this within hyperref? If yes, how?

0

1 Answer 1

1

With hyperref you can use \autoref, like \autoref{chapter:one}, \autoref{sec:one}

If you want to get Chapter and Section instead of chapter and section, you can redefine the auto referencing names to be used.

\documentclass{report}

\usepackage{hyperref}

\renewcommand\chapterautorefname{Chapter} % use Chapter instead of chapter <<<<<<<<<<<
\renewcommand\sectionautorefname{Section} % use Section instead of section <<<<<<<<<<<
    
\begin{document}
    
    \chapter{One}\label{chapter:one}        
    
    \section{First}\label{sec:one}
    
    \chapter{Two}
    
    \autoref{chapter:one}, \autoref{sec:one}    % <<<<<<<<<<<<<<<<<<<<      

\end{document}

b

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