General ⇒ \ref in headings
\ref in headings
I have some section titles that use a "\ref". This works fine, but when I enable headings, the headings (from the default report style) include the section titles and thus the \refs. However, the headings can not resolve the \refs and I end up with question marks in the heading (even after multiple builds).
Any ideas?
Any ideas?
NEW: TikZ book now 40% off at Amazon.com for a short time.
- Stefan Kottwitz
- Site Admin
- Posts: 10321
- Joined: Mon Mar 10, 2008 9:44 pm
\ref in headings
Hi,
when I use \ref inside a section title, then it's working fine inside the headings of a report document, the reference is resolved.
You could give us a minimal working example, that shows the problem, then we could provide specific help.
Stefan
when I use \ref inside a section title, then it's working fine inside the headings of a report document, the reference is resolved.
You could give us a minimal working example, that shows the problem, then we could provide specific help.
Stefan
\ref in headings
I think I do not fully understand your problem. Can you please be a little more explicit? Better yet, can you please post a minimal working example clearly showing the undesired behaviour?
1,1,2,3,5,8,13,21,34,55,89,144,233,...
\ref in headings
I've figured out that the problem only occurs when I include the hyperref package. Here's an example. (sorry about the length, the first heading only appears on the second page of a chaper)
Code: Select all
\documentclass[12pt,twosided]{report}
\usepackage{hyperref}
\usepackage{theorem}
\newtheorem{thm}{Theorem}
\begin{document}
\pagestyle{headings}
\chapter{Example Reference \ref{foo}}
\begin{thm}\label{foo}
Theorem....
\end{thm}
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
fill text fill text fill text fill text fill text fill text fill text fill text
\end{document}
\ref in headings
How about using the optional argument of the sectional commands, as the following example suggests?
Remark: the blindtext package was loaded only to automatically generate some text.
Code: Select all
\documentclass{report}
\usepackage[english]{babel}
\usepackage{blindtext}
\begin{document}
\tableofcontents
\pagestyle{headings}
%the optional argument will be used in the Table of Contents and in the headings
\chapter[First chapter]{First chapter referencing section~\ref{sec:secone}}
\Blindtext
\Blindtext
\section{First section}
\label{sec:secone}
\end{document}
Remark: the blindtext package was loaded only to automatically generate some text.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Re: \ref in headings
Well, that is certainly better than having question marks in my document. Thanks for the suggestion. I'll either do that or just not use the hyperrefs (I have many appendix sections labeled "Proof of Lemma \ref{}" so an alternate heading label won't really distinguish between the sections unless I explicitly use the numbers, which sort of defeats the whole point of \refs.)
Re: \ref in headings
Notice that the hyper-reference to the theorem, lemma, etc. will work in the actual title of the sectional unit. I do not think that it is usual for the page headings to contain hyperlinks though.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
- Stefan Kottwitz
- Site Admin
- Posts: 10321
- Joined: Mon Mar 10, 2008 9:44 pm
Re: \ref in headings
Hi,
you may use uppercase labels like FOO, and it will work, because the headings use uppercase.
Test it or check the warnings in your logfile concerning undefined references, they are printed in uppercase.
If you had checked the log, you would have seen another warning, the option twosided is undefined, it must be twoside.
Stefan
you may use uppercase labels like FOO, and it will work, because the headings use uppercase.
Test it or check the warnings in your logfile concerning undefined references, they are printed in uppercase.
If you had checked the log, you would have seen another warning, the option twosided is undefined, it must be twoside.
Stefan
Re: \ref in headings
Nice catch Stefan, the problem was the conversion to uppercase.
@gmedina: Yeah, I don't really care if the heading has a hyperlink, I just want it to have the correct number for the ref.
@gmedina: Yeah, I don't really care if the heading has a hyperlink, I just want it to have the correct number for the ref.