
執筆中の本に独自の見出しを付けようとしています。「左」と「右」という 2 つの見出しを交互に表示したいのですが、問題は、 を使用すると左と右が印刷されないことです\markboth
。
コードは
\documentclass{book}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{graphics,color}
\usepackage[superscript]{cite}
\begin{document}
\pagestyle{myheadings}
\markboth{Right}{Left}
First page
\newpage
Second page
\newpage
Third page
\newpage
Fourth page
\end{document}
これにより、次のことが実現されます。
2ページ目:
しかし、私は次のようになりたいです(以下):
2ページ目:
3番目:
4番目:
答え1
あなたが投稿した希望の出力画像には、ヘッダーの下に罫線が引かれ、余白が縮小されています。余白を設定するには、geometry
パッケージを使用するのが最適です。ヘッダーについては、パッケージが必要な機能を提供します。あなたの構文 (実際には逆にfancyhdr
なっていますが) を使用すると、次のように記述できます。Right
Left
\documentclass[a4paper,12pt]{book}
\usepackage[vmargin=0.2cm,hmargin=1cm,head=16pt,includeheadfoot]{geometry}
\usepackage{fancyhdr}
\fancyhead{}
\fancyfoot{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[LO]{\slshape\rightmark}
\fancyhead[RE]{\slshape\leftmark}
\pagestyle{fancy}
\begin{document}
\markboth{Right}{Left}
\thispagestyle{empty}
First page
\newpage
Second page
\newpage
Third page
\newpage
Fourth page
\end{document}
\pagestyle{empty}
最初のページ (またはコマンドが実行されるページ) にヘッダーがないことを確認します。
\markboth
標準的な方法を使用するには、次のようにします。
\documentclass[a4paper,12pt]{book}
\usepackage[vmargin=0.2cm,hmargin=1cm,head=16pt,includeheadfoot]{geometry}
\usepackage{fancyhdr}
\fancyhead{}
\fancyfoot{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[LO]{\slshape\leftmark}
\fancyhead[RE]{\slshape\rightmark}
\pagestyle{fancy}
\begin{document}
\markboth{Left}{Right}
\thispagestyle{empty}
First page
\newpage
Second page
\newpage
Third page
\newpage
Fourth page
\end{document}