autorefnames を変更するとヘッダーにスペースが挿入されます

autorefnames を変更するとヘッダーにスペースが挿入されます

私はhyperrefと を使用していますautorefが、autorefnames を再定義しています。 を使用して、章とセクションの名前をページ ヘッダーに入れていますscrlayer-scrpage。見出しの左側には常に不要なスペースがあります... 偶数ページか奇数ページかは関係ありません。章またはセクションの名前が長すぎて見出しに収まらない場合は特に顕著です。例では、原理的には収まるはずですが、スペースのせいで収まりません。

s の名前を変更しなければautoref、すべて問題ありません。ここで何が起こっているのでしょうか。どうすれば修正できますか?

私はもう試した「ガツガツ食べる」、新しい の前後に があります\...autorefnameが、役に立ちません。

\documentclass[pdfa,a4paper,
               11pt,
               bibliography=totoc,
               numbers=noenddot,
               twoside,openright,
               parskip=half]{scrbook}
\usepackage{lipsum}
% ********************************************************************
% Languages, Typesetting
% ******************************************************************** 
\usepackage[ngerman, english]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}         %windows: latin9, linux: utf8

% ********************************************************************
% page layout
% ********************************************************************
\usepackage[]{scrlayer-scrpage}
\renewcommand{\chapterpagestyle}{empty} % no headings or footings on first chapter page
\renewcommand{\chaptermark}[1]{\markboth{{#1}}{{#1}}}
\renewcommand{\sectionmark}[1]{\markright{\upshape{\thesection}\enspace{#1}}}
\lehead{\mbox{\llap{\small\upshape\thepage\kern2em}\scshape\headmark\hfil}}
\rohead{\mbox{\hfil{\scshape\headmark}\rlap{\small\kern2em\upshape\thepage}}}
\chead{}\ifoot{}\cfoot{}\ofoot{}
\pagestyle{scrheadings}

% ********************************************************************
% Hyperreferences, always load last
% ********************************************************************
\usepackage[]{hyperref}
% Commenting this whole block fixes the problem
\makeatletter
\@ifpackageloaded{babel}
{
    \addto\extrasenglish{
        \renewcommand*{\figureautorefname}{Figure}
        \renewcommand*{\tableautorefname}{Table}
        \renewcommand*{\partautorefname}{Part}
        \renewcommand*{\chapterautorefname}{Chapter}
        \renewcommand*{\sectionautorefname}{Section}
        \renewcommand*{\subsectionautorefname}{Section}
        \renewcommand*{\subsubsectionautorefname}{Section}
        \renewcommand*{\appendixautorefname}{Appendix}
    }
}{\relax}
\makeatother


\begin{document}
\part{Intro}
\chapter{Short chapter name}
\lipsum[1]
\section{Short section name}
\lipsum
\lipsum
\chapter{Very long chapter name just not fitting into the headline}
\lipsum[1]
\section{Very long section name just not fitting into the headline}
\lipsum
\lipsum
\end{document}

答え1

使用できます

\AfterPackage*{babel}
{
  \renewcaptionname{english}{\figureautorefname}{Figure}
  \renewcaptionname{english}{\tableautorefname}{Table}
  \renewcaptionname{english}{\partautorefname}{Part}
  \renewcaptionname{english}{\chapterautorefname}{Chapter}
  \renewcaptionname{english}{\sectionautorefname}{Section}
  \renewcaptionname{english}{\subsectionautorefname}{Section}
  \renewcaptionname{english}{\subsubsectionautorefname}{Section}
  \renewcaptionname{english}{\appendixautorefname}{Appendix}
}

\AfterPackage*scrlfileは、KOMA スクリプト クラスによって自動的にロードされるパッケージによって定義されます。\renewcaptionnameも KOMA スクリプト コマンドです。

さらに、ページレイアウトの設定を次のように変更します。

\renewcommand{\chapterpagestyle}{empty} % no headers or footers on first chapter page
\usepackage[]{scrlayer-scrpage}
\automark[chapter]{chapter}
\automark*[section]{}
\renewcommand\chaptermarkformat{}% no chapter number in header/footer
\addtokomafont{pagehead}{\scshape}
\addtokomafont{pagenumber}{\small}
\clearmainofpairofpagestyles
\lehead{\mbox{\llap{\pagemark\kern2em}\headmark}}
\rohead{\mbox{{\ifstr{\leftmark}{\rightmark}{}{\upshape}\headmark}\rlap{\kern2em\pagemark}}}

例:

\documentclass[pdfa,a4paper,
               11pt,
               bibliography=totoc,
               numbers=noenddot,
               twoside,openright,
               parskip=half]{scrbook}
\usepackage{lipsum}
% ********************************************************************
% Languages, Typesetting
% ******************************************************************** 
\usepackage[ngerman, english]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

% ********************************************************************
% page layout
% ********************************************************************
\renewcommand{\chapterpagestyle}{empty} % no headers or footers on first chapter page
\usepackage[]{scrlayer-scrpage}
\automark[chapter]{chapter}
\automark*[section]{}
\renewcommand\chaptermarkformat{}%  no chapter number in header/footer
\addtokomafont{pagehead}{\scshape}
\addtokomafont{pagenumber}{\small}
\clearmainofpairofpagestyles
\lehead{\mbox{\llap{\pagemark\kern2em}\headmark}}
\rohead{\mbox{{\ifstr{\leftmark}{\rightmark}{}{\upshape}\headmark}\rlap{\kern2em\pagemark}}}

% ********************************************************************
% Hyperreferences, always load last
% ********************************************************************
\usepackage[]{hyperref}

\AfterPackage*{babel}
{
  \renewcaptionname{english}{\figureautorefname}{Figure}
  \renewcaptionname{english}{\tableautorefname}{Table}
  \renewcaptionname{english}{\partautorefname}{Part}
  \renewcaptionname{english}{\chapterautorefname}{Chapter}
  \renewcaptionname{english}{\sectionautorefname}{Section}
  \renewcaptionname{english}{\subsectionautorefname}{Section}
  \renewcaptionname{english}{\subsubsectionautorefname}{Section}
  \renewcaptionname{english}{\appendixautorefname}{Appendix}
}

\begin{document}
\part{Intro}
\chapter{Short chapter name}
\lipsum[1]
\section{Short section name}
\lipsum
\lipsum
\chapter{Very long chapter name just not fitting into the headline}
\lipsum[1]
\section{Very long section name just not fitting into the headline}
\lipsum
\lipsum
\end{document}

ここに画像の説明を入力してください


アップデート:コメントに関する別の例:

\documentclass[pdfa,a4paper,
               11pt,
               bibliography=totoc,
               numbers=noenddot,
               twoside,openright,
               parskip=half]{scrbook}
\usepackage{lipsum}
% ********************************************************************
% Languages, Typesetting
% ******************************************************************** 
\usepackage[ngerman, english]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{microtype}

\usepackage{textcase}
\DeclareRobustCommand{\spacedlowsmallcaps}[1]{\textls[80]{\scshape\MakeTextLowercase{#1}}}
% ********************************************************************
% page layout
% ********************************************************************
\renewcommand{\chapterpagestyle}{empty} % no headers or footers on first chapter page
\usepackage[]{scrlayer-scrpage}
\automark[chapter]{chapter}
\automark*[section]{}
\renewcommand*\chaptermarkformat{}%  no chapter number in header/footer
\renewcommand*\sectionmarkformat{{\small\thesection\autodot\enskip}}% section number using \small
\addtokomafont{pagenumber}{\small}% page number using \small
\clearmainofpairofpagestyles% remove all default entries for page style scrheadings
\lehead{\mbox{\llap{\pagemark\kern2em}\spacedlowsmallcaps{\headmark}}}
\rohead{\mbox{\spacedlowsmallcaps{\headmark}\rlap{\kern2em\pagemark}}}

% ********************************************************************
% Hyperreferences, always load last
% ********************************************************************
\usepackage[]{hyperref}

\AfterPackage*{babel}
{
  \renewcaptionname{english}{\figureautorefname}{Figure}
  \renewcaptionname{english}{\tableautorefname}{Table}
  \renewcaptionname{english}{\partautorefname}{Part}
  \renewcaptionname{english}{\chapterautorefname}{Chapter}
  \renewcaptionname{english}{\sectionautorefname}{Section}
  \renewcaptionname{english}{\subsectionautorefname}{Section}
  \renewcaptionname{english}{\subsubsectionautorefname}{Section}
  \renewcaptionname{english}{\appendixautorefname}{Appendix}
}

\begin{document}
\part{Intro}
\chapter{Short chapter name}
\lipsum[1]
\section{Short section name}
\lipsum
\lipsum
\chapter{Very long chapter name just not fitting into the headline}
\lipsum[1]
\section{Very long section name just not fitting into the headline}
\lipsum
\lipsum
\end{document}

または\MakeTextLowercaseでは使用できないことに注意してください。したがって、のいずれかに を挿入する必要があります。\setkomafont\addtokomafont\spacedlowsmallcaps\lehead\rohead

答え2

いずれのステートメントも、プリアンブル内ではなくタイプセット中に呼び出される\renewcommand*{\....autorefname}{...}内部で実行されるため、余分なスペース文字が発生します。\extraenglish

%各行の末尾にを追加します。

\documentclass[pdfa,a4paper,
               11pt,
               bibliography=totoc,
               numbers=noenddot,
               twoside,openright,
               parskip=half]{scrbook}
\usepackage{lipsum}
% ********************************************************************
% Languages, Typesetting
% ******************************************************************** 
\usepackage[ngerman, english]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}         %windows: latin9, linux: utf8

% ********************************************************************
% page layout
% ********************************************************************
\usepackage[]{scrlayer-scrpage}
\renewcommand{\chapterpagestyle}{empty} % no headings or footings on first chapter page
\renewcommand{\chaptermark}[1]{\markboth{{#1}}{{#1}}}
\renewcommand{\sectionmark}[1]{\markright{\upshape{\thesection}\enspace{#1}}}
\lehead{\mbox{\llap{\small\upshape\thepage\kern2em}\scshape\headmark\hfil}}
\rohead{\mbox{\hfil{\scshape\headmark}\rlap{\small\kern2em\upshape\thepage}}}
\chead{}\ifoot{}\cfoot{}\ofoot{}
\pagestyle{scrheadings}

% ********************************************************************
% Hyperreferences, always load last
% ********************************************************************
\usepackage[]{hyperref}
% Commenting this whole block fixes the problem
\makeatletter
\@ifpackageloaded{babel}
{
  \addto\extrasenglish{%
    \renewcommand*{\figureautorefname}{Figure}%
    \renewcommand*{\tableautorefname}{Table}%
    \renewcommand*{\partautorefname}{Part}%
    \renewcommand*{\chapterautorefname}{Chapter}%
    \renewcommand*{\sectionautorefname}{Section}%
    \renewcommand*{\subsectionautorefname}{Section}%
    \renewcommand*{\subsubsectionautorefname}{Section}%
    \renewcommand*{\appendixautorefname}{Appendix}%
  }%
}{\relax}
\makeatother


\begin{document}
\part{Intro}
\chapter{Short chapter name}
\lipsum[1]
\section{Short section name}
\lipsum
\lipsum
\chapter{Very long chapter name just not fitting into the headline}
\lipsum[1]
\section{Very long section name just not fitting into the headline}
\lipsum
\lipsum
\end{document}

関連情報