
重複の可能性あり:
ヘッダー、フッター、フォントのカスタマイズ
私はもっと大きなプロジェクト (本) を執筆中ですが、ヘッダーについてはさまざまな可能性があることがわかりました。しかし、私は初心者で、どれがベストなのかわかりません。そこで、ヘッダーを最も効果的に実装するにはどうしたらよいかお聞きしたいのです。ヘッダーにはページ番号とセクション タイトルを表示し、その下に線を引いておきたいのですが、これをどう実装すればよいかわかりません。また、現在テキストの下にあるページ番号は消え、ヘッダーのテキストには色を付けますが、ページ番号は黒にする必要があります。線は 4 pt より少し太くする必要があります。ご協力ありがとうございます。これが私のコードです。
\documentclass{book}
\usepackage{geometry}
\geometry{left=4cm,right=3cm, top=2cm, bottom=2cm}
\usepackage{titlesec}
\titlespacing*{\chapter}{0pt}{-30pt}{20pt}
\titleformat{\chapter}[display]{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
\usepackage[ngerman]{babel}
\usepackage{mathptmx}
\usepackage{helvet}
\usepackage{wallpaper}
\usepackage{color}
\usepackage[final]{pdfpages}
%,bookmarksopenlevel={1}
%\usepackage[hidelinks,bookmarks=true,bookmarksopen=true,bookmarksnumbered=true,colorlinks=true,linkcolor=black,]{hyperref}
\usepackage[colorlinks,linkcolor=black,bookmarksopen=false,
hypertexnames=TRUE,pdfpagelabels=true]{hyperref}[2011/02/05]
\hypersetup{
pdftitle={},
% pdfauthor={},
pdfsubject={Statistics Book},
pdfkeywords={},
}
\usepackage{xcolor,bookmark}
\usepackage{scrextend}
\usepackage{titlepic}
\usepackage{shorttoc}
\usepackage{courier}
\usepackage{type1cm}
\usepackage{zref-abspage}
\usepackage{makeidx}
\usepackage{graphicx}
\usepackage{multicol}
\usepackage[bottom]{footmisc}
\usepackage{tocstyle}
\usetocstyle{allwithdot}
\usepackage{shadethm}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{marginnote}
\usepackage{wrapfig}
\usepackage{paralist}
\usepackage{amssymb}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{ulem}
\definecolor{shadethmcolor}{rgb}{.9,.9,.95}%
\newtheoremstyle{mystyle}
{\topsep}{\topsep}{}{}%
{\bfseries}{:}{.5em}{}%
\theoremstyle{mystyle}
\newmdtheoremenv[hidealllines=true,backgroundcolor=shadethmcolor,skipabove=\topsep,
skipbelow=\topsep]{example}{example}
\begin{document}
\frontmatter%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\setlength{\marginparwidth}{2.1cm}
\marginparsep = -4pt
\pagestyle{plain}
\pagenumbering{Roman}
\include{dedic}
\newpage\section*{}
\include{foreword}
\newpage\section*{}
\include{preface}
\newpage\section*{}
\include{acknow}
\newpage\section*{}
\include{acronym}
%
\shorttableofcontents{Inhalts\"ubersicht}{1}
\bookmark[page=15,rellevel=1,keeplevel,view={XYZ},color=red]{Inhalts\"ubersicht}
\bookmark[page=17,rellevel=1,keeplevel,view={XYZ},color=red]{Inhaltsverzeichnis}
\tableofcontents
\clearpage
\pagenumbering{arabic}
%
\mainmatter%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\include{part1}
\include{chapter1}
\include{chapter2}
\include{chapter3}
\include{part2}
\include{chapter4}
\include{chapter5}
\include{chapter6}
\backmatter
\appendix
\include{appendix}
\listoffigures
\newpage
\listoftables
\backmatter%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\include{glossary}
%\include{solutions}
\cleardoublepage
\phantomsection
\addcontentsline{toc}{part}{Index}
\printindex
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\cleardoublepage
\phantomsection
\addcontentsline{toc}{part}{\"Uber den Autor}
\includepdf{ueberautor}
\includepdf{back}
\end{document}
答え1
まず、ラインを交換する必要があります
\usepackage{titlesec}
と
\usepackage[pagestyles]{titlesec}
コマンドを\newpagestyle
使用できるようにします。次に、構文 のこのコマンドを使用して、独自のヘッダーとフッターのスタイルを作成できます。 「commands」引数には、ヘッダーの下に水平線を含める (希望どおり) か、ヘッダーの内容をカスタマイズする\newpagestyle{stylename}[global style options]{commands}
などの他のコマンドを含めることができます。構文は です。\headrule
\sethead
\sethead[even-left][even-center][even-right]{odd-left}{odd-center}{odd-right}
たとえば、次の行を追加することで、スタイル「mystyle」を作成できます。
\newpagestyle{mystyle}{
\headrule \sethead[\thepage][][\color{red} \chaptertitlename\ \thechapter. \chaptertitle]
{\color{red} \thesection\ \sectiontitle}{}{\thepage}}
\pagestyle{mystyle}
章ではなくセクションのタイトルだけに興味がある場合(bookクラスを使用しているにもかかわらず)、以下を試すことができます。
\newpagestyle{mystyle2}{
\headrule \sethead[\thepage][][\color{red} \thesection\ \sectiontitle]
{\color{red} \thesection\ \sectiontitle}{}{\thepage}}
\pagestyle{mystyle2}
これは期待どおりのはずです。