# cleveref & varioref : Missing \endcsname inserted

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%
\hypersetup{pdfstartview={FitH}, bookmarksnumbered={true}}
\else%
\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, ...) ?

-
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

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{xcolor}

\usepackage{varioref}

\ifpdf
\hypersetup{pdfstartview={FitH}, bookmarksnumbered={true}}
\else
\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}

-
Well ! So there is no possible solution ... It's a pity. Thank you anyway for your research. – madit Nov 26 '12 at 6:21
This is nuts. Thank you very much. – Jill-Jênn Vie Nov 14 '15 at 18:31