[Tex/LaTex] Cross-reference to an entry in the toc

cross-referencinglyxtable of contents

Is there any way to cross-reference to sections/subsections via their title? I find myself writing "Please see section 4 for more details", and it gets annoying very soon, especially when I have to change the numbers repeatedly.

I am using lyx, so it would be nice if there's some way of automating some of the steps.

Best Answer

Use \label and \ref.

\section{Green's function}
\label{sec:green}

...

\ref{sec:green}.

More details can be found in the Not So Short Introduction to LaTeX2e, which is worth reading.

The cleveref package can save you some typing by automatically preceding the reference with section, theorem, equation, etc. as appropriate.

\documentclass{article}
\usepackage{cleveref}
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}
\label{thm}
This is a theorem.
\end{theorem}
\cref{thm}
\end{document}