[Tex/LaTex] How to change label/reference formats

citingcross-referencinglabels

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.)??

Best Answer

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}

enter image description here