0

I'm using the fancyref package in Texmaker and PdfLaTeX and have a problem with the language settings.

One Chapter is in English, the remaining stuff in German.

As soon as I add the language English in my babel package, the text created by fancyref is in English.

However, the last language in the argument should be the main language. Where is my error?

\documentclass[fontsize=11pt, paper=a4, DIV=10, BCOR=8mm, oneside]{scrreprt}
\usepackage{blindtext}
\usepackage[english,ngerman]{babel}
\usepackage[english,german]{fancyref}


\begin{document}
\chapter{Chapter 1}
\blindtext
Test of \fref{eq:reaction1} and of \fref{tab:table1}.
\begin{equation}
A
\label{eq:reaction1}
\end{equation}

\begin{table}
    \centering
    \caption{One}
    \begin{tabular}{cc}
    1 & 2 \\
    3 & 4 \\
    \end{tabular}
\label{tab:table1}
\end{table}

\chapter{Chapter 2}
\selectlanguage{english}

\begin{table}
    \centering
    \caption{Two}
    \begin{tabular}{cc}
    1 & 2 \\
    3 & 4 \\
    \end{tabular}
\label{tab:table2}
\end{table}

Test of reference with \fref{eq:reaction1} and \fref{tab:table2}.

\end{document}
4
  • No, the first chapter should be in german and the second chapter in english.
    – Auk
    Jul 3, 2020 at 20:59
  • But in german language it should be "Tabelle 1.1" and not "tabelle 1.1". There is not tabelle with small capital letter.
    – Auk
    Jul 4, 2020 at 7:40
  • I have hundreds of \fref and it was perfect until I had to add an english chapter (so english as option in babel and fancyref). Isn't there a different solution?
    – Auk
    Jul 4, 2020 at 11:48
  • Okay, I posted a fix. There’s at least one bug like that in the English localization: it gives “in chapter 2” rather than “in Chapter 2.” Yes, I admit, the fact that English uses the same rule as German for chapters (and a few other arbitrary exceptions such as “Book I”) is completely illogical.
    – Davislor
    Jul 4, 2020 at 21:39

1 Answer 1

1

The problem here is that you selected the Babel option ngerman, and fancyref only supports german and english. It hasn’t been updated since last century, so it doesn’t know about Neue Rechtschreibung.

You could use a more recent package such as cleveref, or perhaps hyperref together with varioref. Here is the same document rewritten to use cleveref (with a search-and-replace for \fref and \cref).

\documentclass[
  fontsize=11pt,
  paper=a4,
  DIV=10,
  BCOR=8mm,
  oneside,
  english,
  ngerman]{scrreprt}
\usepackage{blindtext}
\usepackage{babel,cleveref}


\begin{document}
\chapter{Chapter 1}
\blindtext
Test of \cref{eq:reaction1} and of \cref{tab:table1}.
\begin{equation}
A
\label{eq:reaction1}
\end{equation}

\begin{table}
    \centering
    \caption{One}
    \begin{tabular}{cc}
    1 & 2 \\
    3 & 4 \\
    \end{tabular}
\label{tab:table1}
\end{table}

\selectlanguage{english}
\chapter{Chapter 2}

\begin{table}
    \centering
    \caption{Two}
    \begin{tabular}{cc}
    1 & 2 \\
    3 & 4 \\
    \end{tabular}
\label{tab:table2}
\end{table}

Test of reference with \cref{eq:reaction1} and \cref{tab:table2}.

\end{document}

If you want to stay loyal to fancyref, you could change ngerman to german. Another temporary workaround is to copy the code to create new Babel “captions” from german to ngerman.

\documentclass[fontsize=11pt, paper=a4, DIV=10, BCOR=8mm, oneside]{scrreprt}
\usepackage{blindtext}
\usepackage[english,ngerman]{babel}
\usepackage[english,german]{fancyref}

  \fancyrefaddcaptions{ngerman}{%
    \providecommand*{\chaptername}{Kapitel}%
    \providecommand*{\figurename}{Abbildung}%
    \providecommand*{\pagename}{Seite}%
    \providecommand*{\tablename}{Tabelle}%
    \renewcommand*{\Frefchapname}{\chaptername}%
    \renewcommand*{\Frefenumname}{Punkt}%
    \renewcommand*{\Frefeqname}{Gleichung}%
    \renewcommand*{\Freffigname}{\figurename}%
    \renewcommand*{\Freffigshortname}{Abb.}%
    \renewcommand*{\Freffnname}{Fu\ss note}%
    \renewcommand*{\Frefonname}{Auf}%
    \renewcommand*{\Frefpgname}{\pagename}%
    \renewcommand*{\Frefpgshortname}{S.}%
    \renewcommand*{\Frefsecname}{Abschnitt}%
    \renewcommand*{\Frefseename}{Siehe}%
    \renewcommand*{\Freftabname}{\tablename}%
    \renewcommand*{\Freftabshortname}{Tab.}%
    \renewcommand*{\frefchapname}{\Frefchapname}%
    \renewcommand*{\frefenumname}{\Frefenumname}%
    \renewcommand*{\frefeqname}{\Frefeqname}%
    \renewcommand*{\freffigname}{\Freffigname}%
    \renewcommand*{\freffigshortname}{\Freffigshortname}%
    \renewcommand*{\freffnname}{\Freffnname}%
    \renewcommand*{\frefonname}{%
      \MakeLowercase{\Frefonname}%
    }%
    \renewcommand*{\frefpgname}{\Frefpgname}%
    \renewcommand*{\frefpgshortname}{\Frefpgshortname}%
    \renewcommand*{\frefsecname}{\Frefsecname}%
    \renewcommand*{\frefseename}{%
      \MakeLowercase{\Frefseename}%
    }%
    \renewcommand*{\freftabname}{\Freftabname}%
    \renewcommand*{\freftabshortname}{\Freftabshortname}%
  }%

\begin{document}
\chapter{Chapter 1}
\blindtext
Test of \fref{eq:reaction1} and of \fref{tab:table1}.
\begin{equation}
A
\label{eq:reaction1}
\end{equation}

\begin{table}
    \centering
    \caption{One}
    \begin{tabular}{cc}
    1 & 2 \\
    3 & 4 \\
    \end{tabular}
\label{tab:table1}
\end{table}

\selectlanguage{english}
\chapter{Chapter 2}

\begin{table}
    \centering
    \caption{Two}
    \begin{tabular}{cc}
    1 & 2 \\
    3 & 4 \\
    \end{tabular}
\label{tab:table2}
\end{table}

Test of reference with \fref{eq:reaction1} and \fref{tab:table2}.

\end{document}

Monkey-patching is far from an ideal solution, since if the package ever did get an update, this code would still depend on the version from the 1990s.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .