0

Putting page numbering top center, some pages keep page numbering bottom center This happens only on the pages, that contain some kind of chapter/section/subsection header on top(I don't really know how properly name it). The issue is depicted on the following image:

Issue image

There's page numbering located at bottom center on the TOC page as well as on the introduction page. The same is when I start the chapter. However, when page doesn't contain chapter/section/subsection on the top, everything is fine. I've encountered this for the first time, being pretty new to latex, I have no idea what's wrong.

My preamble with all the packages and settings is messy, but seems the following code is exactly about page numbering and chapter/section/subsection modifications:

\pagestyle{myheadings}
\makeatletter
\renewcommand{\@oddfoot}{}
\renewcommand{\@oddhead}{\hfil\thepage\hfil}
\makeatother
\usepackage{titlesec}

\newcommand{\chapfnt}{\fontsize{16}{19}}
\newcommand{\secfnt}{\fontsize{14}{17}}
\newcommand{\ssecfnt}{\fontsize{14}{14}}

\titleformat{\chapter}%[display]
{\normalfont\chapfnt\bfseries\filcenter}{\thechapter}{24pt}{\chapfnt}

\titleformat{\section}
{\normalfont\bfseries\filcenter}{\thesection}{1em}{}
\titleformat{\subsection}
{\normalfont\bfseries\filcenter}{\thesubsection}{1em}{}

\titlespacing*{\chapter} {0pt}{50pt}{40pt}
\titlespacing*{\section} {0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\titlespacing*{\subsection} {0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

Can anyone help me with this issue? Thanks!

17
  • Hello, this is unfortunately not a full MWE which can be compiled as it is missing integral preamble information (e.g. \documentclass{} and other loaded packages). I notice however, that you only seem to modify the header of odd pages, which may be part of the problem. Furthermore, the start-pages of chapters by default use a different style, and this may have to be changed specifically in your case. In general, I would suggest using dedicated packages for all this, like fancyhdr or scrlayer-scrpage (especially if you are using a KOMA class). Jun 21, 2021 at 9:38
  • @ManuelWeinkauf, thank you for the reply! I was using fancyhdr but the numbers were too small and the issue hasn't been resolved. I added evenhead, but the problem persists, though even pages has been modified even before adding this. Can you shred some light on how to modify start-pages of chapters/section/subsections? It seems to be the way to resolve my issue, though maybe not the laconic way. Jun 21, 2021 at 9:54
  • 1
    Maybe try redefining the plain page style with fancyhdr: on the first page of a chapter, it is this page style which is applied, and it puts the page number centred in the footer.
    – Bernard
    Jun 21, 2021 at 10:41
  • If you have an issue with font sizes in fancyhdr, maybe check this thread Jun 21, 2021 at 11:07
  • @Bernard, thank you for the answer! Could you please elaborate on how to do this? I feel like this gonna help, but simply putting \pagestyle{plain} near e.g. TOC didn't help :( Jun 21, 2021 at 11:40

1 Answer 1

1

With help of @ManuelWeinkauf and @Bernard, the issue has been resolved via adding this lines to preamble:

\newcommand{\changefont}{%
\fontsize{14}{16}\selectfont
}

\usepackage{fancyhdr}
\fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
\fancyhead[C]{\changefont\thepage} % except the center
}

With only fancy settings, the problem became "upside-down" version: ordinary pages had page numbers at the bottom while start-pages of chapters had page numbers at the top. Using both fancy and settings mentioned in the question, the problem has been solved!

UPD: Another way to solve the problem without reinventing the wheel is to add the next line to preamble:

\AtBeginDocument{\renewpagestyle{plain}{\sethead{}{\thepage}{}}}

You must log in to answer this question.

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