In LaTeX, we can say something like:
"See equation \ref{eq} on page \pageref{eq}..."
Is there any way to do:
"See equation \ref{eq} in chapter \chapterref{eq}..."
In LaTeX, we can say something like:
"See equation \ref{eq} on page \pageref{eq}..."
Is there any way to do:
"See equation \ref{eq} in chapter \chapterref{eq}..."
hyperref offers \autoref which will turn \autoref{chap:foo} into "chapter X"
\documentclass{book}
\usepackage{hyperref}
\begin{document}
\chapter{Foo}
\label{chap:foo}
This is the beginning of \autoref{chap:foo}
\end{document}
Produces:

To edit how hyperref references appear, see answers to this question
cleveref is another package that offers this sort of functionality.
The LaTeX wikibook has details on various cross-referencing options.
You can do this with the zref package. Here is an example use:
\documentclass{book}
\usepackage{zref-user}
\makeatletter
\zref@newprop{chapter}{\thechapter}
\zref@newprop{chaptertype}{\@chapapp}% as suggested by Danie Els
\zref@addprop{main}{chapter,chaptertype}
\makeatother
\begin{document}
\chapter{ch1}
ch1
\chapter{ch2}
ch2
\begin{equation}\zlabel{x1}
x=1
\end{equation}
\chapter{ch3}
See equation~\zref{x1} in chapter~\zref[chapter]{x1}.
Or, Danie's suggestion (in case you move equations between
chapters and appendices):
See equation~\zref{x1} in \zref[chaptertype]{x1}~\zref[chapter]{x1}
\end{document}
chapter~.... is a problem if the equation is inside an appendix. Maybe a \zref@newprop{chaptertype}{\@chapapp} for the book classes. Note that AMSbook uses \chaptername
– Danie Els
Mar 17 '11 at 07:09
\zref@addprop{main}{chapter,chaptertype} by \zref@addprop{main}{chapter} \zref@addprop{main}{chaptertype}.
– Marcel
Aug 12 '12 at 16:49
As meep.meep already posted the nameref can be used to reference to the name of the chapter. However, to get it right you need to label and reference the chapter manually and not use the label of the equation.
\documentclass{report}
\usepackage{nameref}
\usepackage[english]{babel}
\begin{document}
\chapter{Introduction}\label{chap:intro}
\begin{equation}
E = m\cdot c^2 \label{eq:emcsq}
\end{equation}
\chapter{Other}\label{chap:other}
% By name: "See equation 1.1 in chapter Introduction."
See equation~\ref{eq:emcsq} in chapter~\nameref{chap:intro}.
% By number: "See equation 1.1 in chapter 1."
See equation~\ref{eq:emcsq} in chapter~\ref{chap:intro}.
% Or both: "See equation 1.1 in chapter 1 ``Introduction''."
See equation~\ref{eq:emcsq} in chapter~\ref{chap:intro} ``\nameref{chap:intro}''.
\end{document}
The ~ before \ref is to prevent a line break just at this position.
\pageref works is that \label writes the page number to the .aux file. But the name or number of the chapter is not written. However, this could be added.
– Martin Scharrer
Mar 18 '11 at 00:50
\label command must be changed to also write the chapter information into the .aux file which then can be used by \chapterref.
– Martin Scharrer
Mar 18 '11 at 16:04
You can solve this using the package nameref (which you don't have to load, if you use hyperref:
\documentclass{article}
\usepackage{nameref}
\usepackage[english]{babel}
\begin{document}
\section{Testsection}
\begin{equation}
x=y
\label{eq:test}
\end{equation}
See equation \ref{eq:test} in section \nameref{eq:test}.
\end{document}

EDIT: I just noted, that if you also have a \subsection{text} then \namerefwould refer to this rather than the section. If I find the solution to this, I'll supplement it.
nameref and I suspect that this problem would be solvable. However, my knowlege of this LaTeX level is basic at best. So, I would recommend asking a new question like How to modify nameref to always refer to the current chapter? or something like that. Sorry, that I can't help you further.
– meep.meep
Mar 18 '11 at 10:41
\nameref worked for me, but, for anyone who might wonder, it gave the chapter's name. Not its number.
– Νικολέτα Σεβαστού
Feb 26 '22 at 18:40
You can use labels to sections and subsections, then refer to them like you'd refer to any other float, see below:
\section{Introduction}
\subsection{Background}
\label{sec:bg}
tesagahgshlgasghagö as seen in \ref{sec:bg} ......
I can see two somewhat manual ways to do it:
1) Introducing an additional counter, that passes the number of the chapter containing the equation:
% in preamble
\newcounter{einst-chap}
% around the equation
E=mc^2 \label{einst} \setcounter{einst-chap}{\value{chapter}}
% and to reference
See equation \ref{einst} in chapter \arabic{einst-chap}...
However, you have to take care of the format (eg. you'd have to type \Roman{einst-chap} if you had chapter I, chapter II etc.), which makes this solution not fully automatic.
2) Storing the adequate value of \thechapter (which includes the format as well as possible superdivisions, eg. chapter A#3), using \edef:
% just after the equation
\edef\einstChap{\thechapter}
% and to reference
See equation \ref{einst} in chapter \einstChap...
You can also use a package called cleveref. It automatically recognise what you are referring to and adds the appropriate name and numbering style.
in the previous example (by Daniel Els) you use it like this.
\documentclass{book}
\usepackage{cleveref}
\begin{document}
\mainmatter
\chapter{First chapter}\label{chp:Chp1}
\cref{eq:Einst} in \cref{chp:Chp1} and \cref{eq:Feyn} in
\cref{chp:App1} it is ...
\begin{equation}
E=mc^2 \label{eq:Einst}
\end{equation}
\appendix
\chapter{First Appendix}\label{chp:App1}
\begin{equation}
e^{i\pi}-1 = 0 \label{eq:Feyn}
\end{equation}
\end{document}
The refstyle package has this functionality. It will correctly reference an Appendix also if your label is such. You can also link it to varioref. Please read the documentaion.
\documentclass{book}
\usepackage[nokeyprefix]{refstyle}
\begin{document}
\mainmatter
\chapter{First chapter}\label{chp:Chp1}
\Eqref{eq:Einst} in \chapref{chp:Chp1} and \eqref{eq:Feyn} in \chapref{chp:App1} it is ...
\begin{equation}
E=mc^2 \label{eq:Einst}
\end{equation}
\appendix
\chapter{First Appendix}\label{chp:App1}
\begin{equation}
e^{i\pi}-1 = 0 \label{eq:Feyn}
\end{equation}
\end{document}
This gives:

Put these commands in the preamble:
\newcommand{\chap}[1]{\hyperref[#1]{Chapter \ref{#1}}}
\newcommand{\Chap}[1]{\hyperref[#1]{Chapter \ref{#1}}, \nameref{#1}}
\newcommand{\chaps}[2]{\hyperref[#1]{Chapters \ref{#1} \& \ref{#2}}}
then the text looks something like
In \chap{C4} we proved that... and in \chaps{C2}{C1} we claimed that...
etc...
hyperref defines its own \autoref command that effectively does this. (See my answer)
– Seamus
Mar 16 '11 at 15:50
\chapterrefreturn? The number or the name of the chapter? – Martin Scharrer Mar 16 '11 at 14:34