NGerman babel 不起作用

NGerman babel 不起作用

我需要一些关于 LateX 的帮助,因为我不是最擅长的。所以我目前遇到的问题是 babel 包 [ngerman] 不起作用。英语可以工作,但我需要德语才能工作,我就是搞不清楚为什么。在此处输入图片描述

感谢您的帮助

抱歉回来这么晚 - 代码不是最好的...很抱歉,但我不是程序员

\documentclass[
  12pt,
  chapterprefix,
  egregdoesnotlikesansseriftitles% no sans serif headings etc.
  ]{scrreprt} % for bigger size of text 
%\providecommand*\Ifstr{\ifstr}% needed up to and including KOMA-Script version 3.27, see https://komascript.de/faq_deprecatedif
%\usepackage{blindtext}% only for dummy text
\usepackage{newtxtext}% <- changed
\usepackage[ngerman]{babel} %help: usepackage[ngerman]{babel} does not work ... \enquote: commas should be at the bottom in the beginning, not the top - not running - error line
\usepackage{adjustbox}
\usepackage[final]{pdfpages}
\usepackage{csquotes} %enquote
\usepackage{graphicx}
\usepackage{MnSymbol,wasysym} %smiley
\usepackage{tabularx} % table x for certain width

\usepackage{setspace}

\usepackage{float}

\usepackage{tablefootnote}
\addtolength{\footnotesep}{1mm} %fußnoten abstand 
\interfootnotelinepenalty=10000 %footnote won't run on two pages
\usepackage{footmisc} %footnotes indent 
\setlength{\footnotemargin}{\parindent}  %footnotes indent 

\newenvironment{hanging}[1][2em]{%  %Literaturverzeichnis
  \addmargin[#1]{0pt}\setlength{\parindent}{-#1}\hspace*{-#1}% 
  \ignorespaces 
}{% 
  \endaddmargin 
} 

\setcounter{secnumdepth}{\chapternumdepth}% only parts and chapters should be numbered

\addtokomafont{disposition}{\mdseries}% headings of section, subsection etc. should not be bold

%chapter in toc and on page (numbering)
\RedeclareSectionCommand[
  font=\bfseries\large,% does the same as \setkomafont{chapter}{\bfseries\large}
  tocentrynumberformat={\def\autodot{:}},
  tocdynnumwidth
]{chapter}

\renewcommand\raggedchapter{\centering}% center chapter headings
\renewcommand*{\chaptermarkformat}{\chapappifchapterprefix{\nobreakspace}\thechapter\autodot:\enskip} 

\let\originaladdchaptertocentry\addchaptertocentry
\renewcommand*{\addchaptertocentry}[2]{%
  \IfArgIsEmpty{#1}
    {\originaladdchaptertocentry{#1}{#2}}
    {\originaladdchaptertocentry{\chapappifchapterprefix{\nobreakspace}#1\autodot}{#2}}%
}

% section
\RedeclareSectionCommand[font=\sffamily\Large]{section}% does the same as \setkomafont{section}{\sffamily\Large}
% subsection
\RedeclareSectionCommand[
  %indent=1em,% <- add this if the subsections should be indented
  font=\itshape% changes the font, does the same as \setkomafont{subsection}{\itshape}
]{subsection}

% format headings with style=section, eg. section, subsection and subsubsection
\let\originalsectionlinesformat\sectionlinesformat
\renewcommand\sectionlinesformat[4]{%
  \Ifstr{#1}{section}
    {\centering #3#4}% centers section headings
    {\originalsectionlinesformat{#1}{#2}{#3}{#4}}% original definition for other section levels
}

% use page style empty in in ToC, LoF and LoT
\AfterTOCHead{\thispagestyle{empty}\pagestyle{empty}}
\AfterStartingTOC{\clearpage}

% rename LoF and LoT
\renewcaptionname{english}{\listfigurename}{Figures}
\renewcaptionname{english}{\listtablename}{Tables}

\begin{document}

答案1

问题在于组合

\usepackage[ngerman]{babel}
[...]
\renewcaptionname{english}{\listfigurename}{Figures}
\renewcaptionname{english}{\listtablename}{Tables}

您正在加载babel选项ngerman,这意味着语言english尚未定义。当您这样做时

\renewcaptionname{english}{...}{...}

那么你就会收到错误。

如果您只是编写德语文本,那么请删除这两\renewcaptionname条指令。

答案2

对于 Ubuntu,安装该包:

$ sudo apt -y install texlive-lang-german

解决方案来自这里

相关内容