.png)
この質問は既にされているかもしれませんが、答えが見つからないか、理解できないようです。
私はmuthesis
論文を書くためのテンプレート。これにより、偶数ページの章タイトルは「第 x 章。章の名前」となり、奇数ページにはセクション名と番号が表示されます。
すべてのページに「第 x 章。章の名前」(現在のページ番号も含む) だけを表示するようにするにはどうすればよいですか。
これは fancyhdr で実行できると思いますが、その方法がわかりません。
両面文書を使用していることに注意してください。
誰かが助けてくれるといいですね!
MWE は次のとおりです。
\documentclass[11pt,PhD,twoside]{muthesis}
\usepackage{textcomp}
\usepackage{graphicx}
\usepackage{todonotes}
\usepackage{amsmath}
\usepackage{amstext}
\usepackage{paralist}
\usepackage{enumitem}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage[font=footnotesize,labelfont=bf]{caption}
\usepackage{stackengine}
\usepackage[aboveskip=2pt]{subcaption} % aboveskipchanges spacing beten caption and figure
\usepackage{caption}
\captionsetup[subfigure] {justification=justified,singlelinecheck=false} %%% alignment of subfigure captions
\usepackage{pgfplotstable}
\usepackage[UKenglish]{datetime}
\usepackage{parskip}
\usepackage{booktabs}
\usepackage{colortbl}
\pgfplotstableset{col sep=comma}
\usepackage[none]{hyphenat}
\usepackage{subfig}
\usepackage{multirow}
\usepackage{lscape}
\usepackage{cite}
% for references\
\usepackage{natbib}
%\setlength{\bibhang}{5em}
%%%%%% Make font smaller
\renewcommand{\bibfont}{\normalfont\small}
%%% to sort out issues with urls
\usepackage[hyperindex,breaklinks]{hyperref}
\usepackage{cite}
\usepackage{graphics}
\usepackage{amstext}
\usepackage{amsmath}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{booktabs}
\usepackage{url} % typeset URLs reasonably
\usepackage{listings}
%%%%%% section size
\usepackage[]{titlesec}
\titleformat{\section}
{\normalfont\fontsize{13}{15}\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}
{\normalfont\fontsize{13}{15}\bfseries}{\thesubsection}{1em}{}
\titleformat{\subsubsection}
{\normalfont\fontsize{13}{15}\bfseries}{\thesubsubsection}{1em}{}
\titleformat{\subsubsubsection}
{\normalfont\fontsize{13}{15}\bfseries}{\thesubsubsubsection}{1em}{}
%%%% Number of sections that are numbered increase
\setcounter{tocdepth}{4}
\setcounter{secnumdepth}{4}
%%%%%%%%%%%%%%%
\begin{document}
\title{A thesis}
\author{AN Author}
\school{School of}
\faculty{Faculty}
\def\wordcount{57103}
\beforeabstract
\section*{Abstract}
\addcontentsline{toc}{chapter}{Abstract}
\sloppy
\begin{spacing}{1.0}
\fontsize{12}{12}\normalfont
abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract
\end{spacing}
\afterabstract
\prefacesection{Acknowledgements}
I would like to thank......
\afterpreface
\chapter{Introduction}
\section{Background}
Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background
\clearpage
\section{Background2}
Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background
\clearpage
\section{Background3}
Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background
\end{document}
答え1
いくつかの点:
このクラスを使用する唯一の理由は、それが実装する機関の要件を満たす必要があることです。この場合、レイアウトを変更すると、作業が受け入れられないとみなされます。
そうでない場合は、別のクラスを使用することをお勧めします。このクラスは、優れたタイポグラフィのルールに違反しているという事実を非常に明確に示しています。そうする必要があります。組織の要件では、劣ったタイポグラフィが求められています。
現状では、コードはエラーなしでコンパイルされません。これは次の点と密接に関連しています。
序文が乱雑です。これにより、一貫性を確保することが難しくなり、パッケージが競合する可能性が高まり、奇妙で不可解な問題がほぼ確実に発生し、問題が必然的に発生したときに診断することがより困難になります。
- パッケージを複数回ロードしないでください。
- 特に、異なるオプションを持つパッケージをロードしないでください。
- 同じドキュメント要素を異なる方法でフォーマットするように設計された複数のパッケージをロードしないでください (例:
enumitem
およびparalist
;subcaption
およびsubfig
)。 - 余分なパッケージをロードしないでください。例:
url
およびhyperref
;graphics
およびgraphicx
。 hyperref
重要な順序付け要件(遅れてロードする必要があるなど)に注意してください。- 必要な数だけパッケージを使用し、必要以上に使用しないでください。
あなたの所属機関がそのような印刷上の怪物的な文字を明示的に要求しない限り、論文全体を でタイプセットしないでください
\sloppy
。(これはありそうにありません。他の種類の印刷上の怪物的な文字を頻繁に要求しているにもかかわらず、これが要求されているという話は聞いたことがありません。)
特定の質問に対する回答として、\afterpreface
ページ スタイルを に設定します。このコマンドを に設定するようheadings
に再定義すると、設定が有効になります。fancy
fancyhdr
以下に、より具体的な注釈が付いた完全なコードを示します。必要な機能と不要な機能を簡単に確認できるように、同様の機能を提供するパッケージをグループ化するようにしました。パッケージを使用する理由がわからない場合は、コメント アウトして、コンパイルが中断されるかどうかを確認してください。中断されない場合は、おそらくそのパッケージなしでもかまいません。
ただし、強く推奨されるフォント エンコーディングfontenc
を追加してT1
、スケーラブルな Type1 フォントも取得できるようにしました。
\documentclass[11pt,PhD,twoside]{muthesis}
\usepackage[T1]{fontenc}% recommended
\usepackage{textcomp}
\usepackage{todonotes}
\usepackage{amsmath}
\usepackage{amstext}
% \usepackage{paralist}% enumitem provides similar functionality - stick to one interface
\usepackage{enumitem}
% tables
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{booktabs}
% captions and floats
\usepackage[font=footnotesize,labelfont=bf]{caption}
\usepackage[aboveskip=2pt]{subcaption} % aboveskipchanges spacing beten caption and figure
\captionsetup[subfigure] {justification=justified,singlelinecheck=false} %%% alignment of subfigure captions
% \usepackage{subfig}% if you are using subcaption, don't try to use subfig, too - this way lies madness
\usepackage{stackengine}
% colour, graphics, diagrams
\PassOptionsToPackage{table}{xcolor}
\usepackage{graphicx}% don't load graphics as well - this covers it all already
\usepackage{pgfplotstable}
\pgfplotstableset{col sep=comma}
\usepackage[UKenglish]{datetime}
\usepackage{parskip}
\usepackage[none]{hyphenat}
\usepackage{lscape}
% for references
% \usepackage{cite}% do you really want this as well as natbib? they are likely to fight!
\usepackage{natbib}
%\setlength{\bibhang}{5em}
\renewcommand{\bibfont}{\normalfont\small}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{listings}
\usepackage[]{titlesec}
\usepackage{fancyhdr}
% to sort out issues with urls
% for latex
% \usepackage[hyperindex,breaklinks]{hyperref}% load late: loads url - no need to load separately
% for pdflatex, lualatex or xelatex
\usepackage[hyperindex]{hyperref}% load late: loads url - no need to load separately
\titleformat{\section}
{\normalfont\fontsize{13}{15}\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}
{\normalfont\fontsize{13}{15}\bfseries}{\thesubsection}{1em}{}
\titleformat{\subsubsection}
{\normalfont\fontsize{13}{15}\bfseries}{\thesubsubsection}{1em}{}
\titleformat{\subsubsubsection}
{\normalfont\fontsize{13}{15}\bfseries}{\thesubsubsubsection}{1em}{}
\setcounter{tocdepth}{4}
\setcounter{secnumdepth}{4}
\def\afterpreface{\newpage
\pagestyle{fancy}}
\pagestyle{fancy}
\fancyhf{}
\renewcommand*\headrulewidth{0pt}
\fancyhf[leh,roh]{\thepage}
\fancyhf[loh,reh]{\slshape\leftmark}
\begin{document}
\title{A thesis}
\author{AN Author}
\school{School of}
\faculty{Faculty}
\def\wordcount{57103}
\beforeabstract
\section*{Abstract}
\addcontentsline{toc}{chapter}{Abstract}
% \sloppy% don't do this: It applies \sloppy to the rest of your document which is almost certainly not what you want
\begin{spacing}{1.0}
\fontsize{12}{12}\normalfont% is this a requirement? Because it will give you ugly output which is hard to read
abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract abstract
\end{spacing}
\afterabstract
\prefacesection{Acknowledgements}
I would like to thank......
\afterpreface
\chapter{Introduction}
\section{Background}
Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background
\clearpage
\section{Background2}
Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background
\clearpage
\section{Background3}
Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background
\end{document}
答え2
それぞれの側を定義するには、オプションを使用して偶数ページ番号と奇数ページ番号、および使用するヘッダーの側を指定します。この形式は、私が作業している本のもので、ヘッダーを開いているページの「外側」に押し出します。
\fancyhead{} % clear all header fields
\fancyhead[RO]{The Book Title} % [RO] here means Right/Odd numbered page
\fancyhead[LE]{\chaptername \ \thechapter} % {LE] here means Left/Even numbered page
あなたの場合、任意の場所にページ番号を挿入するには、\thepage を含めます。
\fancyhead{} % clear all header fields
\fancyhead[RO]{\chaptername \ \thechapter \ \thepage} % [RO] here means Right/Odd numbered page
\fancyhead[LE]{\chaptername \ \thechapter \ \thepage} % {LE] here means Left/Even numbered page