ヘッダー - ページ番号とテキストが収まりません

ヘッダー - ページ番号とテキストが収まりません

ヘッダーをどう変更して収まるようにしたらよいか、ちょっと混乱しています。奇数ページではページ番号が右側、章 (セクションではない) 名が左側、偶数ページではその逆のヘッダーにしたいです。次のコードを使用しましたが、%KernXXem を使用してページ番号を移動することしかできませんでした。これはすべての章名に適しているわけではありません。さらに、章番号が表示されません。まだ LaTeX の使い方を学んでいる最中なので、どなたか助けていただけるととてもうれしいです。よろしくお願いします。:

これまでの結果はここで見ることができます

\PassOptionsToPackage{headsepline, automark}{scrlayer-scrpage}
\setkomafont{pageheadfoot}{\normalfont}     % Kapielname u.ä. nicht kursiv in Kopfzeile
\usepackage[automark,headsepline=.4pt]{scrlayer-scrpage}

   
    \RequirePackage{scrlayer-scrpage} % provides headers and footers (KOMA Script)
     \clearpairofpagestyles
  




    
    \let\MakeMarkcase\spacedlowsmallcaps
    \ifthenelse{\boolean{ct@nochapters}}%
        {\relax}%
        {\renewcommand{\chaptermark}[1]{\markboth{\spacedlowsmallcaps{#1}}{\spacedlowsmallcaps{#1}}}} 
 \renewcommand{\chaptermark}[1]{\markrboth{\textsc{\thechapter}\enspace\spacedlowsmallcaps{#1}\hline}
   \automark[chapter]{chapter}
   {\textsc{\thechapter}\enspace\spacedlowsmallcaps{#1}\hline}}
    %links
    \lehead{\mbox{\hfil{\small\pagemark\kern25em}\headmark\hfil}}
        %rechts
    \rohead{\mbox{\hfil{\small\headmark\kern25em\pagemark}}}
  
  \ofoot[\small\pagemark]{}% only for plain.scrheadings page style (first page of a chapter)



    
    \renewcommand{\headfont}{\small}
 \DeclareRobustCommand{\fixBothHeadlines}[2]{} % <--- ToDo
         \def\toc@heading{%
            \ifthenelse{\boolean{ct@nochapters}}%
            {\chapter*{\contentsname}}%chapters
            \@mkboth{\spacedlowsmallcaps{\contentsname}}{\spacedlowsmallcaps{\contentsname}}} 

答え1

ページ ヘッダーの左側に章番号、ページ ヘッダーの右側にページ番号を表示するには、次の操作を行います。

\usepackage{scrlayer-scrpage}
\automark[chapter]{chapter}
\clearpairofpagestyles
\ihead{\headmark}
\ohead*{\pagemark}

ヘッダーの下に水平線を追加するには、オプションheadseplineとオプションを追加しますplainheadsepline

マークの大文字と小文字をさらに変更するには、 を再定義することができます\MakeMarkcase。次のようなものを探しているようです:

\usepackage{microtype}
\DeclareRobustCommand{\spacedlowsmallcaps}[1]{\textsc{\textls[80]{\MakeLowercase{#1}}}}
\AtBeginDocument{\let\MakeMarkcase\spacedlowsmallcaps}

ただし、フォントのみを変更する場合は、次のように\setkomafont{…}{…}または を使用できます\addtokomafont{…}{…}

\setkomafont{pageheadfoot}{}

注:\normalfontはすでにベースになっているので、ここでは追加していません。

全体として、次のようなものを探しているようです:

\documentclass[headsepline]{scrbook}
\usepackage{blindtext}
\usepackage{microtype}
\DeclareRobustCommand{\spacedlowsmallcaps}[1]{\textsc{\textls[80]{\MakeLowercase{#1}}}}
\usepackage{scrlayer-scrpage}
\automark[chapter]{chapter}
\clearpairofpagestyles
\ihead{\headmark}
\ohead*{\pagemark}
\setkomafont{pageheadfoot}{}
\AtBeginDocument{\let\MakeMarkcase\spacedlowsmallcaps}
\begin{document}
\blinddocument
\end{document}

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

章の先頭ページにもヘッダーを表示したい場合は、これをサポートするクラス(KOMAスクリプトクラスなど)が必要です。たとえば、次のように追加します。

\renewcommand*{\chapterpagestyle}{headings}

上記の例のドキュメントのプリアンブルに次のコードを追加すると、次のようになります。

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

章の開始ページにのみページ番号を表示する代わりに。

「ヘッダーとフッターscrlayer-scrpage」を参照してください。KOMAスクリプトマニュアルと「ページの先頭と末尾を変更する方法」使用方法の詳細については、KOMA-Script wikiをscrlayer-scrpageご覧ください。ここにタグを付けます。これについては既にいくつかの質問と回答があります。

関連情報