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.

My problem may have a similar root cause as this question, and although I've got a working solution I'm happy with, I'm puzzled as to why this happens at all. MWE:

\documentclass{article}
\usepackage{mathtools}
\usepackage{breqn}
\usepackage{hyperref}
\begin{document}
\section{Content}
\begin{figure}
\mbox{Figure content}
%%% Version 1, causes "Rerun to get cross-references right" warning every time
%%% if hyperref, mathtools, and breqn loaded simultaneously.
%\caption{dirac\_example.m}
%%% Version 2, works fine
\caption{dirac\textunderscore{}example.m}
%%% Version 3, works fine
%\newcommand{\mycaption}{dirac\_example.m}
%\caption{\mycaption{}}
\label{dirac}
\end{figure}
\end{document}

As noted in the comments, the first version of my figure caption causes pdflatex to constantly throw "Rerun to get cross-references right" warnings. Removing either of hyperref or breqn made the problem go away, and obviously, replacing the escaped underscore with a \textunderscore{} or another definition fixed the problem as well.

Things I've tried already:

  1. Tried with original TL 2010 DVD.
  2. Tried with current packages, updated this morning from CTAN.
  3. Tried moving breqn after hyperref.

No difference on any of those. All exhibited the error, and though I've not tried reinstalling the original DVD, I assume what works on my updated install would work there, too.

share|improve this question
3  
First of all mathtools is irrelevant (it seems), and breqn is just evil. I'll pass your example on the the breqn maintainers (I'm one, but I mostly work with mathtools) –  daleif Mar 3 '11 at 20:25
    
I could have sworn that I had to include mathtools to make breqn work, but on further review, I must have had something else going on. breqn does stand alone. –  Mike Renfro Mar 3 '11 at 21:50
add comment

1 Answer

up vote 2 down vote accepted

The problem is that when the .aux file is read at document start, the catcode of _ is 11, while at the end it's 12. Indeed, putting `\catcode_=11 just before\end{document}` "cures" the problem.

I suspect this has something to do with the LaTeX3 part of breqn, where the catcode of _ is indeed set to 11. And putting

\showthe\catcode`\_

after loading breqn shows 11, while after \begin{document} it shows 12.

share|improve this answer
add comment

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.