Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

As stated in the original title of the thread, I would like to use a reference number inside a section name.

Actually, it is to refer using the structure like

\section{Data related to Figure~\ref{fig:XY}}

The MWE for what I want is:

\documentclass[11pt,twoside,a4paper]{book}
\usepackage{hyperref}
\begin{document}
\chapter{First}\label{c:First}
\chapter{I want to use ref~\ref{c:First} here }\label{c:Second}
\section{Dummy section}
\newpage
\section{Dummy section in new page}
\end{document}

I tried to run such file into LuaLaTeX several times, since I am using it for my actual project. The related line in log output is

LaTeX Warning: Reference `C:FIRST' on page 4 undefined on input line 16.

The PDF file is generated, but the chapter name in page 4 becomes

CHAPTER 2. I WANT TO USE REF ?? HERE

I tried to find a possible duplicate, but I didn't find. Thanks in advance.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

The problem is that \MakeUppercase, that is used for the page headers, also converts the argument of \ref. A protected macro could be defined to prevent this:

\DeclareRobustCommand*{\refcfirst}{\ref*{c:First}}
...
\chapter{I want to use ref~\refcfirst\ here}
share|improve this answer
    
Thank you very much.It solved my issue. Just to complement, even if is sounds obvious (well, for me it wasn't at first): the robust declaration must be done before begin document. –  AYHarano Jan 23 '13 at 17:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.