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.

I read the excellent question Difference between ref, varioref and cleveref. Decision for a thesis and various doc on the net (the varioref package documentation) and tried to use it... but with many errors

An exemple :

\documentclass{article}
\usepackage[a4paper]{geometry}
\geometry{top=25mm,bottom=25mm,inner=25mm,outer=20mm,,marginparwidth=1cm,marginparsep=10pt}

\usepackage[ansinew]{inputenc}
\usepackage[french]{babel}
\usepackage[lmodern]
\usepackage[T1]{fontenc}
\usepackage{microtype}

\usepackage{color,xcolor}


\ifpdf%
        \usepackage[pdftex,pagebackref=true,hyperindex=true,colorlinks=true]{hyperref}
        \hypersetup{pdfstartview={FitH}, bookmarksnumbered={true}}
\else%
        \usepackage[hypertex=true,hyperindex=true,colorlinks=false]{hyperref}
\fi

\usepackage{cleveref}
\usepackage{varioref} 

\usepackage{lipsum}


\begin{document}
\section{Bla bla}\label{sec:bla}
\lipsum[1]

\newpage
\section{Second bla bla}
Test section 1 : 
\begin{itemize}
    \item with \verb"\ref" : \ref{sec:bla}
    \item with \verb"\vref" : \vref{sec:bla}
          = error "!Missing \verb"\endcsname" inserted" 
    \item with \verb"\cref" : \cref{sec:bla}
          = error "!Missing \verb"\endcsname" inserted"       
\end{itemize}

\newpage 
\section{Third bla bla}
Test section 1 : 
\begin{itemize}
    \item with \verb"\ref" : \ref{sec:bla}
    \item with \verb"\vref" : \vref{sec:bla}
          = error "!Missing \verb"\endcsname" inserted" 
    \item with \verb"\cref" : \cref{sec:bla}
          = error "!Missing \verb"\endcsname" inserted"       
\end{itemize}
\end{document}

I get the error !Missing \endcsname inserted and more other after... (same error with vref as for cref.

How is it possible to resolve this ? I don't find an answer on this forum nor on the net.

I will use those packages (vref and cref) for my customized environnements, for exemple with such a macro-box :

\newtheorem{theoreme}{{\sffamily Théorème}}[section]

\newcommand{\boxthm}[2]
{{\colorbox{yellow}{\begin{minipage}{0.98\linewidth}
      \begin{theoreme}\label{thm:#1}
        {\sffamily ~\\#2}
      \end{theoreme}
\end{minipage}}}\\~}

I presume that if I can resolve the problem for a section, I also get the tip for all my macro-boxes (thm, definitions, algorithms, lemma, examples, ...) ?

share|improve this question
    
Load varioref after cleveref. What's the purpose of loading aeguill? It's a very obsolete package. If you haven't the CM-Super fonts installed, use lmodern. Also giving both the frenchb and francais options to babel is redundant: use either one or simply french. –  egreg Nov 22 '12 at 13:42
    
Load lmodern or install the CM-Super fonts. –  egreg Nov 22 '12 at 15:33
    
indeed with 'varioref' after 'cleveref', the command vref works (but not wioth french label as seen in its documentation). But cref doesn't work ... the problem is always pending –  madit Nov 22 '12 at 15:39
    
Now I see! It's a completely different problem: it's caused by the colons in the labels. –  egreg Nov 22 '12 at 15:42
    
code edited for correction given by egreg (thanks) –  madit Nov 22 '12 at 15:50
add comment

1 Answer

The problem is that varioref and cref don't like babel shorthands in the labels. Since the colon has a special meaning for French, you get that strange errors.

\documentclass{article}
\usepackage[a4paper]{geometry}
\geometry{top=25mm,bottom=25mm,inner=25mm,outer=20mm,
  marginparwidth=1cm,marginparsep=10pt}

\usepackage[T1]{fontenc}
\usepackage[ansinew]{inputenc}
\usepackage[english,french]{babel}
\usepackage{microtype} % loads also ifpdf

\usepackage{xcolor}

\usepackage{varioref}

\ifpdf
  \usepackage[pagebackref=true,hyperindex=true,colorlinks=true]{hyperref}
  \hypersetup{pdfstartview={FitH}, bookmarksnumbered={true}}
\else
  \usepackage[hypertex=true,hyperindex=true,colorlinks=false]{hyperref}
\fi

\usepackage{cleveref}

\begin{document}
\section{Bla bla}\label{sec-bla}
\lipsum[1]

\section{Second bla bla}
Test section 1 : 
\begin{itemize}
    \item with \verb|\ref| : \ref{sec-bla}
    \item with \verb|\vref| : \vref{sec-bla}
    \item with \verb|\cref| : \cref{sec-bla}
\end{itemize}

\newpage

\vref{sec-bla}
\end{document}

Some notes. The packages ae and aeguill are really obsolete and don't have really good metric files.

Better use the Type1 fonts that are provided by the CM-Super package (it depends on what distribution you're using how you install them) or say

\usepackage{lmodern}
share|improve this answer
    
Well ! So there is no possible solution ... It's a pity. Thank you anyway for your research. –  madit Nov 26 '12 at 6:21
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.