2

I have the following problem:

\documentclass[a4paper]{book}

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{fancyhdr}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx} 
\usepackage{dsfont}
\usepackage{tikz}
\usepackage{braket}
\usepackage[figurename=Fig., font={footnotesize}]{caption}
\usepackage{float}
\usepackage{placeins}
\usepackage{epstopdf}
\usepackage[a4paper,left=40mm, right=40mm ,top=35mm,bottom=35mm]{geometry}
\usepackage{subfig}
\usepackage{tabularx}
\epstopdfsetup{outdir=./}
\usepackage{tikz-feynman, contour}
\usepackage[toc,title]{appendix}
\usepackage[nottoc]{tocbibind}
\usepackage[parfill]{parskip}
\usepackage{mathtools}
\usepackage[square, numbers, comma, sort&compress]{natbib} 
\captionsetup[figure]{labelfont=bf}
\usepackage{hyperref}

\makeatletter
\@addtoreset{footnote}{section}
\makeatother

\renewcommand\vec{\boldsymbol}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LO]{{\rightmark}}
\fancyhead[RE]{{\leftmark}}
\fancyfoot[RO,LE]{\thepage}

\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\usepackage{chngcntr}
\counterwithout{figure}{chapter}

This is everything I have before I start the document. The problem I have now, is: every time I start a new chapter, the page number appears at the bottom of the page in the center, but the way I set it up (and want it to be) is that it should appear either left or right (depending on even/odd page number). I cannot find the error. Before, this was not a book, but an article and there it worked the way I wanted it. Now I changed it to book and left the rest the way it was before. Everything else works fine, its just the starting page of each chapter.

I hope my information is sufficient for you to find the error.

In addition, it would be nice, if I could keep my footer even if a new chapter starts on this page (the header can vanish as it usually does with new chapters).

Edit: Now that is weird. I thought the commands would line up beneath each other, but they don't. Really sorry for that, gonna see if I can fix it up.

  • 1
    this is not a complete minimum working example (to be honest, it is not even minimum :) ). It just your preamble. please put a complete mwe, in order for us to see the problem – Yorgos Aug 17 '16 at 21:25
  • Comment aside: needless to load amsmath if you load mathtools. – Bernard Aug 17 '16 at 21:35
  • @Yorgos Yeah, I know that, the thing is: What if I loaded a package, that did not work well with another one? That's why I listed the WHOLE stuff at the beginning in case I had 2 packages, that shut each other down and caused this problem I was in. – Zyrax Aug 17 '16 at 22:16
6

The problem comes from the fact that, in the book class, the first page of a chapter uses the plain style. The solution consists in redefining the plain style with fancyhdr. Here is a code, adapted from the documentation:

\fancypagestyle{plain}{%
\fancyhf{}% clears all header and footer fields
\fancyhead[LE,RO]{\thepage}%
\renewcommand{\headrulewidth}{0pt}%
\renewcommand{\footrulewidth}{0.4pt}}
| improve this answer | |
  • Thanks, it works! Another question I have: Every time a new chapter starts, it always starts on an odd page, meaning that if the last page before was an odd one, it will automatically add a new even page in-between. Do you maybe know, how to prevent this? – Zyrax Aug 17 '16 at 22:14
  • Add the option openany to the document class. The default is openright. – Bernard Aug 17 '16 at 22:22
  • Thanks! Another question: I defined a chapter with \chapter*, how can I let it appear in the header, like I did with the rest of the chapters? – Zyrax Aug 17 '16 at 22:46
  • Adding \markboth{chapter title}{} right after \chapter*{chapter title} should do the trick. – Bernard Aug 17 '16 at 23:41
  • Another question: how can I create a 2x2 table (already done this part) and put one column on flushleft and the other column on flushright? – Zyrax Aug 18 '16 at 0:02

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.