GeneralHow to refer to the index in the text?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
kaiserschwarcz
Posts: 8
Joined: Sat Oct 16, 2010 1:24 am

How to refer to the index in the text?

Post by kaiserschwarcz »

Hi. I'm new in this community.
I hope to be posting in the right section.

Does anyone know how to refer to index in the text?

I mean... I want to write something like this: "as stated before in item XX". And instead of "XX" I want that LaTeX show the corresponding item number showed in the index.

The point is: When I change the document putting in a new section or subsection, the number in index will change. I want that change to be followed in the text too.

Thank you all.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

How to refer to the index in the text?

Post by gmedina »

Hi,

if by "index" you mean the Table of Contents (ToC) of your document, then the simplest approach would be to use the \label{<key>}, \ref{<key>} mechanism; a little example:

Code: Select all

\documentclass{book}

\begin{document}

\tableofcontents
\clearpage

In Chapter~\ref{cha:one} we present... and in Chapter~\ref{cha:two} we discuss...

\chapter{Test chpater one}\label{cha:one}
\section{Test section one one}\label{sec:oneone}
\section{Test section one two}\label{sec:onetwo}
\chapter{Test chpater two}\label{cha:two}
\section{Test section two one}\label{sec:twoone}
\section{Test section two two}\label{sec:twotwo}

As we see in Sections~\ref{sec:oneone} and~\ref{sec:twotwo}...

\end{document}
You must compile your document twice.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
kaiserschwarcz
Posts: 8
Joined: Sat Oct 16, 2010 1:24 am

Re: How to refer to the index in the text?

Post by kaiserschwarcz »

Yes. Thats is exact what I wanted.
Thank you, very much!
Post Reply