0

I have a problem that has been discussed before, but none of the solutions given in the answers I've found worked for me.

The problem is that the bottom margin of the first page is different than the one of the other pages and this puts the footer in different places.

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{array}
\usepackage{graphicx}
\usepackage{fancyhdr}
% I have tried most options to geometry that made some sense to me. No change
\usepackage%,includefoot%, headheight=2cm, includeheadfoot
{geometry}
\usepackage{lastpage}

% Someone suggested in an answer that the behaviour of \newgeometry should be different.
\newgeometry{left=2.00cm, right=3.00cm, top=2cm, bottom=5.5cm}

\pagestyle{fancy}
\fancyhf{}

\renewcommand{\headrulewidth}{0pt}

\chead{\begin{minipage}{4.5cm}
        \includegraphics[width=4cm]{example-image-a}
    \end{minipage}%
    \begin{minipage}{10.5cm}
        \begin{tabular}{| >{\raggedright\arraybackslash}m{5cm}|>{\raggedright\arraybackslash}m{5.8cm}|}
            \hline 
            \multicolumn{2}{| >{\raggedright\arraybackslash}m{10.5cm}|}{{\large Some information}} \\[2ex]
            \hline
            \rule{0pt}{4ex} {\large Klasse:} &  {\large Name:} \\[3ex] 
            %\cline{2-2}
            \rule{0pt}{4ex} {\large Datum:}     & \\[3ex]
            \hline
        \end{tabular}
\end{minipage}}

\rfoot{\thepage/\pageref{LastPage}}

\title{My example}

\begin{document}
    
% With \maketitle uncommented the behavior is even funnier: the first page style is not fancy

%   \maketitle

    Blabla
    
    \pagebreak
    
    Blabla
    
    \pagebreak
    
    Blabla  
    
\end{document}

If I make the margin too small, the first page will look fine, with the page numbering at the right place, but then the page numbers won't show up on the other pages. If I set it too big, the page numbers will show up on all pages, but in the first one it will be too high. None of the (many) things I have tried has done anything. I'm obviously overlooking something, but I don't know what.

1

Not really an answer but it maybe of some help (too long for a comment). I've fiddled around with your MWE, for which thank you.

% footprob.tex  SE 563265
\documentclass[12pt,a4paper]{article}

\usepackage{lipsum}  % PW ADDED

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{array}
\usepackage{graphicx}
\usepackage{fancyhdr}
% I have tried most options to geometry that made some sense to me. No change
\usepackage%,includefoot%, headheight=2cm, includeheadfoot
{geometry}
\usepackage{lastpage}

% Someone suggested in an answer that the behaviour of \newgeometry should be different.
\newgeometry{left=2.00cm, right=3.00cm, top=2cm, bottom=5.5cm}
\newgeometry{left=2.00cm, right=2.00cm, top=5cm, bottom=5.5cm}

\pagestyle{fancy}
\fancyhf{}

\renewcommand{\headrulewidth}{0pt}

\chead{\begin{minipage}{4.5cm}
        \includegraphics[width=4cm]{example-image-a}
    \end{minipage}%
    \begin{minipage}{10.5cm}
        \begin{tabular}{| >{\raggedright\arraybackslash}m{5cm}|>{\raggedright\arraybackslash}m{5.8cm}|}
            \hline 
            \multicolumn{2}{| >{\raggedright\arraybackslash}m{10.5cm}|}{{\large Some information}} \\[2ex]
            \hline
            \rule{0pt}{4ex} {\large Klasse:} &  {\large Name:} \\[3ex] 
            %\cline{2-2}
            \rule{0pt}{4ex} {\large Datum:}     & \\[3ex]
            \hline
        \end{tabular}
\end{minipage} % \vspace{12pt}
}

\rfoot{\thepage/\pageref{LastPage}}

\title{My example}

\begin{document}

%\enlargethispage{2cm}

%\pagestyle{fancy}
%\fancyhf{}

%\begin{document}
    
% With \maketitle uncommented the behavior is even funnier: the first page style is not fancy

%   \maketitle

% PW ADDED
% \thispagestyle{plain} % added during EDIT
\mbox{}
\vspace{2cm}

    Blabla

\lipsum % PW ADDED
    
    \pagebreak
    
    Blabla
    
    \pagebreak
    
    Blabla  
    
\end{document}

Your header was wider than the \textwidth so I increased that in the \newgeometry.

Processing your original MWE on the first page the word Blabla was typeset in the header. I added the \mbox ... which seemed to correct that. I tried \enlargethispage for the first page which typeset about the right amount of text but this overwrote the footer which remained in the same position as in your MWE.

In an edit to my answer code I put \thispagetsyle{plain} on the first page. The second page was then all screwed up.

I have really no idea what is causing the problem as your code looked very reasonable to me.

| improve this answer | |
  • Thank you, Peter. Yes, I noticed the fist page's Blabla which ended up in the header, but that was not too much of a concern to me because I fixed it in the actual document. I also noticed that the header was wider than \textwidth, but that too didn't bother me too much, unless it's the cause of the trouble with the footer (which would be pretty odd in my opinion). – Andyc Sep 20 at 6:09
  • @Andyc I have slightly edited my answer by making the pagestyle of the first page to be plain. The second page is then all screwed up. It seems that the first use of your fancy pagestyle does something weird although later uses are OK.. – Peter Wilson Sep 22 at 17:52
0

I think I found the culprit.

Because my source compiled without errors, I wasn't "redirected" to the log tab (by TexStudio, which I'm using), so I didn't see the warnings. When I got into an error by playing with the file a little bit, I saw among the errors there was the warning of the header being too small and it suggested to set \setlength{\headheight}{at-least-so-much}. I followed the suggestion and now my MWE looks as follows (I also added \blindtext instead of "blabla").

\documentclass[12pt,a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{array}
\usepackage{graphicx}
\usepackage{lastpage}
\usepackage[left=2.00cm, right=3.00cm, top=2.00cm, bottom=4.00cm, includefoot]{geometry}

\usepackage{mwe}

\usepackage{fancyhdr}
\setlength{\headheight}{102pt}
\pagestyle{fancy}

\fancyhf{}

\renewcommand{\headrulewidth}{0pt}

\lhead{\begin{minipage}{4.5cm}
        \includegraphics[width=4cm]{example-image-a}
    \end{minipage}%
    \begin{minipage}{11.6cm}
        \begin{tabular}{| >{\raggedright\arraybackslash}m{5cm}|>{\raggedright\arraybackslash}m{6cm}|}
            \hline 
            \multicolumn{2}{| >{\raggedright\arraybackslash}m{11.8cm}|}{\rule{0pt}{4ex}{\large 1. Klassenarbeit Mathematik (A) \hfill Lehrer: Andyc}} \\[2ex]
            \hline
            \rule{0pt}{4ex} {\large Klasse:} & \rule{0pt}{4ex} {\large Name:} \\[3ex] 
            \rule{0pt}{4ex} {\large Datum:}     & \\[3ex]
            \hline
        \end{tabular}
\end{minipage}}

\rfoot{\thepage/\pageref{LastPage}}


\author{Andyc}

\begin{document}
    \blindtext
    \pagebreak
    \blindtext
    \pagebreak
    \blindtext
\end{document}

and now all the page numbering looks correct (even though a bottom margin of 4 cm feels like a lot to me only to make the numbers appear 1/2cm above the page border).

| improve this answer | |

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.