tudace / tuda_latex_templates

LaTeX Templates for TU Darmstadt
LaTeX Project Public License v1.3c
212 stars 71 forks source link

cleveref conflict with TUDaThesis/PhD #379

Closed xylophoneengine closed 2 years ago

xylophoneengine commented 2 years ago

The thesis latex-template passes the package ngerman to the documentclass although the package babel is loaded with the ngerman options. The package ngerman is outdated and its use together with babel might lead to serious problems.

In my case my tex capacity exceeded when using the cleveref-package with ngerman and babel. Removing ngerman in line 2 fixed that problem.

Please consider passing babel to the documentclass instead of ngerman and thus using both packages.

TeXhackse commented 2 years ago

Please make a difference between the ngerman option and the ngerman package. We don't load the ngerman package.

Anyway there will be a renaming of ngerman to german within the next LaTeX release. Therefore this name conflict will be avoided anyway. It will be changed with the next release of TUDa-CI.

Maybe I should add that we always load the main language as a global option to make other packages to be able to use it as well. That's the reason why it's set two times within the template.

TeXhackse commented 2 years ago

@xylophoneengine I tried to reconstruct this. And I cannot. In case I should have a look at the conflict concerned by cleveref, please give me a minimal working example.

xylophoneengine commented 2 years ago

@TeXhackse Thank you for your help. Minimal example:

\documentclass[
    ngerman,
    ruledheaders=section,
    class=report,
    thesis={type=bachelor},
    accentcolor=1b,
    custommargins=false,
    marginpar=false,
    BCOR=12mm,
    twoside,
    open=right,
    parskip=half-,
    fontsize=11pt,
    IMRAD=false,
    bibliography=totoc,
]{tudapub}

\usepackage{iftex}
\ifPDFTeX
    \usepackage[utf8]{inputenc}
\fi
\usepackage[english, main=ngerman]{babel}
\usepackage{cleveref}
\usepackage{amsthm}
\newtheorem{Requirement}{Requirement}[chapter]
\crefname{Requirement}{Requirement}{Requirements}

\begin{document}

\Metadata{
    title=TUDaThesis - Abschlussarbeiten im CD der TU Darmstadt,
    author=Marei Peischl
}
\title{TUDaThesis}
\subtitle{TU Darmstadt}
\author[M. Peischl]{Marei Peischl}
\reviewer{Marei Peischl}
\department{ce}
\institute{Institut}
\group{Arbeitsgruppe}
\submissiondate{\today}
\examdate{\today}
\maketitle
\affidavit
\tableofcontents
\chapter{Über diese Datei}

\begin{Requirement}
    This is some random requirement.
    \label{req: example}
\end{Requirement}

\cref{req: example} is a random requirement which makes no sense.

\end{document}

Compiling this will result in the following error: image

Removing "ngerman" from the documentclass it compiles and displays the pdf: image

Do ignore the bibtex error. I did not create a bibliography file.

TeXhackse commented 2 years ago

Thanks so. It has nothing to do with the ngerman package at all. You get the same error when you load cleveref with the german option. The cleveref documentation itself states, what one should load the language option and even recommends using it as a global option.

The bad news about this is, that cleveref doesn't support an „within document changing“ of the names. KOMA-Script is doing this by appending content to \extrasgerman cleveref is preventing this from being expandable and this is creating the endless loop.

Actually this is nothing directly caused by TUDa-CI rather by some kind of incompatibility between cleveref and KOMA-Script. I will think about it, what's a good solution and will then get into contact to the authors themselves. But please for future Reports please ensure that the description you give is actually true. You could have find out that ngerman is never loaded within your log anyway or could have taken a look at the clevered documentation which also suggests to load the language as an option.

TeXhackse commented 2 years ago

For convenience here is a MWE without TUDa-CI

\documentclass[ngerman]{scrbook}

\usepackage{babel}
\usepackage{cleveref}

\crefname{Requirement}{Requirement}{Requirements}

\defcaptionname{ngerman, german}{\testname}{test}

\begin{document}
\end{document}
xylophoneengine commented 2 years ago

Thank you very much!

schoeps commented 2 years ago

By the way, maybe \autoref from the hyperref package does what you are looking for (and you may have loaded hyperref anyway)?

xylophoneengine commented 2 years ago

That's a great idea! I solved my problem by redefining a whole new theorem type. Cleveref is then able to correctly reference it without defining the reference name:

\newtheoremstyle{exampstyle}
  {-3pt} % Space above
  {-3pt} % Space below
  {} % Body font
  {} % Indent amount
  {\bfseries} % Theorem head font
  {:} % Punctuation after theorem head
  {.5em} % Space after theorem head
  {} % Theorem head spec (can be left empty, meaning `normal')
\theoremstyle{exampstyle}\newtheorem{Requirement}{Requirement}[chapter]
xylophoneengine commented 2 years ago

That's a great idea! I solved my problem by redefining a whole new theorem type. Cleveref is then able to correctly reference it without defining the reference name:

This has somehow stopped working for me. Fixed it by importing cleveref AFTER amsth:

\documentclass[
 %  ngerman,
    ruledheaders=section,
    class=report,
    thesis={type=bachelor},
    accentcolor=1b,
    custommargins=false,
    marginpar=false,
    BCOR=12mm,
    twoside,
    open=right,
    parskip=half-,
    fontsize=11pt,
    IMRAD=false,
    bibliography=totoc,
]{tudapub}

\usepackage{iftex}
\ifPDFTeX
    \usepackage[utf8]{inputenc}
\fi
\usepackage[english, main=ngerman]{babel}
\usepackage{amsthm}
\usepackage{cleveref}
\newtheoremstyle{exampstyle}{-3pt}{-3pt}{}{}{\bfseries}{:}{.5em}{}
\theoremstyle{exampstyle}\newtheorem{Requirement}{Requirement}[chapter]

\begin{document}\chapter{Referencing a custom theorem-environment with cleveref}
\begin{Requirement}
    This is a random requirement.
    \label{req: example}
\end{Requirement}
\Cref{req: example} is a random requirement which makes no sense. Another reference to \cref{req: example}  should be in this sentence.
\end{document}