0

I've decided to use Latex for my thesis.
I need to follow some style directions such as having the page number on the upper right side, starting to print the numbers only from the second page of TOC and beyond. Before that page the counter goes on but shouldn't print anything.

When I tried to do it with regular Latex commands I faced problems and decided to try fancyhdr, but the problem is the same:

\RequirePackage{luatex85}
\documentclass[11pt,a4paper, twoside, spanish]{book}
\usepackage[left=3.5cm, right=3.4cm, top=4.7cm, bottom=4.1cm]{geometry} 
\usepackage{indentfirst}
\usepackage[skip=12pt, indent=2em]{parskip}   
\usepackage{fontspec}
\setmainfont{TeXGyrePagellaX}
\usepackage{float}
\usepackage[section]{placeins}   
\usepackage[capitalise,noabbrev]{cleveref}  
\usepackage[bottom,hang, flushmargin]{footmisc}
\renewcommand{\footnotelayout}{\setstretch{1.2}}
\setlength{\footnotemargin}{5mm}
\usepackage{chngcntr}  
\counterwithout{footnote}{chapter}
\usepackage{appendix}
\counterwithin*{chapter}{part}
\renewcommand{\restoreapp}{} 
\usepackage{polyglossia}    
\setmainlanguage{spanish}
\title{''VERY LONG TITLE''}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}  
\fancyhead[RE]{\thepage}
\fancyhead[RO]{\thepage}  
\usepackage{blindtext}

\begin{document}
\begin{titlepage}
         THIS is a THESIS
        \vspace{1cm}
        \large FACULTAD EN CIENCIAS DE LA SALUD,\\
        \vspace{2cm}
        \LARGE ``LONG TITLEEEEEEEEEEEEEEEEEEEEEE.''\\
        \tiny
        \vspace{1cm}
        \Large Autor: \\        
        \Large MR. X\\
\end{titlepage}

\newpage

\chapter*{}
\begin{flushright}
    \textit{Dedicado a mi familia}
\end{flushright}

\chapter*{Abstract}
\blindtext[1]

\tableofcontents
\cleardoublepage
\listoffigures 
\cleardoublepage
\listoftables 

\chapter{Introducción}
\blindtext[1]
\section{Cosas interesantes}
\blindtext[1]
\subsection{Ámbito del estudio} 
\blindtext[1]
\chapter{Discusión}
\blindtext[1]
\begin{appendices} 
\chapter{Resumen procesos de limpieza y transformación de los datos}    
\blindtext[1]
\chapter{Código fuente}
\blindtext[1]    
\chapter{Artículo científico asociado a la tesis}
\blindtext[1]
\end{appendices}
\blindtext[1]
\end{document}

Some page numbers appear on the header, some other on the footer, I don't know why.

enter image description here

I've also tried with local modifiers such as \thispagestyle{empty} but if the text of that section is long it seems to only affect the first page of that section.

6
  • This is because on pages with chapter titles, the page style is the plain style. If want page numbers also in the right header for these pages, you have to redefine the plain style. Do you want also want head rules on these pages?
    – Bernard
    Jul 28, 2019 at 12:04
  • I would like to have the number from the second page of the TOC and beyond. The head rules aren't important for me, the easier solution would be right, or the solution you suggest.
    – skan
    Jul 28, 2019 at 14:59
  • Your suggestion led to try \fancypagestyle{plain}{% \fancyhf{} \fancyhead[RE]{\thepage} \fancyhead[RO]{\thepage} \renewcommand{\headrulewidth}{0pt}} . Now the numbers are OK but the head rules still appear on odd pages.
    – skan
    Jul 28, 2019 at 15:08
  • I've also tried to redefine the empy and plain styles but then the compilation lasts forever and crashes. The problem may be related with scyntex.
    – skan
    Jul 28, 2019 at 15:25
  • I have a simple solution, with no headrules at all. I'll try to see if an easier solution can be found with titleps to have headrules, except on the first page of chapters.
    – Bernard
    Jul 28, 2019 at 16:25

1 Answer 1

1

Here is a solution with titleps: I redefine the plain style as the empty style if a boolean all plain is false, and as a style with the page number on the top right corner of the page, and I define a ruledplain style, which adds a head rule. In addition, I load the emptypage package, which removes all footers and headers from empty pages.

\RequirePackage{luatex85}
\documentclass[11pt, a4paper, twoside, spanish]{book}
\usepackage[left=3.5cm, right=3.4cm, top=4.7cm, bottom=4.1cm]{geometry}
\usepackage{indentfirst}
\usepackage[skip=12pt, indent=2em]{parskip}
\usepackage{fontspec}
\setmainfont{TeXGyrePagellaX}
\usepackage{float}
\usepackage[section]{placeins}
\usepackage[capitalise,noabbrev]{cleveref}
\usepackage[bottom,hang, flushmargin]{footmisc}
\renewcommand{\footnotelayout}{\setstretch{1.2}}
\setlength{\footnotemargin}{5mm}
\counterwithout{footnote}{chapter}
\usepackage{appendix}
\counterwithin*{chapter}{part}
\renewcommand{\restoreapp}{}
\usepackage{polyglossia}
\setmainlanguage{spanish}
\title{''VERY LONG TITLE''}

\usepackage{etoolbox}
\newbool{allplain}

\usepackage{titleps}
\renewpagestyle{plain}{%
\ifbool{allplain}{\sethead{}{}{\thepage}{}}{}%
}%
\newpagestyle{ruledplain}{%
\headrule
\sethead{}{}{\thepage}}%
\usepackage{blindtext}
\usepackage{lipsum}
\usepackage{emptypage}

\begin{document}

\pagestyle{plain}
\begin{titlepage}
         THIS is a THESIS
        \vspace{1cm}
        \large FACULTAD EN CIENCIAS DE LA SALUD,\\
        \vspace{2cm}
        \LARGE ``LONG TITLEEEEEEEEEEEEEEEEEEEEEE.''\\
        \tiny
        \vspace{1cm}
        \Large Autor: \\
        \Large MR. X\\
\end{titlepage}

\newpage

\chapter*{}
\begin{flushright}
    \textit{Dedicado a mi familia}
\end{flushright}
\lipsum

\chapter*{Abstract}
\blindtext[1]
\tableofcontents
\setbool{allplain}{true}
\pagestyle{ruledplain}
\cleardoublepage
\listoffigures
\cleardoublepage
\listoftables

\chapter{Introducción}
\blindtext[1]
\section{Cosas interesantes}
\blindtext[1]
\subsection{Ámbito del estudio}
\blindtext[1]
\chapter{Discusión}
\blindtext[1]
\begin{appendices}
\chapter{Resumen procesos de limpieza y transformación de los datos}
\blindtext[1]
\chapter{Código fuente}
%\blindtext
\lipsum[1-10]
\chapter{Artículo científico asociado a la tesis}
\blindtext[1]
\end{appendices}
\blindtext[1]

\end{document} 
6
  • Great. It would be nice to get this things done just with LaTex. Now it works. The numbering has been removed from all blank pages and the Abstract and Title pages. And the numbering starts from the third page of my TOC (which has 3 pages). How can I force it to start at the second TOC page? It's a ridiculuos style specification of my university but I have to do it.
    – skan
    Jul 28, 2019 at 18:10
  • Mmmmm… For me, it starts at the second page of the toc. Could you post a minimal code reproducing the problem?
    – Bernard
    Jul 28, 2019 at 18:29
  • OK, just add \setcounter{secnumdepth}{3} \setcounter{tocdepth}{4} and many new sections or subsections in order to get a 3 pages TOC. Or maybe I can just start the numbering after the TOC.
    – skan
    Jul 28, 2019 at 18:51
  • No problem whatsoever.
    – Bernard
    Jul 28, 2019 at 19:00
  • How can I remove the header rule or the number on a single page? For example I have several sidewaystables (floats) taking up a whole page (they exact placement is not decided by me, it's automatic).
    – skan
    Jul 28, 2019 at 19:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .