在文档类“报告”中,在某些特定页面中,我希望有两种页眉。我希望奇数页的页眉如下:
Title1 ................................................. Page number
偶数页的页眉如下:
Page number ............................................ Title2
我应该解释一下,标题 1 与“我的报告名称”相关,标题 2 是固定的,与章节名称无关。下面我提到了我的工作:
\documentclass[11pt,a5paper,twoside]{report}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage[top=25mm, bottom=25mm, left=20mm, right=20mm]{geometry}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{framed}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{indentfirst}
\usepackage{emptypage}
\usepackage{titlesec}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[colorlinks=true,linkcolor=Blue,urlcolor=Blue,citecolor=Blue]{hyperref}
\usepackage{algorithm,algcompatible}
\usepackage[textfont={small},labelfont={rm,small},format=hang,labelsep=quad,justification={centering},aboveskip=1pt,belowskip=1pt]{caption}
\usepackage{subcaption}
\usepackage[nottoc]{tocbibind}
\usepackage{tocloft}
\usepackage{times}
\usepackage{cite}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\titleformat{\chapter}[display]
{}{}{1ex}{\bfseries\fontsize{15}{16}\selectfont}[]
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}} % for chapters
\begin{document}
\pagenumbering{alph}
\tableofcontents
\cleardoublepage
\pagestyle{plain}
\pagenumbering{arabic}
This is my work.
\end{document}
我该怎么做?
谢谢
答案1
这是一个带有 的简单解决方案titleps
,它使用pagestyles
选项加载titlesec
。同样, clearempty
选项取代了加载emptypage
包。
请注意,章节的第一页(如果有)仍具有plain
页面样式(页码位于页脚中央)。这可以进行修改,添加命令\titleformat{\chapter}
或使用 重新定义plain
页面样式\renewpagestyle{plain}
。
我借此机会简化了 的选项geometry
。其他一些备注:hyperref
应作为最后一个包加载,只有极少数例外(最值得注意的是cleveref
应在之后加载)。此外,如果您的文档中有数学(我想是的,因为您加载了 mathtools),则应使用适合的数学字体times
- 我newtxmath
为此加载了基于 Times-clone 的TeX Gyre Termes
广告,我建议,如果允许您替换时间,也加载newtxtext
,以获得真正的小型大写字母和一些其他精美功能。
\documentclass[11pt,a5paper,twoside, dvipsnames]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage[vmargin=25mm, hmargin=20mm]{geometry}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{framed}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{indentfirst}
\usepackage{emptypage}
\usepackage[pagestyles, clearempty]{titlesec}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{algorithm,algcompatible}
\usepackage[textfont={small},labelfont={rm,small},format=hang,labelsep=quad,justification={centering},aboveskip=1pt,belowskip=1pt]{caption}
\usepackage{subcaption}
\usepackage[nottoc]{tocbibind}
\usepackage{tocloft}
\usepackage{times, newtxmath}
\usepackage{cite}
\usepackage[colorlinks=true,linkcolor=Blue,urlcolor=Blue,citecolor=Blue]{hyperref}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[toc]{blindtext} %for demonstrating purposes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\titleformat{\chapter}[display]
{}{}{1ex}{\bfseries\fontsize{15}{16}\selectfont}[]
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}} % for chapters
\newpagestyle{myps}{%
\sethead[][\thepage\enspace\dotfill\enspace Title 2][]{}{Title 1\enspace\dotfill\enspace\thepage}{}
\setfoot{}{}{}
}%
\begin{document}
\pagenumbering{alph}
\tableofcontents
\cleardoublepage
\pagestyle{myps}
\pagenumbering{arabic}
\chapter{A First Chapter}
\Blindtext[5][2]
\chapter{A Second Chapter}
\Blindtext[2][5]
\end{document}
答案2
如果我理解了你的问题,以下是一个基本的答案:
\documentclass[11pt,a5paper,twoside]{report}
\usepackage{lipsum}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage[top=25mm, bottom=25mm, left=20mm, right=20mm]{geometry}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{framed}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{indentfirst}
\usepackage{emptypage}
\usepackage{titlesec}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[colorlinks=true,linkcolor=Blue,urlcolor=Blue,citecolor=Blue] {hyperref}
\usepackage{algorithm,algcompatible}
\usepackage[textfont={small},labelfont= {rm,small},format=hang,labelsep=quad,justification= {centering},aboveskip=1pt,belowskip=1pt]{caption}
\usepackage{subcaption}
\usepackage[nottoc]{tocbibind}
\usepackage{tocloft}
\usepackage{times}
\usepackage{cite}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\fancyhf{}
\fancyhead[LO]{\small \leftmark \ \hrulefill\ \thepage}
\fancyhead[RE]{\small \thepage \ \hrulefill\ \rightmark}
\fancypagestyle{plain}{%
\fancyhead{}
}
\renewcommand{\headrulewidth}{0pt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\titleformat{\chapter}[display]
{}{}{1ex}{\bfseries\fontsize{15}{16}\selectfont}[]
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}} % for chapters
\begin{document}
\pagenumbering{alph}
\tableofcontents
\cleardoublepage
%\pagestyle{plain}
\pagenumbering{arabic}
\lipsum[3-56]
\end{document}
您可以使用\dotfill
命令代替\hrulefill
虚线标题。