Discussion:
label points to wrong page in theorem-like environment (with hyperref and floats)
(too old to reply)
Vincent Lefevre
2009-04-02 14:39:28 UTC
Permalink
We have a LaTeX document (private, so that I can't provide a testcase
without doing much work first) using hyperref and with something like:

\newtheorem{example}{Example}

... Text with some floating tables ...

\begin{example}[Some text for first example]
\label{ex:decimal:decimal:1}
...
\end{example}

\begin{example}[Some text for second example]
... \ref{ex:decimal:decimal:1} ...
\end{example}

The problem is that the label ex:decimal:decimal:1 points to the
wrong page: the .aux file says page 109, whereas it should be
page 113. Note that there is a later example also with its own
label, which points to the correct page (page 114). So, this
problem seems to be purely local. I've tried adding \phantomsection
before the \label or the \begin{example}, but this does not change
anything.

The .aux file looks like this:

[...]
\citation{Erle2007}
\newlabel{ex:decimal:decimal:1}{{3}{109}{Section title\relax }{example.3}{}}
\@writefile{lot}{\contentsline {table}{\numberline {3.17}{\ignorespaces Table caption.}}{110}{table.3.17}}
\newlabel{tab:decimal:encoding}{{3.17}{110}{Table caption}{table.3.17}{}}
\@writefile{lot}{\contentsline {table}{\numberline {3.18}{\ignorespaces Table caption.}}{111}{table.3.18}}
\newlabel{tab:binary:encoding}{{3.18}{111}{Table caption}{table.3.18}{}}
\@writefile{lot}{\contentsline {table}{\numberline {3.19}{\ignorespaces Table caption.}}{112}{table.3.19}}
\newlabel{declet-to-decimal}{{3.19}{112}{Table caption}{table.3.19}{}}
\@writefile{lot}{\contentsline {table}{\numberline {3.20}{\ignorespaces Table caption.}}{112}{table.3.20}}
\newlabel{decimal-to_declet}{{3.20}{112}{Table caption}{table.3.20}{}}
\newlabel{ex:decimal:decimal:2}{{5}{114}{Decimal interchange format encodings\relax }{example.5}{}}
[...]

What's strange is that the tables are defined in the .tex file
*before* the examples. But perhaps pdflatex can decide their layout
only after seeing the beginning of the example. However I suppose
that it should have taken care of such problems.

Also, the page numbers for the tables are correct: page 110 contains
only Table 3.17, page 111 contains only Table 3.18, and page 112
contains both Tables 3.19 and 3.20 (and no text).

Is it a known problem? Is there anything we should do?

FYI, all the packages that are used:

\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[pdftex]{graphicx}
\usepackage{rotating}
\usepackage{palatino}
\usepackage[scaled=0.85]{beramono}
\usepackage{url,lettrine}
\usepackage{amsthm,amssymb,amsmath}
\usepackage{color}
\usepackage{soul}
\usepackage{listings}
\usepackage{float}
\usepackage[titles]{tocloft}
\usepackage{array,longtable}
\usepackage{comment}
\usepackage{makeidx}
\usepackage{multirow,bigstrut}
\usepackage[table]{xcolor}
\usepackage{proof}
\usepackage{tocbibind}
\usepackage{caption}
\usepackage{algorithmic}
\usepackage{boxedminipage}
\usepackage{hyperref}

and package info from the log file:

Package: inputenc 2006/05/05 v1.1b Input encoding file
Package: fontenc 2005/09/27 v1.99g Standard LaTeX package
Package: graphicx 1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR)
Package: keyval 1999/03/16 v1.13 key=value parser (DPC)
Package: graphics 2006/02/20 v1.0o Standard LaTeX Graphics (DPC,SPQR)
Package: trig 1999/03/16 v1.09 sin cos tan (DPC)
Package graphics Info: Driver file: pdftex.def on input line 90.
Package: rotating 1997/09/26, v2.13 Rotation package
Package: ifthen 2001/05/26 v1.1c Standard LaTeX ifthen package (DPC)
Package: palatino 2005/04/12 PSNFSS-v9.2a (SPQR)
Package: beramono 2004/01/31 (WaS)
Package: url 2005/06/27 ver 3.2 Verb mode for urls, etc.
Package: amsthm 2004/08/06 v2.20
Package: amssymb 2002/01/22 v2.2d
Package: amsfonts 2001/10/25 v2.2f
Package: amsmath 2000/07/18 v2.13 AMS math features
Package: amstext 2000/06/29 v2.01
Package: amsbsy 1999/11/29 v1.2d
Package: amsopn 1999/12/14 v2.01 operator names
Package: color 2005/11/14 v1.0j Standard LaTeX Color (DPC)
Package color Info: Driver file: pdftex.def on input line 130.
Package: soul 2003/11/17 v2.4 letterspacing/underlining (mf)
Package: listings 2004/10/17 1.3b (Carsten Heinz)
Package: float 2001/11/08 v1.3d Float enhancements (AL)
Package: tocloft 2003/09/26 v2.3c parameterised ToC, etc., typesetting
Package tocloft Note: The document has chapter divisions.
Package: array 2005/08/23 v2.4b Tabular extension package (FMi)
Package: longtable 2004/02/01 v4.11 Multi-page Table package (DPC)
Package: makeidx 2000/03/29 v1.0m Standard LaTeX package
Package: xcolor 2007/01/21 v2.11 LaTeX color extensions (UK)
Package xcolor Info: Driver file: pdftex.def on input line 225.
Package: colortbl 2001/02/13 v0.1j Color table columns (DPC)
Package xcolor Info: Model `cmy' substituted by `cmy0' on input line 1337.
Package xcolor Info: Model `hsb' substituted by `rgb' on input line 1341.
Package xcolor Info: Model `RGB' extended on input line 1353.
Package xcolor Info: Model `HTML' substituted by `rgb' on input line 1355.
Package xcolor Info: Model `Hsb' substituted by `hsb' on input line 1356.
Package xcolor Info: Model `tHsb' substituted by `hsb' on input line 1357.
Package xcolor Info: Model `HSB' substituted by `hsb' on input line 1358.
Package xcolor Info: Model `Gray' substituted by `gray' on input line 1359.
Package xcolor Info: Model `wave' substituted by `hsb' on input line 1360.
Package: tocbibind 2003/03/13 v1.5g extra ToC listings
Package tocbibind Note: The document has chapter divisions.
Package tocbibind Note: Using chapter style headings, unless overridden.
Package: caption 2007/01/07 v3.0k Customising captions (AR)
Package: caption3 2007/01/07 v3.0k caption3 kernel (AR)
Package caption Info: float package v1.3 (or newer) detected on input line 275.
Package caption Info: listings package v1.2 (or newer) detected on input line 3
Package caption Info: longtable package v3.15 (or newer) detected on input line
Package caption Info: rotating package v2.0 (or newer) detected on input line 3
Package: algorithmic 2006/06/02
Package: calc 2005/08/06 v4.2 Infix arithmetic (KKT,FJ)
Package: hyperref 2007/02/07 v6.75r Hypertext links for LaTeX
Package: kvoptions 2006/08/22 v2.4 Connects package keyval with LaTeX options (
Package hyperref Info: Hyper figures OFF on input line 2288.
Package hyperref Info: Link nesting OFF on input line 2293.
Package hyperref Info: Hyper index ON on input line 2296.
Package hyperref Info: Plain pages OFF on input line 2303.
Package hyperref Info: Backreferencing OFF on input line 2308.
Package hyperref Info: Bookmarks ON on input line 2444.
Package hyperref Info: Hyper figures OFF on input line 3102.
Package hyperref Info: Link nesting OFF on input line 3107.
Package hyperref Info: Hyper index ON on input line 3110.
Package hyperref Info: backreferencing OFF on input line 3117.
Package hyperref Info: Link coloring OFF on input line 3122.
Package: ragged2e 2003/03/25 v2.04 ragged2e Package (MS)
Package: everysel 1999/06/08 v1.03 EverySelectfont Package (MS)
Package caption Info: hyperref package v6.74m (or newer) detected on input line
Package hyperref Info: Link coloring OFF on input line 234.
Package: nameref 2006/12/27 v2.28 Cross-referencing by name of section
Package: refcount 2006/02/20 v3.0 Data extraction from references (HO)
Package hyperref Info: bookmark level for unknown program defaults to 0 on inpu
Package hyperref Warning: Token not allowed in a PDFDocEncoded string,
Package hyperref Warning: Token not allowed in a PDFDocEncoded string,
Package hyperref Warning: Token not allowed in a PDFDocEncoded string,
Package hyperref Warning: Token not allowed in a PDFDocEncoded string,
Package hyperref Warning: Token not allowed in a PDFDocEncoded string,
Package hyperref Warning: Token not allowed in a PDFDocEncoded string,
Package hyperref Warning: Token not allowed in a PDFDocEncoded string,
Package hyperref Warning: Token not allowed in a PDFDocEncoded string,
Package hyperref Warning: Token not allowed in a PDFDocEncoded string,
Package hyperref Warning: Token not allowed in a PDFDocEncoded string,
Package hyperref Warning: Token not allowed in a PDFDocEncoded string,
Package amsthm Warning: The \qedhere command may not work correctly here on inp
--
Vincent Lefèvre <***@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)
Vincent Lefevre
2009-04-02 15:06:09 UTC
Permalink
In article <20090402140914$***@prunille.vinc17.org>,
Vincent Lefevre <vincent+***@vinc17.org> wrote:

[...]
Post by Vincent Lefevre
The problem is that the label ex:decimal:decimal:1 points to the
wrong page: the .aux file says page 109, whereas it should be
page 113.
[...]
Post by Vincent Lefevre
What's strange is that the tables are defined in the .tex file
*before* the examples. But perhaps pdflatex can decide their layout
only after seeing the beginning of the example. However I suppose
that it should have taken care of such problems.
I forgot to say that it happens that the theorem-like environment
(example) is laid out at the top of page 113 and follows the text
that is on page 109 (and pages 110 to 112 are taken by the floating
tables). If I add some text so that the beginning of the example
no longer appears at the top of a page (4 lines are needed), then
the label points to the correct page 113.
--
Vincent Lefèvre <***@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)
Ulrike Fischer
2009-04-02 15:14:46 UTC
Permalink
Post by Vincent Lefevre
We have a LaTeX document (private, so that I can't provide a testcase
\newtheorem{example}{Example}
... Text with some floating tables ...
\begin{example}[Some text for first example]
\label{ex:decimal:decimal:1}
...
\end{example}
\begin{example}[Some text for second example]
... \ref{ex:decimal:decimal:1} ...
\end{example}
The problem is that the label ex:decimal:decimal:1 points to the
wrong page: the .aux file says page 109, whereas it should be
page 113. Note that there is a later example also with its own
label, which points to the correct page (page 114). So, this
problem seems to be purely local. I've tried adding \phantomsection
before the \label or the \begin{example}, but this does not change
anything.
[...]
\citation{Erle2007}
\newlabel{ex:decimal:decimal:1}{{3}{109}{Section title\relax }{example.3}{}}
\newlabel{tab:decimal:encoding}{{3.17}{110}{Table caption}{table.3.17}{}}
\newlabel{tab:binary:encoding}{{3.18}{111}{Table caption}{table.3.18}{}}
\newlabel{declet-to-decimal}{{3.19}{112}{Table caption}{table.3.19}{}}
\newlabel{decimal-to_declet}{{3.20}{112}{Table caption}{table.3.20}{}}
\newlabel{ex:decimal:decimal:2}{{5}{114}{Decimal interchange format encodings\relax }{example.5}{}}
[...]
What's strange is that the tables are defined in the .tex file
*before* the examples.
That's normal. The label etc are written at shipout to the .aux-file
(so that page number are correct), so a float can come later than
its definition.
Post by Vincent Lefevre
Is it a known problem? Is there anything we should do?
Probably the label gets somehow separated from the following text of
the example. Without some exact code it is difficult to say more.

But your hyperref is quite old
Post by Vincent Lefevre
Package: hyperref 2007/02/07 v6.75r Hypertext links for LaTeX
I have hyperref.sty 2009/02/22 v6.78p Hypertext links for LaTeX. So
you should at first try if the problem persits with a new version.
--
Ulrike Fischer
Vincent Lefevre
2009-04-03 01:30:49 UTC
Permalink
Post by Ulrike Fischer
Post by Vincent Lefevre
What's strange is that the tables are defined in the .tex file
*before* the examples.
That's normal. The label etc are written at shipout to the .aux-file
(so that page number are correct), so a float can come later than
its definition.
OK, but even in the PDF, the examples come *after* the tables.
Post by Ulrike Fischer
Post by Vincent Lefevre
Is it a known problem? Is there anything we should do?
Probably the label gets somehow separated from the following text of
the example. Without some exact code it is difficult to say more.
I'll try to produce a testcase next week.
Post by Ulrike Fischer
But your hyperref is quite old
Post by Vincent Lefevre
Package: hyperref 2007/02/07 v6.75r Hypertext links for LaTeX
I have hyperref.sty 2009/02/22 v6.78p Hypertext links for LaTeX. So
you should at first try if the problem persits with a new version.
2007/02/07 is the latest version in texlive. And the new hyperref
has too many dependencies that are annoying to install one by one
(I gave up...).
--
Vincent Lefèvre <***@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)
Ulrike Fischer
2009-04-03 07:59:38 UTC
Permalink
Post by Vincent Lefevre
Post by Ulrike Fischer
Post by Vincent Lefevre
Is it a known problem? Is there anything we should do?
Probably the label gets somehow separated from the following text of
the example. Without some exact code it is difficult to say more.
I'll try to produce a testcase next week.
You could try to put a minipage around the example to test if this
keeps the label together with the example.
Post by Vincent Lefevre
Post by Ulrike Fischer
But your hyperref is quite old
Post by Vincent Lefevre
Package: hyperref 2007/02/07 v6.75r Hypertext links for LaTeX
I have hyperref.sty 2009/02/22 v6.78p Hypertext links for LaTeX. So
you should at first try if the problem persits with a new version.
2007/02/07 is the latest version in texlive.
Not in texlive 2008.
Post by Vincent Lefevre
And the new hyperref has too many dependencies that are annoying
to install one by one (I gave up...).
But if your problem is due to a bug in hyperref that you will
probably not have a choice, after all it's one of the main point of
new versions to correct bugs.

In miktex, if I would had to do it manually, I would simply grab

CTAN:/tex-archive/install/macros/latex/contrib/oberdiek.tds.zip
CTAN:/tex-archive/install/macros/latex/contrib/hyperref.tds.zip,

unzip them and add their roots as new local roots to my system.
--
Ulrike Fischer
Vincent Lefevre
2009-04-03 14:22:56 UTC
Permalink
Post by Ulrike Fischer
You could try to put a minipage around the example to test if this
keeps the label together with the example.
After adding \begin{minipage}{\textwidth} and \end{minipage} around
\begin{example}...\end{example}, the label becomes correct!
Post by Ulrike Fischer
Post by Vincent Lefevre
Post by Ulrike Fischer
I have hyperref.sty 2009/02/22 v6.78p Hypertext links for LaTeX. So
you should at first try if the problem persits with a new version.
2007/02/07 is the latest version in texlive.
Not in texlive 2008.
Debian is always late. And concerning MacPorts, I've just seen the
following bug:

http://trac.macports.org/ticket/16492

The upgrade is blocked by problems with the 2008 version.
Post by Ulrike Fischer
Post by Vincent Lefevre
And the new hyperref has too many dependencies that are annoying
to install one by one (I gave up...).
But if your problem is due to a bug in hyperref that you will
probably not have a choice, after all it's one of the main point of
new versions to correct bugs.
In miktex, if I would had to do it manually, I would simply grab
CTAN:/tex-archive/install/macros/latex/contrib/oberdiek.tds.zip
CTAN:/tex-archive/install/macros/latex/contrib/hyperref.tds.zip,
unzip them and add their roots as new local roots to my system.
I've installed both in my $HOME/share/texmf, but this is not
sufficient:

! LaTeX Error: File `etexcmds.sty' not found.

Still another dependency! I wonder how many are necessary...
--
Vincent Lefèvre <***@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)
Robin Fairbairns
2009-04-03 14:34:57 UTC
Permalink
Post by Vincent Lefevre
Post by Ulrike Fischer
[...]
In miktex, if I would had to do it manually, I would simply grab
CTAN:/tex-archive/install/macros/latex/contrib/oberdiek.tds.zip
CTAN:/tex-archive/install/macros/latex/contrib/hyperref.tds.zip,
unzip them and add their roots as new local roots to my system.
I've installed both in my $HOME/share/texmf, but this is not
! LaTeX Error: File `etexcmds.sty' not found.
Still another dependency! I wonder how many are necessary...
oberdiek.tds.zip on ctan *now* contains etexcmds; so you've either
- not got the current copy of that zip, or
- your $home/share/texmf isn't in your texmf.cnf or
- you've failed to run texhash.

or something i've not thought of.
--
Robin Fairbairns, Cambridge
Vincent Lefevre
2009-04-06 09:34:45 UTC
Permalink
Post by Robin Fairbairns
oberdiek.tds.zip on ctan *now* contains etexcmds; so you've either
- not got the current copy of that zip, or
- your $home/share/texmf isn't in your texmf.cnf or
- you've failed to run texhash.
I didn't know that I had to run texhash. Anyway this wasn't the
problem. My $TEXINPUTS was incorrect: I had $HOME/share/texmf/tex/latex
in it, whereas I needed $HOME/share/texmf/tex.

The bug no longer occurs with this new version.

Thanks.
--
Vincent Lefèvre <***@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)
Ulrike Fischer
2009-04-03 14:36:33 UTC
Permalink
Post by Vincent Lefevre
Post by Ulrike Fischer
In miktex, if I would had to do it manually, I would simply grab
CTAN:/tex-archive/install/macros/latex/contrib/oberdiek.tds.zip
CTAN:/tex-archive/install/macros/latex/contrib/hyperref.tds.zip,
unzip them and add their roots as new local roots to my system.
I've installed both in my $HOME/share/texmf, but this is not
! LaTeX Error: File `etexcmds.sty' not found.
etexcmds should be in oberdiek. Which probably means that you didn't
install the files correctly. Did you run texhash?
--
Ulrike Fischer
Ulrich M. Schwarz
2009-04-03 16:33:05 UTC
Permalink
On Thu, 02 Apr 2009 16:39:28 +0200, Vincent Lefevre
Post by Vincent Lefevre
We have a LaTeX document (private, so that I can't provide a testcase
\newtheorem{example}{Example}
... Text with some floating tables ...
\begin{example}[Some text for first example]
\label{ex:decimal:decimal:1}
...
\end{example}
\begin{example}[Some text for second example]
... \ref{ex:decimal:decimal:1} ...
\end{example}
The problem is that the label ex:decimal:decimal:1 points to the
wrong page: the .aux file says page 109, whereas it should be
page 113. Note that there is a later example also with its own
label, which points to the correct page (page 114). So, this
problem seems to be purely local.
Yes, amsthm is a tricky one. In an attempt to do I-don't-know-what,
starting a theorem (here, example), works as follows, as far as a
cursory look at amsthm suggests (don't worry if it doesn't suggest
to you):
1. increase the number for the theorem. This sets the hyperref link target.
2. add the spacing above the theorem.
3. prepare for the header to be typeset when the next paragraph starts.

Unfortunately, not only can a page break occur between 1. and 3., but the
page builder can also decide to output a whole lot of float pages in
between.
A solution that has been suggested before is to add a good-looking
breakpoint
at the beginning of the theorem, like \newpage[2]. (Note that thmtools can
help
you automatically add things before the theorem starts.)

Sincerely (but in a bit of a hurry)
Ulrich
Vincent Lefevre
2009-04-06 09:37:47 UTC
Permalink
Post by Ulrich M. Schwarz
Yes, amsthm is a tricky one. In an attempt to do I-don't-know-what,
starting a theorem (here, example), works as follows, as far as a
cursory look at amsthm suggests (don't worry if it doesn't suggest
1. increase the number for the theorem. This sets the hyperref link target.
2. add the spacing above the theorem.
3. prepare for the header to be typeset when the next paragraph starts.
OK, this explains the problem. But it seems that the new version
of hyperref (or one of its dependents) fixes the problem, at least
in my case.
Post by Ulrich M. Schwarz
Unfortunately, not only can a page break occur between 1. and 3., but the
page builder can also decide to output a whole lot of float pages in
between.
Yes, this is what happened here.
--
Vincent Lefèvre <***@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)
Vincent Lefevre
2009-04-06 10:46:24 UTC
Permalink
Post by Ulrich M. Schwarz
Yes, amsthm is a tricky one. In an attempt to do I-don't-know-what,
starting a theorem (here, example), works as follows, as far as a
cursory look at amsthm suggests (don't worry if it doesn't suggest
1. increase the number for the theorem. This sets the hyperref link target.
2. add the spacing above the theorem.
3. prepare for the header to be typeset when the next paragraph starts.
I said that the new hyperref version fixed the problem, but in fact
I don't think it does as I can reproduce it on a simple testcase
(see below); I suppose that the page layout slightly changed, so
that the effect of the bug on the tested document disappeared.

Here's the testcase:

\documentclass{article}
\newtheorem{theorem}{Theorem}

\begin{document}

Paragraph 1.

\vskip 180mm

Paragraph 2.

\begin{theorem}
\label{th}
Theorem.
\end{theorem}

See Theorem~\ref{th} page~\pageref{th}.

\end{document}

Adding \usepackage{hyperref} doesn't change anything.
Post by Ulrich M. Schwarz
A solution that has been suggested before is to add a good-looking
breakpoint at the beginning of the theorem, like \newpage[2]. (Note
that thmtools can help you automatically add things before the
theorem starts.)
\newpage[2] makes a [2] appear on page 2.
--
Vincent Lefèvre <***@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)
Ulrike Fischer
2009-04-06 10:56:54 UTC
Permalink
Post by Vincent Lefevre
I said that the new hyperref version fixed the problem, but in fact
I don't think it does as I can reproduce it on a simple testcase
(see below); I suppose that the page layout slightly changed, so
that the effect of the bug on the tested document disappeared.
\documentclass{article}
\newtheorem{theorem}{Theorem}
\begin{document}
Paragraph 1.
\vskip 180mm
Paragraph 2.
\begin{theorem}
\label{th}
Theorem.
\end{theorem}
See Theorem~\ref{th} page~\pageref{th}.
\end{document}
\begin{theorem}
\leavevmode
\label{tha}%
Theorem.
\label{thb}%
\end{theorem}

See Theorem~\ref{tha} page~\pageref{tha}, \pageref{thb}.
--
Ulrike Fischer
Vincent Lefevre
2009-04-06 11:18:34 UTC
Permalink
Post by Vincent Lefevre
\begin{theorem}
\leavevmode
\label{tha}%
Theorem.
\label{thb}%
\end{theorem}
Thanks. I've just seen an alternate solution given by Donald Arseneau on

http://groups.google.com/group/comp.text.tex/browse_thread/thread/bae7af1d66e34c7d/

\mbox{\label{th}}%

But \mbox does a \leavevmode. Is the \leavevmode sufficient in all
cases, or may \mbox be necessary?

Also, can this fix be done in a global way (i.e. without having to
change all occurrences)?
--
Vincent Lefèvre <***@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)
Vincent Lefevre
2009-04-06 11:51:05 UTC
Permalink
Post by Vincent Lefevre
Post by Vincent Lefevre
\begin{theorem}
\leavevmode
\label{tha}%
Theorem.
\label{thb}%
\end{theorem}
Thanks. I've just seen an alternate solution given by Donald Arseneau on
http://groups.google.com/group/comp.text.tex/browse_thread/thread/bae7af1d66e34c7d/
\mbox{\label{th}}%
But \mbox does a \leavevmode. Is the \leavevmode sufficient in all
cases, or may \mbox be necessary?
Well, this doesn't solve the problem: Adding \leavevmode doesn't
change anything on my original document (with the old hyperref
package, but I think the problem is independent from hyperref,
but is due to a different context). Moreover, in my testcase,
it fails with:

--------------------------------------------------------------------
Paragraph 1.

\vskip 177mm

Paragraph 2.

\begin{theorem}[blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah]
\leavevmode\label{th2}%
Theorem.
\end{theorem}

See Theorem~\ref{th2} page~\pageref{th2}.
--------------------------------------------------------------------

The referenced page should be the one of "Theorem ...", not the one
where the contents of the theorem begin.
--
Vincent Lefèvre <***@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)
Ulrike Fischer
2009-04-06 12:12:26 UTC
Permalink
Post by Vincent Lefevre
Post by Vincent Lefevre
Thanks. I've just seen an alternate solution given by Donald Arseneau on
http://groups.google.com/group/comp.text.tex/browse_thread/thread/bae7af1d66e34c7d/
\mbox{\label{th}}%
But \mbox does a \leavevmode. Is the \leavevmode sufficient in all
cases, or may \mbox be necessary?
There should be no difference, anything that starts the paragraph
and so avoid that the label gets separated from the following text
should work.
Post by Vincent Lefevre
Well, this doesn't solve the problem: Adding \leavevmode doesn't
change anything on my original document (with the old hyperref
package, but I think the problem is independent from hyperref,
but is due to a different context). Moreover, in my testcase,
--------------------------------------------------------------------
Paragraph 1.
\vskip 177mm
Paragraph 2.
\begin{theorem}[blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah]
\leavevmode\label{th2}%
Theorem.
\end{theorem}
See Theorem~\ref{th2} page~\pageref{th2}.
--------------------------------------------------------------------
The referenced page should be the one of "Theorem ...", not the one
where the contents of the theorem begin.
In this case you want to tie the label to the blab blah so the
\leavevmode is contraproductive. Put the label inside the [...].
--
Ulrike Fischer
Vincent Lefevre
2009-04-06 12:49:49 UTC
Permalink
Post by Ulrike Fischer
In this case you want to tie the label to the blab blah so the
\leavevmode is contraproductive. Put the label inside the [...].
OK. This still doesn't solve the problem on the original document
with the old hyperref package, but I think this is a bug in this
package, because:

* if I use the new version, the page layout doesn't change and
the page number is correct;

* if I don't use hyperref, the page layout doesn't change either
and the page number is also correct (there isn't a link in the
PDF, but I could check the page number in the .aux file).
--
Vincent Lefèvre <***@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)
Loading...