2

I want to redefine cross-reference name for \subsection. That does work in the following MWE:

\documentclass{scrbook}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage[pdftex]{hyperref}
\usepackage[ngerman]{cleveref}
\usepackage{lipsum}

\crefname{subsection}{Punkt}{Punkte}

\begin{document}

\chapter{Test}\label{test}
\section{Test A}\label{testa}
\lipsum[1]

\subsection{Dummy-Text}\label{dummya}
\lipsum[2]

\subsection{Noch mehr}\label{dummyb}
\lipsum[3]

\section{Querverweis}\label{crossref}
\cref{dummya} in \cref{testa} (\cref{test}) ist irrelevant.
\end{document}

However, it does not work in my real document. There, I have moved this code:

\usepackage[ngerman,nameinlink]{cleveref}
\crefname{table}{Tab.}{Tab.}
\crefname{scheme}{Übersicht}{Übersichten}
\crefname{subsection}{Punkt}{Punkte}

immediately before \begin{document}. Nevertheless, \cref still precedes tables with "Tabelle"/"Tabellen" and subsections with "Abschnitt"/"Abschnitte" (apparently the German default value inherited from section). The strange thing is that the definitions for the type "scheme" are accepted. The only difference between table/subsection and scheme is that I defined the scheme-environment myself, while the others use default counters.

Does anybody have an idea what might be wrong?

  • I can not reproduce the issue. With your code I get: "Punkt 1.1.1 in Abschnitt 1.1 (Kapitel 1) ist irrelevant." in the pdf. – esdd May 18 '16 at 17:19
1

You could use aliase:

\crefname{punkt}{Punkt}{Punkte}
\crefalias{subsection}{punkt}

enter image description here

Code:

\documentclass[american,ngerman]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{hyperref}

\usepackage[nameinlink]{cleveref}
\crefname{tab}{Tab.}{Tab.}
\crefname{scheme}{Übersicht}{Übersichten}
\crefname{abschnitt}{Abschnitt}{Abschnitte}
\crefname{punkt}{Punkt}{Punkte}

\crefalias{section}{abschnitt}
\crefalias{subsection}{punkt}
\crefalias{table}{tab}

\begin{document}
\selectlanguage{ngerman}

\chapter{Test}
\section{asdf}\label{sec}
\subsection{ghjk}\label{sub}
\begin{table}
\caption{A table}\label{tab}
\end{table}

\cref{sec,sub,tab} Plural der Namen: \namecrefs{sec}, \namecrefs{sub} und \namecrefs{tab} 
\end{document}
  • Sorry I didn't respond earlier. Nevertheless, \crefalias works like a charm! :-) – Andreas May 27 '16 at 12:46
1

OK, I've minimized my MWE too much! Apparently, it was babel's fault. This version works:

\documentclass{scrbook}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[american,main=ngerman]{babel}
\usepackage[ngerman,nameinlink]{cleveref}
\crefname{table}{Tab.}{Tab.}
\crefname{scheme}{Übersicht}{Übersichten}
\crefname{section}{Abschnitt}{Abschnitte}
\crefname{subsection}{Punkt}{Punkte}

\begin{document}
\selectlanguage{ngerman}
\crefname{table}{Tab.}{Tab.}
\crefname{scheme}{Übersicht}{Übersichten}
\crefname{section}{Abschnitt}{Abschnitte}
\crefname{subsection}{Punkt}{Punkte}  

\chapter{Test}
\section{asdf}\label{sec}
\subsection{ghjk}\label{sub}
\begin{table}
\caption{A table}\label{tab}
\end{table}

\cref{sec,sub,tab}
\end{document}

Notice the \selectlanguage{ngerman}? This seems to turn on the default values for the default types/counters. Type "scheme" is a custom environment/counter, so it is not reset by \selectlanguage{ngerman}.

Strangely enough, it is not sufficient to define the crefnames after \selectlanguage! If the lines with \crefname are removed from the preamble (leaving just the duplicates after \setlanguage), the default values are used again:

\documentclass{scrbook}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[american,main=ngerman]{babel}
\usepackage[ngerman,nameinlink]{cleveref}

\begin{document}
\selectlanguage{ngerman}
\crefname{table}{Tab.}{Tab.}
\crefname{scheme}{Übersicht}{Übersichten}
\crefname{section}{Abschnitt}{Abschnitte}
\crefname{subsection}{Punkt}{Punkte}

\chapter{Test}
\section{asdf}\label{sec}
\subsection{ghjk}\label{sub}
\begin{table}
\caption{A table}\label{tab}
\end{table}

\cref{sec,sub,tab}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.