Discussion:
reference to algorithms
(too old to reply)
Daniel Ricardo Hernandez Hernandez
2005-06-29 00:39:57 UTC
Permalink
Hello, I writing algorithms with latex and the packages: algorithm and
algorithmic. The algorithms are numbered with the option subsection
at the time of the algorithm pagkage loading, ie. with:

\documentclass{article}
\usepackage[subsection]{algorithm}
\usepackage{algorithmic}

My problem is that I referece the algorithms in the text with senteces
like 'see the algorithm 3.2.1' and if I insert a new section or a new
algorithm the references turn wrong.

thaks
Daniel
Pieter Rautenbach
2005-06-29 05:57:07 UTC
Permalink
Hi Daniel,

Have you considered using \label and \ref?

Regards
Pieter Rautenbach
Axel Sommerfeldt
2005-06-29 06:49:41 UTC
Permalink
Post by Daniel Ricardo Hernandez Hernandez
My problem is that I referece the algorithms in the text with senteces
like 'see the algorithm 3.2.1' and if I insert a new section or a new
algorithm the references turn wrong.
I cannot confirm this:

\documentclass{article}
\usepackage[subsection]{algorithm}
\usepackage{algorithmic}

\begin{document}
\section{A}\subsection{B}
\begin{algorithm}
A = B
\caption{An algorithm}\label{algo1}
\end{algorithm}
\section{C}
See algorithm \ref{algo1}.
\end{document}

Are you sure you put the \label command inside or after the \caption
command?

See also:
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=crossref

HTH,
Axel
Daniel Ricardo Hernandez Hernandez
2005-06-29 12:30:27 UTC
Permalink
Thanks, \label and \ref resolves a very comon problem for me. The
solution was very easy and I didn't know it.
Ralf Stubner
2005-06-29 12:50:37 UTC
Permalink
Post by Daniel Ricardo Hernandez Hernandez
Thanks, \label and \ref resolves a very comon problem for me. The
solution was very easy and I didn't know it.
May I suggest reading some sort of LaTeX introduction? For example
something like Tobias Oetiker's '(Not so) Short Introduction to
LaTeX2e'. <URL:http://www.tex.ac.uk/cgi-bin/texfaq2html?label=tutorials>
gives a longer list.

cheerio
ralf
Rogério Brito
2005-07-05 07:40:48 UTC
Permalink
Post by Daniel Ricardo Hernandez Hernandez
Thanks, \label and \ref resolves a very comon problem for me. The
solution was very easy and I didn't know it.
Maybe you'd like to know that the newest version of algorithms also
allows you to use \label's and \ref's for specific lines of a given
algorithm.

BTW, if you are using Emacs, install a recent version of AUCTeX and use
it with RefTeX. You'll wonder why you didn't start using that years ago.
RefTeX makes the use of references a child's play.


Hope this helps, Rogério.
--
Rogério Brito : ***@ime.usp.br : http://www.ime.usp.br/~rbrito
Homepage of the algorithms package : http://algorithms.berlios.de
Homepage on freshmeat: http://freshmeat.net/projects/algorithms/
Continue reading on narkive:
Loading...