报表类中的页眉和页脚以及如何隐藏“章节”字样

报表类中的页眉和页脚以及如何隐藏“章节”字样

我正在尝试编写一个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}}}}

参考

我还删除了代码中的一些重复行并添加了

\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

  1. 您的问题是将\pagestyle{fancy}当前页面样式设置为,fancy并且所有后续页面样式修改都将应用于fancy,而不会影响其他内容。但\chapter默认情况下会发出\thispagestyle{plain}。您可以做的是重新定义plain样式。
  2. \large{\bf{\it{xxx}}并没有像您想象的那样工作。这应该写为{\large\bfseries\itshape xxx}{\large \textbf{\textit{xxx}}}
  3. 你的例子太长了,而且充斥着不相关的内容。这是如何使用的问题fancyhdr。代码转储中的其他内容都只是噪音。http://www.minimalbeispiel.de/mini-en.html

相关内容