# Redefine \cref for non-English languages

Would it be possible to define another command \frcref that is similar to \cref, but when it is called, e.g. \frcref{ch:chapter1}, it displays the French word "Chapitre" instead of the English word "Chapter" in the hyperlink? (\cref should still print the English words.)

• Have you tried \usepackage[french]{cleveref}? – Mico Mar 29 at 15:31
• But then all \cref would be in French right? I only need some of them, because there is both Fr and En in my document. – Joe Dumars Mar 29 at 15:38
• Then please update your question with this important information about multiple languages in the same document – daleif Mar 29 at 15:59
• For example, do please confirm that you load the hyperref package as well. Do you load the babel package? If so, with which language option(s)? And, with which options (if any) do you load the cleveref package? – Mico Mar 29 at 16:04

You can just surround the \cref command with e.g. \foreignlanguage, provided you have passed your languages to both babel and cleveref:

\documentclass{book}

\usepackage[T1]{fontenc}
\usepackage[danish,french,main=british]{babel}
\usepackage[danish,french,english]{cleveref}

\begin{document}

\chapter{Test}
\label{chap-test}

\Cref{chap-test}

\foreignlanguage{danish}{\Cref{chap-test}}

\foreignlanguage{french}{\Cref{chap-test}}

\end{document}


Note cleveref with french does not like certain characters, including : in labels.

You can capture this in new macros such as

\newcommand{\fCref}[1]{\foreignlanguage{french}{\Cref{#1}}}


However, below I have gone further and defined a command \newcreflang with the effect that

\newcreflang{f}{french}


defines both \fcref and \fCref in one go. This command could be extended further to create analogues of other macros from cleveref.

\documentclass{book}

\usepackage[T1]{fontenc}
\usepackage{etoolbox}

\usepackage[swedish,french,main=british]{babel}
\usepackage[swedish,french,english]{cleveref}

\makeatletter
\newrobustcmd{\@mlcref}[3]{\foreignlanguage{#1}{\@cref{#2}{#3}}}
\newcommand{\newcreflang}[2]{%
\csgdef{@#1cref}##1##2{\@mlcref{#2}{##1}{##2}}%
\csgdef{#1cref}##1{\csuse{@#1cref}{cref}{##1}}%
\csgdef{#1Cref}##1{\csuse{@#1cref}{Cref}{##1}}}
\makeatother

\newcreflang{sw}{swedish}
\newcreflang{f}{french}

\begin{document}

\chapter{Test}
\label{chap-test}

\Cref{chap-test}

\swCref{chap-test} or \swcref{chap-test,chap-test-2}'' or
\swcref{chap-test,chap-test-2,chap-test-3}''

\fCref{chap-test} or
\fcref{chap-test,chap-test-2}'' or
\fcref{chap-test,chap-test-2,chap-test-3}''

\chapter{Test 2}
\label{chap-test-2}

\chapter{Test 3}
\label{chap-test-3}

\end{document}


(I have switched the other language from danish to swedish, as there is currently an error in the danish set-up in cleveref that I will report to the package author.)

• @Marijn I get the following error: Missing \endcsname inserted. Any idea where it may come from? – Joe Dumars Mar 30 at 17:27
• @JoeDumars did you try the exact code that Andrew Swann posted? Did you get any errors there? Or did you get an error when you tried to copy it into your actual document? In that case you might have copied it incompletely or in the wrong position. – Marijn Mar 30 at 21:14
• @Marijn I get errors when I copy it in my document. I don't think I have copied it incompletely. Concerning the position, I have multiple packages in my document. Where should I copy the Adrew Swann's code? – Joe Dumars Mar 31 at 14:39