# crefname in preamble is ignored

I'm not sure whether this question is useful, but I have a strange LaTeX source file where\crefname{figure}{Fig.}{Figs.} needs to be after \begin{document}.

I've tried to create a minimal working example, but in the simplest-possible example, \crefname in the preamble does take effect.

So, somehow, in my real LaTeX source, which uses tons of packages, something interferes with \crefname.

Does somebody think of a possible explanation? It would take a lot of time for me to debug this (and I wouldn't probably spend the time because I already know a workaround, that is, to place the declarations after \begin{document}.).

I'm using lualatex in texlive 2021 on macOS.

Answer: Thanks to the comments, I've been able to solve the problem. Initially, I had

\usepackage{polyglossia}
\setmainlanguage{english}


When I replaced it with

\usepackage[english]{babel}


the problem went away: \crefname now takes effect.

• most likely your \.....name commands are being set by a babel language option and the default language is set at begin document Aug 12 at 19:02
• Please do tell us whether you employ the babel package and, if that's the case, which language(s) you specify.
– Mico
Aug 12 at 19:05
• Since you apparently want to change the default from fig. to Fig. have you tried the capitalise option of the cleveref package? Aug 12 at 19:14
• Do you have any language switch command \selectlanguage in your document? Aug 13 at 9:55
• Thank you all for your ideas. You all are brilliant! It turns out that the problem was caused by polyglossia. I've switched to babel and the problem has disappeared. (But is this considered a bug on the side of polyglossia or cleveref ?)
– Ryo
Aug 14 at 4:57

So the cleveref package acutally has options that do that for you. Even consistently for figures, tables, and other objects that can be referenced.

As mentioned in my comment the capitalise or capitalize option will turn the lower-case abbreviation \cref to upper-case abbreviations, leaving the non-abbreviated version \Cref unchanged (it is in upper-case anyways.)

To change the space between the label and the number, the package options have you covered as well: There is the following command \crefdefaultlabelformat{} which allows you e.g. to add brackets or spaces to your references (see manual page 12 for more details on that) Again, this ensures consistent output for all your references, not just figures.

EDIT: Using the above options leads to slighty inconsistent spacing when referencing more than one object, therefore you need to also adjust the conjunctions using \crefpairconjunction and \crefrangeconjunction

In a self-contained example, this would look something like this:

\documentclass{article}

\usepackage[ngerman]{babel}
\usepackage[capitalise]{cleveref}

\crefdefaultlabelformat{\!#2#1#3}
\newcommand{\crefpairconjunction}{\! and }
\newcommand{\crefrangeconjunction}{\! to }

\begin{document}
\cref{fig:somefigure}.

\cref{fig:somefigure,fig:otherfigure}.

\cref{fig:somefigure,fig:otherfigure,fig:morefigure}.

\Cref{fig:somefigure}.

\Cref{fig:somefigure,fig:otherfigure}.

\Cref{fig:somefigure,fig:otherfigure,fig:morefigure}.

\begin{figure}[ht]
\caption{Some figure.\label{fig:somefigure}}
\end{figure}
\begin{figure}[ht]
\caption{Some other figure.\label{fig:otherfigure}}
\end{figure}
\begin{figure}[ht]
\caption{Yet another figure.\label{fig:morefigure}}
\end{figure}
\end{document}

• Are you saying that \crefname should never be used? If all modifications can be achieved by other methods, \crefname should indeed be removed as a user interface. As long as \crefname is exposed to the user as a user interface, the same problem as I encountered will happen.
– Ryo
Aug 15 at 5:18
• By the way, your excellent answer above should really be the answer to tex.stackexchange.com/questions/122898/…
– Ryo
Aug 15 at 5:27
• No, that is not what I'm saying. There may be legitimate reasons to redefine the reference name, e.g. if you want all of your figures to be called Illustration or Graph. And there are also packages that will allow you to define you own floats. These will not have a ref name, so you will need to manually define that (I guess, have not tested that). But in general: Yes, try to avoid manually interfering with a package, especially if it has built-in options that do the job for you. Aug 15 at 10:58
• The question you refer to is from 2013, so I cannot actually guarantuee that at the time, the given answer was the best possible answer. Just try to watch out for any questions/answers that are this old, because LaTeX and most packages are constantly being updated and new features will be implemented, while others may become obsolete. This is also the reason why you should avoid using random templates from other people. Aug 15 at 11:02
• Feel free to accept my answer though, if you feel it solves your issue. Aug 15 at 11:02