我正在尝试编写一个report
类文档,我在目录中对各节进行编号,但无法打印,也无法隐藏或删除“章节”一词,例如,我的代码是:
\documentclass[letter,titlepage,doublesided]{report}
\usepackage{xcolor}
\usepackage{hyperref}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage[margin=0.6in,bottom=0.8in, top=0.8in]{geometry}
\usepackage{titlesec}
\usepackage{url}
\usepackage{tikz}
\usepackage{fix-cm}
\usepackage{graphicx}
\usepackage{pbox}
\usepackage{titletoc}
\newcommand\mybox[2][]{\tikz[overlay]\node[fill=blue!20,inner sep=2pt, anchor=text, rectangle, rounded corners=1mm,#1] {#2};\phantom{#2}}
\title{REPORT}
\author{\includegraphics[width=0.1\textwidth]{logo.png}}
\date{Revision 5}
\pagestyle{fancy}
\lhead{\large{\bf{\it{xxx}}}}
\chead{}
\rhead{\large{\bf{\it{xxx}}}}
\lfoot{\small\it{{xxx}}}
\cfoot{\small\it{{xxx}}}
\rfoot{\small\it{Page \thepage{} of \pageref{LastPage}}}
\renewcommand{\headrulewidth}{0.3pt}
\renewcommand{\footrulewidth}{0.4pt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Colored Section Headings %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\colorsection}[1]{%
\colorbox{blue!20}{\parbox{\dimexpr\textwidth-2\fboxsep}{\thesection\ #1}}}
\newcommand{\colorsubsection}[1]{%
\colorbox{gray!20}{\parbox{\dimexpr\textwidth-2\fboxsep}{\thesubsection\ #1}}}
\titleformat{\section}[block]
{\sffamily\huge}
{}
{0pt}
{\colorsection}
\titlespacing*{\section}{0pt}{\baselineskip}{\baselineskip}
\titleformat{\subsection}[block]
{\sffamily\Large}
{}
{0pt}
{\colorsubsection}
\titlespacing*{\subsection}{0pt}{\baselineskip}{\baselineskip}
\titleformat{\subsubsection}[block]
{\sffamily\large}
{}
{0pt}
{\colorsubsection}
\titlespacing*{\subsubsection}{0pt}{\baselineskip}{\baselineskip}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% / Colored Section Headings %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\hdr}[1]{{\bf\huge{#1}}}
\begin{document}
\centering\Huge{REPORT}
\vspace{5em}
\cleardoublepage
\tableofcontents
\chapter{Scope}
![enter image description here][1]
\section{test}
text!
\end{document}
我无法上传图片,但在第 2、3 页中。我无法看到第 1 页中的页眉和页脚。我想删除第 3 页中的单词章节。
答案1
您是否想将页码放在标题页/目录页中?我建议您不要这样做。但如果这确实是您想要的,那么请将此行添加到您的序言中。
% For the desired chapter heading formatting
\titleformat{\chapter}
{\normalfont\Huge\bfseries}
{\thechapter} {0.5em} {\thispagestyle{myfancypage}} %Remove \thispagestyle{myfancypage} if you don't want the fancy headers to appear in your chapter page and table of contents page
myfancypage
设置为
\fancypagestyle{myfancypage}{
\fancyhf{}
\lhead{\large{\textbf{\textit{xxx}}}}
\chead{}
\rhead{\large\textbf{\textit{xxx}}}
\lfoot{\small\textit{xxx}}
\cfoot{\small\textit{xxx}}
\rfoot{\small\textit{Page \thepage{} of \pageref{LastPage}}}}
参考
- 正如 kahen 在他的回答中提到的,不要使用
\bf
和\it
在 LaTeX 文档中我使用 \textit 或 \it、\bfseries 或 \bf 等有关系吗。 要将标题页和目录页放在同一页,请考虑相关文章:如何在同一页面和目录中显示 \listoffigures 和 \listoftables?可以根据你的情况进行设置
\begingroup \let\clearpage\relax \tableofcontents \endgroup
我还删除了代码中的一些重复行并添加了
\newpage
text!
为了显示myfancypage
完整修订版守则
\documentclass[letter,titlepage,twoside]{report}
\usepackage{xcolor}
\usepackage{hyperref}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage[margin=0.6in,bottom=0.8in, top=0.8in]{geometry}
\usepackage{titlesec}
\usepackage{url}
\usepackage{tikz}
\usepackage{fix-cm}
\usepackage{graphicx}
\usepackage{pbox}
\usepackage{titletoc}
\newcommand\mybox[2][]{\tikz[overlay]\node[fill=blue!20,inner sep=2pt, anchor=text, rectangle, rounded corners=1mm,#1] {#2};\phantom{#2}}
\title{REPORT}
\author{\includegraphics[width=0.1\textwidth]{logo.png}}
\date{Revision 5}
\fancypagestyle{myfancypage}{
\fancyhf{}
\lhead{\large{\textbf{\textit{xxx}}}}
\chead{}
\rhead{\large\textbf{\textit{xxx}}}
\lfoot{\small\textit{xxx}}
\cfoot{\small\textit{xxx}}
\rfoot{\small\textit{Page \thepage{} of \pageref{LastPage}}}}
\renewcommand{\headrulewidth}{0.3pt}
\renewcommand{\footrulewidth}{0.4pt}
% For the desired chapter formatting
\titleformat{\chapter}
{\normalfont\Huge\bfseries}
{\thechapter} {0.5em} {\thispagestyle{myfancypage}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Colored Section Headings %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\colorsection}[1]{%
\colorbox{blue!20}{\parbox{\dimexpr\textwidth-2\fboxsep}{\thesection\ #1}}}
\newcommand{\colorsubsection}[1]{%
\colorbox{gray!20}{\parbox{\dimexpr\textwidth-2\fboxsep}{\thesubsection\ #1}}}
\titleformat{\section}[block]
{\sffamily\huge}
{}
{0pt}
{\colorsection}
\titlespacing*{\section}{0pt}{\baselineskip}{\baselineskip}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% / Colored Section Headings %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\hdr}[1]{{\bfseries\huge{#1}}}
\begin{document}
\begin{center}
\Huge{REPORT}
\end{center}
%\vspace{5em}
%\cleardoublepage
\begingroup
\let\clearpage\relax
\tableofcontents
\endgroup
%\tableofcontents
\pagestyle{myfancypage}
\chapter{Scope}
![enter image description here][1]
\section{test}
text!
\newpage
text!
\end{document}
答案2
- 您的问题是将
\pagestyle{fancy}
当前页面样式设置为,fancy
并且所有后续页面样式修改都将应用于fancy
,而不会影响其他内容。但\chapter
默认情况下会发出\thispagestyle{plain}
。您可以做的是重新定义plain
样式。 \large{\bf{\it{xxx}}
并没有像您想象的那样工作。这应该写为{\large\bfseries\itshape xxx}
或{\large \textbf{\textit{xxx}}}
。- 你的例子太长了,而且充斥着不相关的内容。这是如何使用的问题
fancyhdr
。代码转储中的其他内容都只是噪音。http://www.minimalbeispiel.de/mini-en.html