Page numbers show correctly up in the table of contents, but not on the pages. How can I make LaTex display them on the pages in the document?
I have tried changing the documentclass from report to article and adding the hyperref package.
\documentclass[12pt]{report}
\usepackage[top=1in, bottom=1in, left=1in, right=1in]{geometry}
\usepackage{setspace}
\usepackage{hyperref}
\usepackage[usenames, dvipsnames]{color}
\usepackage{titling}
\usepackage{mathtools}
\usepackage{times}
\usepackage{graphicx}
\usepackage{amsfonts}
\usepackage{booktabs}
\usepackage{hyperref}
\setlength{\droptitle}{-5em}
\setlength{\parindent}{1cm}
\renewcommand{\thesection}{\arabic{section}}
\begin{document}
\thispagestyle{empty}
\newpage
\tableofcontents
\thispagestyle{empty}
\newpage
\doublespacing
\setcounter{page}{1}
I do get page numbers in this minimal example, both for documentclass article as report:
\documentclass{report}
% \documentclass{article}
\begin{document}
\tableofcontents
\section{one}
\newpage
\section{two}
\newpage
\section{three}
\newpage
\end{document}
You may not get a page number because you explicitly say so using \thispagestyle{empty}. Report may also define the first page (of a chapter) as a page without regular head and foot, and hence also without number.
Hyperref has nothing to do with (printed) page numbers.
Related
In my table of contents, the abstract and the table of contents have the same page number. The numbering of the summary is correct as II, but the table of contents must be III. However, I don't understand where the error is or why Overleaf doesn't recognize that my table of contents continues at III. Can someone please give me some advice?
Attached you can see a picture of how it looks.
Here is my code snippet
\documentclass{scrbook}
\usepackage{blindtext}
\usepackage{scrhack}
\begin{document}
\frontmatter
\tableofcontents
\addcontentsline{toc}{chapter}{Abstract}
\input{02_abstract}
\renewcommand{\contentsname}{Table of Contents}
\addcontentsline{toc}{chapter}{Table of Contents}
\tableofcontents
\mainmatter
\Blinddocument
\backmatter
\Blinddocument
\end{document}
Add \newpage in between Abstract block.
\newpage
\addcontentsline{toc}{chapter}{Abstract}
\input{02_abstract}
\newpage
I added a page header with the following command in LaTeX:
\pagestyle{fancy} \fancyhead[L]{\rightmark} \fancyhead[R]{\leftmark}
Here is a minimal reproducible example:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\title{Titlepage}
\date{October 2021}
\pagestyle{fancy} \fancyhead[L]{\rightmark} \fancyhead[R]{\leftmark}
\usepackage{graphicx}
\usepackage{titlesec}
\usepackage{lipsum} %just to generate text for the example
\newcommand*\HUGE{\Huge}
\newcommand*\chapnamefont{\normalfont\LARGE\MakeUppercase CHAPTER}
\newcommand*\chapnumfont{\normalfont\HUGE}
\newcommand*\chaptitlefont{\normalfont\HUGE\bfseries}
\newlength\beforechapskip
\newlength\midchapskip
\setlength\midchapskip{\paperwidth}
\addtolength\midchapskip{-\textwidth}
\addtolength\midchapskip{-\oddsidemargin}
\addtolength\midchapskip{-1in}
\setlength\beforechapskip{18mm}
\titleformat{\section}[display]
{\normalfont\filleft}
{{\chapnamefont}%
\makebox[0pt][l]{\hspace{.8em}%
\resizebox{!}{\beforechapskip}{\chapnumfont\thesection}%
\hspace{.8em}%
\rule{\midchapskip}{\beforechapskip}%
}%
}%
{25pt}
{\chaptitlefont}
\titlespacing*{\section}
{0pt}{40pt}{40pt}
\begin{document}
\maketitle
\newpage
blank page
\newpage
\section{Introduction}
the page header should not be visible here
\newpage
\subsection{Test2}
only the section should be visible in the page header (1 INTODUCTION)
\newpage
only the subsection should be visible in the page header (1.1 Test2)
\end{document}
With this command there is the problem that it appears on all pages, but for my thesis I would like to remove it from pages where the section shows up for the first time
here is an example how it currently looks:
this is how it should look like, when the section appears for the first time:
Also I would like the header to adapt, according to which side it is on (even or odd). For example I would want to have on the left page the section name only (even page) and on the right side the subsection name should show up (odd page):
I would use another documentclass. This would automatically solve most of your problems:
in report or book class, the first pages of a chapter automatically use another page style without the header
if you use a two-sided document, you can define the fancyhead depending on E(ven) or O(dd) pages
\documentclass[twoside]{report}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\title{Titlepage}
\date{October 2021}
\pagestyle{fancy}
\fancyhead{}
\fancyhead[LE]{\leftmark}
\fancyhead[RO]{\rightmark}
\usepackage{graphicx}
\usepackage{titlesec}
\usepackage{lipsum} %just to generate text for the example
\newcommand*\HUGE{\Huge}
\newcommand*\chapnamefont{\normalfont\LARGE\MakeUppercase CHAPTER}
\newcommand*\chapnumfont{\normalfont\HUGE}
\newcommand*\chaptitlefont{\normalfont\HUGE\bfseries}
\newlength\beforechapskip
\newlength\midchapskip
\setlength\midchapskip{\paperwidth}
\addtolength\midchapskip{-\textwidth}
\addtolength\midchapskip{-\oddsidemargin}
\addtolength\midchapskip{-1in}
\setlength\beforechapskip{18mm}
\titleformat{\chapter}[display]
{\normalfont\filleft}
{{\chapnamefont}%
\makebox[0pt][l]{\hspace{.8em}%
\resizebox{!}{\beforechapskip}{\chapnumfont\thechapter}%
\hspace{.8em}%
\rule{\midchapskip}{\beforechapskip}%
}%
}%
{25pt}
{\chaptitlefont}
\titlespacing*{\chapter}
{0pt}{40pt}{40pt}
\begin{document}
\maketitle
\newpage
blank page
\newpage
\chapter{Introduction}
the page header should not be visible here
\newpage
\section{Test2}
only the section should be visible in the page header (1 INTODUCTION)
\newpage
only the subsection should be visible in the page header (1.1 Test2)
\end{document}
I'm using the report class, and I have a table of contents that I would like to start with the introduction. However I'd also like the List of Figures to come after the contents, but not be included in the contents itself.
However at the moment the contents looks like this:
Contents
List of Figures vi
1 Introduction 1
I'd like to still have the LoF after the contents, but I just want it to not appear in the ToC, is this possible?
\documentclass[a4paper, 9pt]{report}
\usepackage{graphicx}
\usepackage[margin=1.0in]{geometry}
\usepackage{sectsty}
\usepackage{url}
\usepackage{hyperref}
\usepackage{listings}
\usepackage{fancyvrb}
\usepackage{pdfpages}
\usepackage{longtable}
\usepackage[utf8]{inputenc} % Required for inputting international characters
\usepackage[T1]{fontenc} % Output font encoding for international characters
\usepackage{mathpazo} % Palatino font
\usepackage[nottoc,numbib]{tocbibind}
\renewcommand{\bibname}{References}
\chapternumberfont{\Large}
\chaptertitlefont{\huge}
\graphicspath{ {images/} }
\lstset{
basicstyle=\small\ttfamily,
columns=flexible,
breaklines=true
}
\hypersetup{
colorlinks,
citecolor=black,
filecolor=black,
linkcolor=black,
urlcolor=black
}
\begin{document}
\pagenumbering{roman}
\begin{titlepage}
\end{titlepage}
\chapter*{Authorship Declaration}
\chapter*{Acknowledgements}
\chapter*{Abstract}
\tableofcontents
\listoffigures
\chapter{Introduction}
It seems that the use of asterisk just after \listoffigures (or \newpage if you are using it) removes the list of figures from the table of contents. Of course the same is valid for the list of tables.
At least it worked for me.
I would like to have a table of content with numbering identical to the ones in text. So, in text each section/subsection/subsubsection is numerated as '1.' or '1.1.' or '1.1.1.'. However my table of content is not updating it, so it shows '1' or '1.1'.
I was following answer to this topic: https://superuser.com/questions/811779/how-to-add-a-dot-for-section-subsection-numbering-in-tex
So I am using 'secdot' package. I have tried using
\renewcommand{\thechapter}{\arabic{chapter}.}
\renewcommand{\thesection}{\thechapter\arabic{section}.}
but I keep getting '\the chapter undefined', 'No counter chapter defined' or 'Missing number, treated as zero' errors.
I would appreciate any tips on what's wrong.
EDIT:
\documentclass[11pt, a4paper, twoside]{article}
\usepackage{listings, lstautogobble}
\usepackage{ragged2e}
\usepackage{times}
\usepackage{secdot}
\sectiondot{subsection}
\usepackage{listings}
\usepackage[toc,page]{appendix}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\geometry{a4paper,
left=30mm,
top=25mm,
bottom=25mm,
right=20mm
}
\sectiondot{subsection}
\makenomenclature
\setlength{\parindent}{0.5 cm}
\renewcommand{\baselinestretch}{1.15}
\pagenumbering{roman}
\begin{document}
\setboolean{#twoside}{false}
\begin{figure}[H]
\begin{center}
\includegraphics[width=14cm,height=15cm,keepaspectratio]{./thesis- frontpagedesign}
\end{center}
\end{figure}
\begin{center}
\tableofcontents
\end{center}
\begin{center}
\listoffigures
\end{center}
\section{Introduction}
%sometext
\makeatletter
\def\#seccntformat#1{%
\expandafter\ifx\csname c##1\endcsname\c#section\else
\csname the#1\endcsname\quad
\fi}
\makeatother
\end{document}
Your current setup is confusing. For example,
\makeatletter
\def\#seccntformat#1{%
\expandafter\ifx\csname c##1\endcsname\c#section\else
\csname the#1\endcsname\quad
\fi}
\makeatother
removes the setting of any \section number. And mixing this with the use of secdot seems problematic.
The easiest way to achieve dots after sectional unit numbers within your text as well as the ToC is to adjust the representation of the respective counters:
\documentclass{article}
\renewcommand{\thesection}{\arabic{section}.}
\renewcommand{\thesubsection}{\thesection\arabic{subsection}.}
\renewcommand{\thesubsubsection}{\thesubsection\arabic{subsubsection}.}
\begin{document}
\tableofcontents
\section{Introduction}
\end{document}
This solution is sufficient, but will also affect \references. For example \ref{sec:introduction} would return 1. which may look odd in the middle of a sentence: ... from section~\ref{sec:introduction} we can see ....
If you don't want periods ending your \references, you can use
\usepackage{secdot}% Adds . after sectional unit numbers
\usepackage{etoolbox}
% \patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
\patchcmd{\numberline}{\hfil}{.\hfil}{}{}
You're already familiar with what secdot does. The patch to \numberline is thanks to etoolbox which changes the default definition
\def\numberline#1{\hb#xt#\#tempdima{#1\hfil}}
into
\def\numberline#1{\hb#xt#\#tempdima{#1.\hfil}}
effectively inserting an ending-period as part of the number that is printed within the ToC. Note that this will also affect how figures/tables are displayed within the LoF/LoT. However, one can change that using scoping:
\begingroup
% The following patch will only affect entries in the ToC
\patchcmd{\numberline}{\hfil}{.\hfil}{}{}
\tableofcontents
\endgroup
\listoffigures
\listoftables
I am writing my thesis in Latex, document class: report. I have got front matter containing of abstract, acknowledgement and so on.
I want to add header only to my main matter which starts with my first chapter:Introduction. I want the header to be the chapter number without the word "chapter" and the chapter title next to it. I also want the page number to appear in the centre on the bottom of the page in all pages of the main matter.
I don't want any header or line in any page of my front matter.
Can you please guide me? Thanks
Here it is the sample code that I am applying.
\documentclass[a4paper,12pt,titlepage]{report}
\usepackage{amsfonts}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{color}
\usepackage{colordvi}
\usepackage{amssymb}
\usepackage{natbib}
\usepackage[nottoc,notlot,notlof]{tocbibind}
\usepackage{setspace}
\usepackage{amsmath}
\usepackage{theorem}
\usepackage{lineno}
\usepackage{multirow}
\usepackage [toc,page]{appendix}
\usepackage{framed}
\usepackage{setspace}
\doublespacing
\usepackage[left=1.5in,top=2in,right=1in,bottom=2in]{geometry}
\begin{document}
\title{xxx}
\author{xxx}
\date{xxx}
\maketitle
\thispagestyle{empty}
\renewcommand{\thepage}{\roman{page}}
% here it comes my front matter for example:
\clearpage
\addcontentsline{toc}{chapter}{Abstract}
\chapter*{Abstract}
ABSTRACT CONTENTS
%then:
\clearpage
\cleardoublepage
\pagenumbering{arabic}
% here it starts my main matter:
\chapter{Introduction} %first chapter
\chapter{First Esssay in XXX} %second chapter
\end{document}
You have a number of options to set headers in a document. The most frequently-used package is fancyhdr.
First of all, you need to remove the word Chapter from the regular chapter mark. For this, add
\usepackage{etoolbox}
\makeatletter
%\newcommand{\updatechaptermark}{%
\appto\ps#fancy{%
\patchcmd{\chaptermark}% <cmd>
{\#chapapp\ }{}% <search><replace>
{}{}% <success><failure>
}%}
\makeatother
to your preamble. The above strips out \#chapapp\ (note the space) from \chaptermark as part of the call to \pagestyle{fancy}. That's required as fancyhdr may update \chaptermark upon calling \pagestyle{fancy}.
Second, you need to set the headers/footers. Here's a setting that yields what you're after:
\usepackage{fancyhdr}
\fancyhf{}% Clear header/footer
\fancyhead[C]{\leftmark}% Chapter mark
\fancyfoot[C]{\thepage}% Footer contains the page number
\renewcommand{\headrulewidth}{.4pt}% Header rule width
The above sets the header as \leftmark, which contains the \chaptermark setting (since \chaptermark actually issues \markboth{<leftmark>}{<rightmark>} with an empty <rightmark>).
\documentclass{report}
\usepackage{fancyhdr,lipsum}
\usepackage{etoolbox}
\makeatletter
%\newcommand{\updatechaptermark}{%
\appto\ps#fancy{%
\patchcmd{\chaptermark}% <cmd>
{\#chapapp\ }{}% <search><replace>
{}{}% <success><failure>
}%}
\makeatother
\fancyhf{}% Clear header/footer
\fancyhead[C]{\leftmark}
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{.4pt}
\begin{document}
%\frontmatter
\pagenumbering{roman}
\title{xxx}
\author{xxx}
\date{xxx}
\maketitle
\thispagestyle{empty}
% here it comes my front matter for example:
\cleardoublepage
\tableofcontents
\cleardoublepage
\addcontentsline{toc}{chapter}{Abstract}%
\chapter*{Abstract} \lipsum[1]
\cleardoublepage
\pagenumbering{arabic}
\pagestyle{fancy}
\chapter{Introduction} \lipsum[1-50] % first chapter
\chapter{Methodology} \lipsum[1-50] % second chapter
\chapter{Conclusion} \lipsum[1-50] % last chapter
\end{document}
Note that \chapters are set by default using the plain style. If you wish this to be different, you'll have to redefine the plain page style.
You can achieve the same output using a different header/footer package like titleps.