标题与文本框架不对齐

标题与文本框架不对齐

我有以下尝试自定义页眉和页脚的序言。但是,我发现该包babel似乎导致左页的页眉与文本框架不对齐。如何使其与文本框对齐,就像在正确的页面上一样?我需要在某处指定我的文档是用德语和英语编写的,但不一定通过babel

左页:

在此处输入图片描述

右页:

在此处输入图片描述

\documentclass[
    twoside,
    footinclude=false,
    fontsize=12pt,
    paper=a4,
    listof=totoc,
    bibliography=totoc,
    BCOR=12mm,
    DIV=12,
    chapterprefix=on,
    numbers=noenddot
]{scrbook}


\usepackage[ngerman,english]{babel} % <--- This line causes headers on the left page not aligned with the text frame

\usepackage{xcolor}
\usepackage{lipsum}

\usepackage[
    top=2cm,
    bottom=2cm,
    inner=3cm,
    outer=2cm,
    a4paper,
    headsep=0.5cm,
    footskip=1cm
]{geometry}

% ------------------------------------------------------
\usepackage{scrlayer-scrpage}
\clearpairofpagestyles   % Removes the default page header and footer entries

\renewcommand{\chaptermark}[1]{\markboth{#1}{}}   % Change this to include chapter name only

\usepackage[final,letterspace=175]{microtype}   % For micro-typographical adjustments
% The package 'microtype' provides the command '\textls{<letterspaced-text>}'
% (Source: https://tex.stackexchange.com/a/62351/245306)

\lehead{\color{gray} \sffamily \textls{\MakeUppercase\leftmark}}
\rohead{\color{gray} \sffamily \textls{\MakeUppercase\leftmark}}
\lefoot[\pagemark]{\color{gray} \sffamily \textls{\pagemark}}
\rofoot[\pagemark]{\color{gray} \sffamily \textls{\pagemark}}
% ------------------------------------------------------

% ------------------------------------------------------
\usepackage{varioref}
\usepackage[unicode,hidelinks,bookmarksnumbered]{hyperref} % 'hidelinks' removes colored boxes around references and links
% According to the documentation, 'hyperref' should be loaded as the last package
% A list of packages that should be loaded after 'hyperref' can be found at:
% https://tex.stackexchange.com/questions/1863/which-packages-should-be-loaded-after-hyperref-instead-of-before
\hypersetup{
    colorlinks=true,
    linkcolor=codegreen,
    citecolor=blue,
    filecolor=codegray,
    urlcolor=darkblue,
}
\newcommand{\aref}[1]{\hyperref[#1]{Appendix~\ref*{#1}}}
\addto\extrasenglish{
    \renewcommand{\chapterautorefname}{Chapter}
    \renewcommand{\sectionautorefname}{Section}
    \let\subsectionautorefname\sectionautorefname
    \let\subsubsectionautorefname\sectionautorefname
}
\usepackage{url}
\usepackage[nameinlink,noabbrev]{cleveref}
\providecommand\algorithmname{Algorithm}
\usepackage{nameref}
% ------------------------------------------------------


\begin{document}

\frontmatter
\pagestyle{plain}
\listoffigures
\listoftables

\mainmatter
\pagestyle{scrheadings}

\chapter{Introduction}
\lipsum[1-50]
\chapter{Methodology}
\lipsum[1-50]

\end{document}

答案1

其实空格是\addto\extrasenglish命令引入的。添加%到没有以宏结尾的行的末尾。

\addto\extrasenglish{%
    \renewcommand{\chapterautorefname}{Chapter}%
    \renewcommand{\sectionautorefname}{Section}%
    \let\subsectionautorefname\sectionautorefname
    \let\subsubsectionautorefname\sectionautorefname
}

答案2

在 MWE 中scrbook使用 KOMA-Script 类。因此,你可以\addto\extrasenglish{...}

\renewcaptionname{english}{\chapterautorefname}{Chapter}
\renewcaptionname{english}{\sectionautorefname}{Section}
\renewcaptionname{english}{\subsectionautorefname}{\sectionautorefname}
\renewcaptionname{english}{\subsubsectionautorefname}{\sectionautorefname}

相关内容