Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 157787 - "undefined reference" but the reference is defined
Summary: "undefined reference" but the reference is defined
Alias: None
Product: Fedora
Classification: Fedora
Component: tetex
Version: rawhide
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Jindrich Novy
QA Contact: David Lawrence
Depends On:
TreeView+ depends on / blocked
Reported: 2005-05-15 15:55 UTC by John Smith
Modified: 2013-07-02 23:07 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2005-05-19 16:06:39 UTC

Attachments (Terms of Use)
foo.tex (deleted)
2005-05-15 15:55 UTC, John Smith
no flags Details
source file with a chapter (deleted)
2005-05-16 08:40 UTC, John Smith
no flags Details

Description John Smith 2005-05-15 15:55:18 UTC
Description of problem:

When I compile the attached file, I get the following error:

Reference `FOOBAR' on page 7 undefined on input line 69.

I have used the identifier `foobar' to define a label and
to refer to it, but I haven't used the identifier `FOOBAR`
anywhere in the source file.

Version-Release number of selected component (if applicable):

How reproducible:
Always, on my machine.  Well, the phenomenom seems to be very
dependent on the layout, and I do not know to what extent the
layout is controlled by parameters in configuration files,
outside of the source file (like papersize etc.).  If it doesn't
work for you, try adding a few lines of foo \bigskip foo ...

Steps to Reproduce:

1. Replace put_your_language_here in the source file with your
language.  [That's something I haven't elucidated yet: if I
don't put the \usepackage[...]{babel} line in the source file
or if I specify another language than mine, latex refuses to
compile the file.]

2. Type: latex foo.tex
Actual results:
LaTeX Warning: Reference `FOOBAR' on page 7 undefined on input line 69.

Expected results:
Compile cleanly.

Comment 1 John Smith 2005-05-15 15:55:19 UTC
Created attachment 114395 [details]

Comment 2 Jindrich Novy 2005-05-16 06:53:54 UTC
The problem is that LaTeX actually doesn't know how to refer to the label I see
from the source you attached. \label has to be used only within some block that
have some reference number, \section, \chapter, \begin{table} etc. Note that you
defined your \label at the top level that has no reference number so LaTeX has
no clue how to name the reference.

It behaves as it should that it refuses to create a reference.

Comment 3 John Smith 2005-05-16 08:40:21 UTC
Created attachment 114415 [details]
source file with a chapter

Comment 4 John Smith 2005-05-16 08:42:03 UTC
I have just added the line

\chapter{Here's a chapter}

before the label definition.  The bug still happens.

Comment 5 Jindrich Novy 2005-05-16 09:07:04 UTC
You need to pass the source through LaTeX twice in order to get correct
references. It's also quite unusual that you refer to a chapter from a section
header. Please refer to it from somewhere inside a section body, i.e.

\section{And now for something completely different}
This is a reference to chapter \ref{foobar}.

and you'll see no warnings about invalid references.

Comment 6 John Smith 2005-05-16 10:03:31 UTC
I know latex has to be run twice.  What I claim is that even if it is
run twice, it finds an undefined reference, which is a bug.

Indeed I could work around the bug by not referring to the label
inside the section body.  But I do want to do this and it *is* valid
LaTeX.  I have been doing it for years and I still want to do it now.

If you remove all (or most of) the lines of foo \bigskip foo,
then suddenly latex does not complain any more, which clearly
is inconsistent.

When I report a bug I'm not asking for advice as to how to work around it.
Please have a serious look at this issue. Thanks in advance.

Comment 7 Jindrich Novy 2005-05-16 10:53:33 UTC
Ok, maybe some regression was introduced by LaTeX within teTeX-3.0.
The warning message seems to be a minor inconsistency. Because pdfLaTeX doesn't 
refuse to generate a valid pdf, changing severity/priority to low.

The best solution here is to report the problem upstream. I don't have a deep
knowledge of LaTeX code and can't spend hours finding a fix for warning message,
sorry. Could you please report this problem upstream? The upstream developers
have a good insight into LaTeX code and respond quickly. Furthermore a fix for
this issue will affect all the distributions, not only Fedora, when a it's
applied upstream.

Please read first:

and then file the bug in:

Could you then add here a reference to the bug you reported so that I can track
it to have a patch to fix this applied?

Comment 8 John Smith 2005-05-19 15:59:31 UTC
Done: babel/3786

It turns out to be a known bug in babel for which "a fix may be difficult if not
impossible in the current implementation".

Comment 9 Jindrich Novy 2005-05-19 16:06:39 UTC
Thanks for filing the bug in upstream and posting here a reference to it.
Did you have any other fruitful feedback from the upstream developers that the
fix for this is hopeless for the current implementation?

Comment 10 John Smith 2005-05-20 09:39:40 UTC
I haven't had other feedback than what can be read in their bug database, i.e.
what I mentioned already and the following workaround:

\section{And now for something completely different: \MakeLowerCase{\ref{foobar}}}

Of course it does not work anymore if the label contains an uppercase letter.
I suggest another workaround: put two labels instead of just one, like this:

Note You need to log in before you can comment on or make changes to this bug.