0

I am using fancyhdr to create two page styles. One page, the first one, will have a memo heading. The company logo, who its going to, organization name,etc. After that, I want a more simplified header and footer. For some reason, I can get my header to fit, but the text is overflowing and knocking out my footer. I have looked at the diagram for page size and margins.

I guess simplistically I would think that headsize+footsize+textsize = pagesize. I have tried shrinking textsize but my footer still seems to disappear. I was hoping that someone could help me fix this.

Below I have a minimal example (commented however):

\documentclass[11pt]{article}
\usepackage{graphicx}
\usepackage{fancyhdr}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\usepackage{color,colortbl}
\usepackage{fix-cm}
\usepackage{setspace}
\usepackage{lipsum}
\usepackage{blindtext}
\usepackage[letterpaper,margin=0.5in]{geometry}

%%%%%%%%%%%%%%%%%%%%% % PAGE STYLE %% %%%%%%%%%%%%%%%%%%%%% \fancypagestyle{firstpage} {%First page definitions \newgeometry{left=0.5in, right=0.5in, top=2.8in, bmargin=3.8in,headheight=179.1pt}

  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %                  HEADERS                             %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  %%%%%RIGHT SIDE HEADER%%%%%
  \fancyhead[R]{
    \begin{tabular}{r@{}c@{}l}
      \textit{To}: & Jane Doe, ABC-DE, PO 5125\\
      \textit{From}: &John Doe, ABC-DEF, PO 5125\\
      &Heather Doe, ABC-DEF, PO 5125\\
      &W. Sam Doe, ABC-DEF, PO 5126\\
      \textit{Thru}: &Chip Doe, ABC-DEF, PO 5126\\
      \textit{Phone}: &(800)867-5309\\
      \textit{Symbol}: &ABC-DEF:2021-XXXX\\
      \textit{Date}: &\today \\
    \end{tabular}
  }
      %%%%%END RIGHT SIDE HEADER%%%%%

%%%%%LEFT SIDE HEADER%%%%% \fancyhead[LH]{\vspace{1cm}ABC-DEF:2021-XXXXX \ \vspace{1cm} \includegraphics[width=0.3\textwidth]{somepic.png}\ \vspace{0.1cm}{\Large\textbf{memorandum}}\ ORG-NAM, SOME ORGANIZATION } %%%%%END LEFT SIDE HEADER%%%%%

%%%%%CENTER HEADER%%%%% \chead[C]{} %%%%%END CENTER HEADER%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % FOOTERS % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%CENTER FOOTER%%%%%%%%%%%%%% \cfoot[C]{} %%%%%%%%END CENTER FOOTER%%%%%%%%%%%%%%

%%%%%LEFT SIDE FOOTER%%%%% \lfoot{\vspace{0cm}\fbox{ \begin{minipage}[c]{0.45\textwidth} \begin{center} {\large\textbf{BLAH}} \end{center} blah blah blah blah blah blah blah blah blah blah blah \end{minipage} }%End of fbox } %%%%%END LEFT SIDE FOOTER%%%%%

%%%%%RIGHT SIDE FOOTER%%%%% \fancyfoot[R]{\vspace{0cm}\fbox{\raggedright \begin{minipage}[r]{0.4\textwidth} \begin{center} {\large \textbf{Chief Editor}} \end{center} \textbf{Brought to you by:} ME\ \textbf{Original:} XZ-ORG1-COMPANY\ \end{minipage} }%end of fbox } %%%%%END RIGHT SIDE FOOTER%%%%%

}%End of first page definitions

\fancypagestyle{otherpages}{%all otherpages \setlength{\headheight}{57.7pt} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % HEADERS % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%RIGHT SIDE HEADER%%%%% \fancyhead[R]{\today} %%%%%END RIGHT SIDE HEADER%%%%%

%%%%%LEFT SIDE HEADER%%%%% \fancyhead[LH]{\vspace{1cm}ABC-DEF: 2021-XXXXX} %%%%%END LEFT SIDE HEADER%%%%%

%%%%%CENTER HEADER%%%%% \fancyhead[C]{{\Huge\color{red}\textbf{HEAD/ER}}\-\thepage} %%%%%END CENTER HEADER%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % FOOTERS % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%CENTER FOOTER%%%%%%%%%%%%%% \cfoot[C]{\Huge\color{red}\textbf{FOOT/ER}} %%%%%%%%END CENTER FOOTER%%%%%%%%%%%%%%

%%%%%LEFT SIDE FOOTER%%%%% \fancyfoot[L]{} %%%%%END LEFT SIDE FOOTER%%%%%

%%%%%RIGHT SIDE FOOTER%%%%% \fancyfoot[R]{} %%%%%END RIGHT SIDE FOOTER%%%%%

}%end of all other pages

%%End of first page definition \pagestyle{otherpages} \thispagestyle{firstpage}

\begin{document}

{\Large \textbf{Subject: (U) poop}} \vspace{0.5cm}

\Blindtext \lipsum[1-10]

\end{document}

2 Answers2

2

I made some changes to the fancy header definitions but mostly to the implementation of the geometry package.

To get back the default geometry on the second page is not an easy task if you don't do it manually, by inserting the \restoregeometry (which itself starts a new page) at the correct place in the text.

However, a solution using the afterpage package seems to work in this case (from https://tex.stackexchange.com/a/358322/161015)

a2

b

\documentclass[11pt]{article}
\usepackage{graphicx}
\usepackage{fancyhdr}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\usepackage{color,colortbl}
\usepackage{fix-cm}
\usepackage{setspace}
\usepackage{lipsum}
\usepackage{blindtext}

\usepackage{showframe} % to show margins. Comment this line to clear <<<< \usepackage{afterpage} % needed <<<<<<<<<<<

\usepackage[letterpaper,left=0.5in, right=0.5in, top=1.5in, bottom=1.2in,headheight=0.8in]{geometry} % changed <<<

%%%%%%%%%%%%%%%%%%%%% % PAGE STYLE %% %%%%%%%%%%%%%%%%%%%%% \fancypagestyle{firstpage} {%First page definitions
\fancyhf{} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % HEADERS % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%RIGHT SIDE HEADER%%%%%
\fancyhead[R]{%% changed to align second column &lt;&lt;&lt;&lt;&lt;&lt;&lt;
    \begin{tabular}{rl}
        \textit{To}: &amp; Jane Doe, ABC-DE, PO 5125\\
        \textit{From}: &amp;John Doe, ABC-DEF, PO 5125\\
        &amp;Heather Doe, ABC-DEF, PO 5125\\
        &amp;W. Sam Doe, ABC-DEF, PO 5126\\
        \textit{Thru}: &amp;Chip Doe, ABC-DEF, PO 5126\\
        \textit{Phone}: &amp;(800)867-5309\\
        \textit{Symbol}: &amp;ABC-DEF:2021-XXXX\\
        \textit{Date}: &amp;\today \\
    \end{tabular}
}
%%%%%END RIGHT SIDE HEADER%%%%%

%%%%%LEFT SIDE HEADER%%%%%
\fancyhead[L]{%% changed &lt;&lt;&lt;&lt;&lt;&lt;
    \begin{tabular}{@{}l}
    ABC-DEF:2021-XXXXX \\[5pt]
    \includegraphics[width=0.3\textwidth]{example-image}\\[5pt]
    \Large\textbf{memorandum}\\[5pt]
    ORG-NAM, SOME ORGANIZATION
\end{tabular}
}
%%%%%END LEFT SIDE HEADER%%%%%

%%%%%CENTER HEADER%%%%%
\chead[C]{}
%%%%%END CENTER HEADER%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                  FOOTERS                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%    

%%%%%%%%CENTER FOOTER%%%%%%%%%%%%%%
\cfoot[C]{}
%%%%%%%%END CENTER FOOTER%%%%%%%%%%%%%%

%%%%%LEFT SIDE FOOTER%%%%%

\fancyfoot[L]{\vspace*{0pt}\fbox{% changed <<<<<< \begin{minipage}[c]{0.45\textwidth}
\centering\textbf{BLAH}\
\raggedright blah blah blah blah blah blah blah blah blah blah blah \end{minipage} }%End of fbox } %%%%%END LEFT SIDE FOOTER%%%%%

%%%%%RIGHT SIDE FOOTER%%%%%
\fancyfoot[R]{\vspace*{0pt}\fbox{%
        \begin{minipage}[r]{0.4\textwidth}              
            \centering\large \textbf{Chief Editor}\\                
            \raggedright    \textbf{Brought to you by:} ME\\
            \textbf{Original:} XZ-ORG1-COMPANY
        \end{minipage}
    }%end of fbox
}
%%%%%END RIGHT SIDE FOOTER%%%%%

}%End of first page definitions

\fancypagestyle{otherpages}{%all otherpages \fancyhf{} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % HEADERS % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%RIGHT SIDE HEADER%%%%%
\fancyhead[R]{\today}
%%%%%END RIGHT SIDE HEADER%%%%%

%%%%%LEFT SIDE HEADER%%%%%
\fancyhead[LH]{\vspace{1cm}ABC-DEF: 2021-XXXXX}
%%%%%END LEFT SIDE HEADER%%%%%

%%%%%CENTER HEADER%%%%%
\fancyhead[C]{{\Huge\color{red}\textbf{HEAD/ER}}\\-\thepage}
%%%%%END CENTER HEADER%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                  FOOTERS                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%CENTER FOOTER%%%%%%%%%%%%%%
\fancyfoot[C]{\Huge\color{red}\textbf{FOOT/ER}}
%%%%%%%%END CENTER FOOTER%%%%%%%%%%%%%%


%%%%%LEFT SIDE FOOTER%%%%%
\fancyfoot[L]{}
%%%%%END LEFT SIDE FOOTER%%%%%

%%%%%RIGHT SIDE FOOTER%%%%%
\fancyfoot[R]{}
%%%%%END RIGHT SIDE FOOTER%%%%%

}%end of all other pages

%%End of first page definition \pagestyle{otherpages} % activate style to by used from the second page

\begin{document}

\thispagestyle{firstpage} \newgeometry{letterpaper,left=0.5in, right=0.5in, top=3.5in, bottom=1.8in,headheight=2.5in} {\noindent\Large \textbf{Subject: (U) poop}} \vspace{0.5cm}

\afterpage{\globaldefs=1 \restoregeometry} % see reference https://tex.stackexchange.com/a/358322/161015

\lipsum[1-10]

\end{document}

As a simpler second alternative, without using afterpage nor \restoregeometry, you can leave some vertical space on the first page, to make place for the expanded heading, and then \pagestyle{otherpages} will start from the second page onwards. (Similar to this answer https://tex.stackexchange.com/a/577066/161015)

d2

With the same preamble use

\begin{document}

\vspace*{1.5in} % added <<<<<<<<

\thispagestyle{firstpage} {\noindent\Large \textbf{Subject: (U) poop}} \vspace{0.5cm}

\lipsum[1-10]

\end{document}

Simon Dispa
  • 39,141
1

If you use geometry to enlarge the header and/or footer, it is generally advisable to include the includeheadfoot option, so that geometry will adapt the textheight.

For the first page, I would advise to put what is in your firstpage header, not in the header but in the text after the \begin{document}. If you want to specify it in the preamble the you can put it in \AtBeginDocument{...}.

If you still want to do it with a header, my advise is to fool LaTeX by making the header appear to be of a normal header height (e.g. 10pt) and leave out the \newgeometry. In this way you can have your geometry the same on all pages. But then you have to compensate by starting the document with a \vspace to make up for the real header height.

You can fake the header height by putting it in a \raisebox and specifying the required height (e.g. 10pt) and depth (0pt). As \raisebox only accepts horizontal material, you have to put the left header inside a \parbox inside the \raisebox. You will have to fiddle a bit with the amount the boxes will be raised to get a proper positioning.

Here is a rough example.

\documentclass[11pt]{article}
\usepackage{graphicx}
\usepackage{fancyhdr}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\usepackage{color,colortbl}
\usepackage{fix-cm}
\usepackage{setspace}
\usepackage{lipsum}
\usepackage{blindtext}
\usepackage[letterpaper,margin=0.5in]{geometry}

%%%%%%%%%%%%%%%%%%%%% % PAGE STYLE %% %%%%%%%%%%%%%%%%%%%%% \fancypagestyle{firstpage} {%First page definitions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % HEADERS % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  %%%%%RIGHT SIDE HEADER%%%%%
  \fancyhead[R]{\raisebox{-5cm}[10pt][0pt]{%
    \begin{tabular}{r@{}c@{}l}
      \textit{To}: &amp; Jane Doe, ABC-DE, PO 5125\\
      \textit{From}: &amp;John Doe, ABC-DEF, PO 5125\\
      &amp;Heather Doe, ABC-DEF, PO 5125\\
      &amp;W. Sam Doe, ABC-DEF, PO 5126\\
      \textit{Thru}: &amp;Chip Doe, ABC-DEF, PO 5126\\
      \textit{Phone}: &amp;(800)867-5309\\
      \textit{Symbol}: &amp;ABC-DEF:2021-XXXX\\
      \textit{Date}: &amp;\today \\
    \end{tabular}}
  }
      %%%%%END RIGHT SIDE HEADER%%%%%

%%%%%LEFT SIDE HEADER%%%%% \fancyhead[L]{\raisebox{-3cm}[10pt][0pt]{\parbox{0.5\headwidth}{\vspace{1cm}ABC-DEF:2021-XXXXX \ [1cm] \includegraphics[width=0.3\textwidth]{example-image}\ \vspace{0.1cm}{\Large\textbf{memorandum}}\ ORG-NAM, SOME ORGANIZATION }}} %%%%%END LEFT SIDE HEADER%%%%%

%%%%%CENTER HEADER%%%%% \chead[C]{} %%%%%END CENTER HEADER%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % FOOTERS % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%CENTER FOOTER%%%%%%%%%%%%%% \cfoot[C]{} %%%%%%%%END CENTER FOOTER%%%%%%%%%%%%%%

%%%%%LEFT SIDE FOOTER%%%%% \lfoot{\vspace{0cm}\fbox{ \begin{minipage}[c]{0.45\textwidth} \begin{center} {\large\textbf{BLAH}} \end{center} blah blah blah blah blah blah blah blah blah blah blah \end{minipage} }%End of fbox } %%%%%END LEFT SIDE FOOTER%%%%%

%%%%%RIGHT SIDE FOOTER%%%%% \fancyfoot[R]{\raisebox{-40pt}[10pt]{\fbox{\raggedright \begin{minipage}[r]{0.4\textwidth} \begin{center} {\large \textbf{Chief Editor}} \end{center} \textbf{Brought to you by:} ME\ \textbf{Original:} XZ-ORG1-COMPANY\ \end{minipage} }%end of fbox }} %%%%%END RIGHT SIDE FOOTER%%%%%

}%End of first page definitions

\fancypagestyle{otherpages}{%all otherpages \setlength{\headheight}{57.7pt} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % HEADERS % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%RIGHT SIDE HEADER%%%%% \fancyhead[R]{\today} %%%%%END RIGHT SIDE HEADER%%%%%

%%%%%LEFT SIDE HEADER%%%%% \fancyhead[LH]{\vspace{1cm}ABC-DEF: 2021-XXXXX} %%%%%END LEFT SIDE HEADER%%%%%

%%%%%CENTER HEADER%%%%% \fancyhead[C]{{\Huge\color{red}\textbf{HEAD/ER}}\-\thepage} %%%%%END CENTER HEADER%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % FOOTERS % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%CENTER FOOTER%%%%%%%%%%%%%% \cfoot[C]{\Huge\color{red}\textbf{FOOT/ER}} %%%%%%%%END CENTER FOOTER%%%%%%%%%%%%%%

%%%%%LEFT SIDE FOOTER%%%%% \fancyfoot[L]{} %%%%%END LEFT SIDE FOOTER%%%%%

%%%%%RIGHT SIDE FOOTER%%%%% \fancyfoot[R]{} %%%%%END RIGHT SIDE FOOTER%%%%%

}%end of all other pages

%%End of first page definition \pagestyle{otherpages}

\begin{document} \thispagestyle{firstpage}

\vspace*{7cm}

{\Large \textbf{Subject: (U) poop}} \vspace{0.5cm}

\Blindtext \lipsum[1-10]

\end{document}

enter image description here