How to change label/reference formats
A possibility is to use cleveref
and its \cref
or \Cref
commands to include the type of the referenced counter, e.g. an equation or a theorem. The \Cref
is used for uppercase purposes, e.g. at the beginning of a sentence.
Please note, that \usepackage[english]{cleveref}
etc. is perhaps more useful, depending on the needed language.
cleveref
's output format for references can be reconfigured using \crefformat
etc.
cleveref
should be the last package be loaded here!
\documentclass{book}
\usepackage{mathtools}
\usepackage{amsthm}
\usepackage{cleveref}
\newtheorem{theorem}{Theorem}[chapter]
\begin{document}
\chapter{First chapter}
In \cref{Einstein} and in \cref{theo} or \Cref{theo} we'll see that ...
\begin{equation}
E=mc^2 \label{Einstein}
\end{equation}
\begin{theorem} \label{theo}
First we have...
\end{theorem}
\end{document}
Related videos on Youtube
Annalise
Updated on April 14, 2020Comments
-
Annalise over 3 years
I have just been using the default label and reference formats, i.e.
$\label{eqn:a}$
and\ref{eqn:a}
but I was wondering if there's a way to change the format of the references. For example if I am referring back to Theorem 1.1$\label{thm:1.1}$
using\ref{thm:1.1}
it shows in the.pdf
file as simply 1.1. I would like my references to say more than the number, i.e. to say Theorem 1.1 in the.pdf
(I would also like this to be true for my Definitions and Lemmas). Obviously I know that this doesn't make sense for a line in a proof but is there a way to change the format when you are referring to a labelled theorem(or definition/lemma/etc.)??-
Admin over 7 years
\usepackage{cleveref}
and\cref{eqn:a}
etc. -
Annalise over 7 yearsI have changed all my refs to clever ref but now it just gives me whats in the curly brackets, i.e. \cref{eqn:a} gives eqn:a. Is there another way or do I have to go and manually change all of my labels?
-
Admin over 7 yearsI don't know what is going wrong there. Without any document this is hard to tell!
-
Mensch over 7 yearsPlease show us a short, compilable code resulting in your error.
-