0

I'm writing my thesis using documentclass book. I want to change the header and footer of pages and modify slightly the size and position of chapter.

Now it looks more or less like this: enter image description here But I want something like this: enter image description here

So what I want is:

  1. Page numbers always centered at the bottom of pages
  2. Headers in lowercase
  3. Chapter number aligned to the left, not in bold and larger
  4. Chapter title right aligned, in bold and size as it is now.

This is my preamble:

\documentclass[a4paper, 11pt, titlepage]{book}

\usepackage[italian]{babel}
\usepackage{courier}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[nouppercase, swapnames]{frontespizio}
\usepackage[hidelinks]{hyperref} 
\usepackage{alltt}
\usepackage{cancel}
\usepackage{textcomp}
\usepackage{float}
\restylefloat{table}

\usepackage{titlesec}
\titleclass{\subsubsubsection}{straight}[\subsection]
\newcounter{subsubsubsection}[subsubsection]
\renewcommand\thesubsubsubsection{\thesubsubsection.\arabic{subsubsubsection}}
\renewcommand\theparagraph{\thesubsubsubsection.\arabic{paragraph}} % optional; useful if paragraphs are to be numbered

\titleformat{\subsubsubsection}
  {\normalfont\normalsize\bfseries}{\thesubsubsubsection}{1em}{}
\titlespacing*{\subsubsubsection}
{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{5}{\z@}%
  {3.25ex \@plus1ex \@minus.2ex}%
  {-1em}%
  {\normalfont\normalsize\bfseries}}
\renewcommand\subparagraph{\@startsection{subparagraph}{6}{\parindent}%
  {3.25ex \@plus1ex \@minus .2ex}%
  {-1em}%
  {\normalfont\normalsize\bfseries}}
\def\toclevel@subsubsubsection{4}
\def\toclevel@paragraph{5}
\def\toclevel@paragraph{6}
\def\l@subsubsubsection{\@dottedtocline{4}{7em}{4em}}
\def\l@paragraph{\@dottedtocline{5}{10em}{5em}}
\def\l@subparagraph{\@dottedtocline{6}{14em}{6em}}
\makeatother
\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{4}



\newsavebox{\RGbox}
\newcommand{\R}[1]{%
  \begingroup\setlength{\fboxsep}{0pt}%
  \sbox{\RGbox}{\colorbox{lightred}{\vphantom{fg}#1}}%
  \usebox{\RGbox}%
  \makebox[0pt][r]{\vrule width \wd\RGbox height .5ex depth -\dimexpr.5ex-0.4pt\relax}%
  \endgroup
}
\newcommand{\G}[1]{%
  \begingroup\setlength{\fboxsep}{0pt}%
  \sbox{\RGbox}{\colorbox{lightgreen}{\vphantom{fg}#1}}%
  \usebox{\RGbox}%
  \makebox[0pt][r]{\vrule width \wd\RGbox height -\dimexpr\dp\RGbox-0.4pt\relax depth \dp\RGbox}%
  \endgroup
}

\usepackage{amsmath} 
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}


\usepackage{listings} 
\usepackage{fancyvrb}
\usepackage{textcomp}
\usepackage{xcolor}
\definecolor{lightgray}{rgb}{.95,.95,.95}
\definecolor{darkgray}{rgb}{.4,.4,.4}
\definecolor{purple}{rgb}{0.65, 0.12, 0.82}
\definecolor{darkred}{rgb}{0.8, 0.0, 0.0}
\definecolor{darkgreen}{rgb}{0.13, 0.55, 0.13}
\colorlet{lightgreen}{green!30}
\colorlet{lightred}{red!30}
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}

\lstset{frame=tb,
  language=Python,
  aboveskip=3mm,
  belowskip=3mm,
  showstringspaces=false,
  columns=flexible,
  basicstyle={\small\ttfamily},
  numbers=left,
  numberstyle=\tiny\color{gray},
  keywordstyle=\color{blue},
  commentstyle=\color{dkgreen},
  stringstyle=\color{mauve},
  breaklines=true,
  breakatwhitespace=true,
  mathescape=<false>,
  tabsize=3
}

\lstnewenvironment{pseudocode}
  {\lstset{frame=tb,
  language=Python,
  aboveskip=3mm,
  belowskip=3mm,
  showstringspaces=false,
  columns=flexible,
  basicstyle={\small\ttfamily},
  numbers=left,
  numberstyle=\tiny\color{gray},
  keywordstyle=\color{blue},
  commentstyle=\color{dkgreen},
  stringstyle=\color{mauve},
  breaklines=true,
  breakatwhitespace=true,
  mathescape=<false>,
  tabsize=3
  }}
  {}
\lstnewenvironment{html}
  {\lstset{language=HTML,basicstyle={\ttfamily\small},frame=none, tabsize=3, numbers=none}}
  {}

\usepackage{booktabs} 
\usepackage{array} 
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\usepackage{graphicx} 
\usepackage{subfig}
\captionsetup[subfigure]{subrefformat=simple,labelformat=simple,listofformat=subsimple}
\renewcommand\thesubfigure{(\alph{subfigure})}
\usepackage{color} 
\usepackage{hyperref}

I know it's a little messed up.. Sorry.

I read that I have to use the package fancyhdr but I'm just starting out with latex. Someone would know help me?

Thank you!

  • there are alternatives to fancyhdr, for example scrlayer-scrpage. – Johannes_B Nov 18 '15 at 17:47
  • Or titletoc, since you use titlesec. – Bernard Nov 18 '15 at 17:52
  • @Bernard and how? I would not know where to start.. – lonely Nov 18 '15 at 18:14
1

Here is a solution with titlesec and titleps I translated you code for \(sub)paragraph in titlesec terms.

\documentclass[a4paper, italian, 11pt, titlepage]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{courier}
\usepackage{fourier, cabin}
\usepackage{babel}
\usepackage[nouppercase, swapnames]{frontespizio}

\usepackage[pagestyles]{titlesec}
\usepackage{microtype}
\SetTracking[no ligatures={f}]{encoding=*}{20}

 \titleformat{name=\chapter}[display]{\lsstyle}{\filright\Huge\chaptername\enspace \thechapter}{4ex}{\LARGE\bfseries\filleft}%
\titleformat{name=\chapter, numberless}[block]{\lsstyle}{}{0pt}{\bfseries\LARGE\filleft}

\titleclass{\subsubsubsection}{straight}[\subsection]
\newcounter{subsubsubsection}[subsubsection]
\renewcommand\thesubsubsubsection{\thesubsubsection.\arabic{subsubsubsection}}
\titleformat{\subsubsubsection}[hang]{\normalfont\normalsize\bfseries}{\thesubsubsubsection}{1em}{}
\titlespacing*{\subsubsubsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

\titleformat{\paragraph}[runin]{\normalfont\normalsize\bfseries}{\thesubsubsubsection.\arabic{paragraph}}{1em}{}
\titleformat{name=\paragraph, numberless}[runin]{\normalfont\normalsize\bfseries}{}{0em}{}
\titlespacing*{\paragraph}{0pt} {3.25ex \@plus1ex \@minus .2ex}{1em}

\titleformat{\subparagraph}[runin]{\normalfont\normalsize\bfseries}{\thesubsubsubsection.\arabic{paragraph}}{1em}{}
\titleformat{name=\subparagraph, numberless}[runin]{\normalfont\normalsize\bfseries}{}{0em}{}
\titlespacing*{\subparagraph}{\parindent} {3.25ex \@plus1ex \@minus .2ex}{1em}

\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{4}

\newpagestyle{mystyle}{%
\sethead[][][\sffamily\small\chaptertitle]{\sffamily\small\sectiontitle}{}{}
\setfoot{}{\sffamily\thepage}{}
\headrule
}
\pagestyle{mystyle}

\usepackage[hidelinks]{hyperref}

\usepackage{lipsum}

\begin{document}

\chapter{Titolo del primo capitolo}
\sffamily
\section{Una prima sezione}

\lipsum[1-12]

\end{document} 

enter image description here enter image description here enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.