Quantcast
Channel: Question and Answer » babel
Viewing all articles
Browse latest Browse all 75

How to make a custom crefformat dependent on language chosen with babel?

$
0
0

For my custom class I use the package and define new custom reference styles:

crefformat{figure}{Meine tolle Abbildung ~#2#1#3}

Is there a way to make this command consider the language chosen with ? Like:

crefformat[ngerman]{figure}{meine tolle Abbildung ~#2#1#3}
crefformat[english]{figure}{my fancy figure ~#2#1#3}

So I get the correct output for what I’ve chosen loading :

usepackage[english]{babel}

The manual states, that it is no problem with something like:

crefformat{equation}{#2cref@equation@name~(#1)#3}

But I can’t see how to apply that to my case.


Edit:

I found a cumbersome solution by myself, but I’d prefer one which wouldn’t require to load all languages with babel (though I don’t know if it’s necessarily a bad thing, I’d just guess its overkill).


MWE:

documentclass{article}

usepackage[demo]{graphicx}
usepackage[english]{babel}
usepackage{hyperref}
usepackage{cleveref}

crefformat{figure}{Abb.~#2#1#3}

begin{document}
    cref{fig:one}

    begin{figure}[h]
        includegraphics[width=textwidth]{example-image-a}
        caption{I am a figurelabel{fig:one}}
    end{figure}

end{document}

Viewing all articles
Browse latest Browse all 75

Trending Articles