![ヘッダー - ページ番号とテキストが収まりません](https://rvso.com/image/476232/%E3%83%98%E3%83%83%E3%83%80%E3%83%BC%20-%20%E3%83%9A%E3%83%BC%E3%82%B8%E7%95%AA%E5%8F%B7%E3%81%A8%E3%83%86%E3%82%AD%E3%82%B9%E3%83%88%E3%81%8C%E5%8F%8E%E3%81%BE%E3%82%8A%E3%81%BE%E3%81%9B%E3%82%93.png)
ヘッダーをどう変更して収まるようにしたらよいか、ちょっと混乱しています。奇数ページではページ番号が右側、章 (セクションではない) 名が左側、偶数ページではその逆のヘッダーにしたいです。次のコードを使用しましたが、%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
ご覧ください。スクレイパー-スクレイパーここにタグを付けます。これについては既にいくつかの質問と回答があります。