4

I am trying to write a report class document, I numbering in the ToC for sections is not printing also how to hide or remove the word "chapter" for instance, my code is :

\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}

I am not able to upload a picture but in the page 2, 3. I am not able to see the header and footer as it is in the Page 1. I want to remove the word chapter in Page 3.

Werner
  • 603,163
Tej
  • 41
  • 2

2 Answers2

2

Are you attempting to put the page numbers in your title page/table of contents page? I would advise you not to. But if that is really what you want, then add this line to your preamble.

% 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 is set up as

\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}}}}

References

I have also deleted some repeated lines in your code and added

\newpage
text!

to illustrate myfancypage

The full revised code

\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}
hpesoj626
  • 17,282
1
  1. Your problem is that \pagestyle{fancy} sets the current page style to fancy and all subsequent page style modifications will apply to fancy and nothing else. But \chapter by default issues a \thispagestyle{plain}. What you could do is to redefine the plain style as well.
  2. \large{\bf{\it{xxx}} does not do what you think it does. This should be written as {\large\bfseries\itshape xxx} or as {\large \textbf{\textit{xxx}}}.
  3. Your example is far too long and filled with irrelevant stuff. This is an issue with how to use fancyhdr. Everything else in your code dump is just noise. http://www.minimalbeispiel.de/mini-en.html
kahen
  • 2,165