I am using cleveref
to cross-reference my thesis. When I use \Cref
to reference chapter 1, in the text it appears as "Chapter 1". I was wondering if there I still use the chapter structure for the main text, but the cross-reference in the text will show as "Section 1" instead.
-
1Is the name substitution ("chapter" -> "section") supposed to be global or just on a case by case base? Please advise.– MicoCommented Jul 20, 2018 at 5:27
-
It is supposed to be global– Han LiCommented Jul 20, 2018 at 15:03
2 Answers
If the name substitution is supposed to be global, you could employ the \crefalias
device to achieve your objective. E.g.,
Asisde: I assume you are well aware of the fact that your readers may get confused if "chapters" are referred to as "sections."
\documentclass{report}
\usepackage{cleveref}
\crefalias{chapter}{section}
\begin{document}
\refstepcounter{chapter}\label{ch:1}
\refstepcounter{chapter}\label{ch:2}
Cross-references to \cref{ch:1,ch:2}.
\end{document}
If, on the other hand, the name substitution is supposed to apply to just a subset of chapters, e.g., the second chapter, you could set an optional argument for \label
instruction associated with the chapter in question.
\documentclass{report}
\usepackage{cleveref}
\begin{document}
\refstepcounter{chapter}\label{ch:1}
\refstepcounter{chapter}\label[section]{ch:2}
Cross-references to \cref{ch:1,ch:2}.
\end{document}
You can use \crefname
to globally redefine the "name" used by cleveref:
Here's the code:
\documentclass{book}
\usepackage{cleveref}
\crefname{chapter}{section}{sections}
\begin{document}
\chapter{A chapter}\label{C:chapter}
\Cref{C:chapter} \cref{C:chapter}
\end{document}