6

Having just bought The LaTeX Companion Third edition, I'm testing the examples given in the book. On p.78, the example treats of the using of \labelformat and \Ref.

\documentclass[10pt,a4paper]{article}

\usepackage[nospace]{varioref}
%\usepackage{babel}

\labelformat{section}{section~#1}
\labelformat{equation}{equation~(#1)}

\begin{document}
\section{An example}\label{sec}
\Ref{sec} shows the use of the \verb=\labelformat= declaration with a reference to \ref{eq}.
\begin{equation} a = b \label{eq} \end{equation}  
\end{document}

if you add an

\usepackage{babel}

with whatever language you want you get a

! Incomplete \iffalse; all text was ignored after line 11.

If you replace \Ref with \ref, all works fine again, but you loose the UpperCasing of the first letter, evidently.

Is there a way around this incompatibility ?

I've tried with [english]babel and [french]babel and babel with no option. I've tried with pdfLaTeX, LaTeX, XeLaTeX, LuaLaTeX ... same problem ...

Thanks

2
  • Welcome to TeX.SE!
    – mickep
    Apr 14 at 16:13
  • 1
    nice first question, clear test file and it looks like a real bug. Apr 14 at 16:13

1 Answer 1

4

You should report this to babel but a quick workaround is to restore the internal command

\documentclass[10pt,a4paper]{article}

\usepackage[nospace]{varioref}

\makeatletter
\let\@kernel@ref@saved\@kernel@ref
\usepackage{babel}
\let\@kernel@ref\@kernel@ref@saved
\makeatother

\labelformat{section}{section~#1}
\labelformat{equation}{equation~(#1)}

\begin{document}
\section{An example}\label{sec}
\Ref{sec} shows the use of the \verb=\labelformat= declaration with a reference to \ref{eq}.
\begin{equation} a = b \label{eq} \end{equation}  
\end{document}

babel redefines some \label/\ref internals so that active shorthand characters work, but this undoes that patch which seems confused by some of the \Ref details. So some characters such as " that are made active by babel may not work in labels after this change.

7
  • It's a little bit akward but it does the job ... for \Ref, not for the quotes ;) Thanks. How do I report anything to anywhere (babel in this case) ?
    – paulbou
    Apr 14 at 16:39
  • @paulbou github.com/latex3/babel/issues Apr 14 at 16:41
  • @paulbou "not for the quotes" ? Apr 14 at 16:42
  • 1
    \usepackage[safe=none]{babel} works too, see the documentation ... Apr 14 at 16:44
  • @DavidCarlisle My mistake !! I've put some quotes after my \end{document} and ... they didn't appear in the pdf (and I can explain why) ! Thanks again.
    – paulbou
    Apr 14 at 17:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .