Hi,

I am trying to use the packages algorithm and hyperref together. Depending 
on the order in which the packages are loaded, this does or doesn't work. 
The order that works however, is impossible to set using LyX. Consider the 
following latex source:

========================= test.tex =========================
\documentclass{article}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{hyperref}


\begin{document}

\tableofcontents

\pagebreak

\section{First section}
\label{firstlabel}

\pagebreak

\section{Second section}
\label{secondlabel}

\pagebreak

\begin{algorithm}
\begin{algorithmic}

\STATE x $\leftarrow$ 1

\end{algorithmic}
\caption{The caption for the algorithm}
\label{algorithmlabel}
\end{algorithm}

\pagebreak

See Algorithm \ref{algorithmlabel} to understand Section \ref{firstlabel}.

\end{document}
========================= test.tex =========================

This produces the following output (actually on the second run, when the 
.aux file is generated):

========================= output =========================
59> latex test
This is TeX, Version 3.14159 (MiKTeX 2 UP 1)
(test.tex
LaTeX2e <2000/06/01>
Babel <v3.6Z> and hyphenation patterns for english, french, german, ngerman, du
mylang, nohyphenation, loaded.
(F:\Work\Tex\tex\latex\base\article.cls
Document Class: article 2000/05/19 v1.4b Standard LaTeX document class
(F:\Work\Tex\tex\latex\base\size10.clo))
(F:\Work\Tex\tex\latex\algorithms\algorithm.sty
Document Style `algorithm' - floating environment
(F:\Work\Tex\tex\latex\misc\float.sty) (F:\Work\Tex\tex\latex\base\ifthen.sty))
  (F:\Work\Tex\tex\latex\algorithms\algorithmic.sty
Document Style `algorithmic' - environment
(F:\Work\Tex\tex\latex\tools\calc.sty))
(F:\Work\Tex\tex\latex\hyperref\hyperref.sty
(F:\Work\Tex\tex\latex\graphics\keyval.sty)
(F:\Work\Tex\tex\latex\hyperref\pd1enc.def)
(F:\Work\Tex\tex\latex\miktex\hyperref.cfg)
Implicit mode ON; LaTeX internals redefined
(F:\Work\Tex\tex\latex\ltxmisc\url.sty))
*hyperref using driver hypertex*
(F:\Work\Tex\tex\latex\hyperref\hypertex.def) (test.aux)
(F:\Work\Tex\tex\latex\hyperref\nameref.sty) (test.toc) [1] [2] [3]

Package hyperref Warning: bookmark level for unknown algorithm defaults to 0.

[4]
! Undefined control sequence.
<argument> algorithm.\theHalgorithm

l.35 See Algorithm \ref{algorithmlabel}
                                         to understand Section \ref{fi...
? H
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

?
[5] (test.aux) )
Output written on test.dvi (5 pages, 1536 bytes).
Transcript written on test.log.
========================= output =========================

If it put "\usepackage{hyperref}" before "\usepackage{algorithm}" the 
problem is solved. However, the only way to include hyperref in LyX 
1.6.1fix1 is to include it in the preamble, where it appears after the 
packages LyX includes. Does anyone know a good workaround for this problem?


Reply via email to