0

This question already has an answer here:

I am using the fancyhdr package and need to configure my headers according to the following requirements:

  1. First page header contains a small image on the right side;
  2. Header on all pages contain a horizontal line that is 8pt wide and red and stretching all the way to the end of the page on both sides;
  3. Headers on all pages after the first page contain the title of the document (this part already works).

In order to make this work, the size (headheight parameter?) of the header on the first page needs to be bigger than on the other pages. Every time I figure out one aspect of this successfully, something else goes wrong.

I get the following error message most recently:

“Package Fancyhdr Warning: \headheight is too small (21.0pt): Make it at least 132.00504pt. We now make it that large for the rest of the document. This may cause the page layout to be inconsistent, however.”

If I make the headheight 133 for the entire document, everything works the way I want, but I of course can’t afford to have such a big header all the way through. I only want that on the first page.

Another option could just be to do something special on the first page to get the image in the top-right corner and the red horizontal line/box underneath it. Then the header can just start on the second page (as is the default, I believe).

I need to make many documents that all have identical style, so I am using a .sty file to control as many of the style elements as possible and then calling it in each individual latex file I make. So far this has worked really well. I just can’t figure out this one header issue.

I also need to do the same with the footer, once this header is figured out. In the footer, I need a big paragraph of text on the first page footer only. On all other pages I need a little bit of text in the footer. In all cases, the footer text needs to have a thin black line (the default, I believe) above it.

Here is my .sty file:

\usepackage{titlesec}
\usepackage{makecell}
\usepackage{framed, ifthen}
\usepackage{caption,seqsplit, graphicx,soul,color,verbatim, fancyhdr}
\usepackage[T1]{fontenc}
\usepackage{wrapfig,lipsum,booktabs,tabularx,bookman,enumitem}
\usepackage[table,xcdraw,dvipsnames]{xcolor}
\usepackage[margin=1.0in, headheight=21pt]{geometry}
% \usepackage[none]{hyphenat}

\usepackage[colorlinks = true,
            linkcolor = black,
            urlcolor  = blue,
            citecolor = blue,
            anchorcolor = black]{hyperref}

\definecolor{shadecolor}{HTML}{FFEFEF}


%%%%%%%%%%%%%% Header/Footer programming start %%%%%%%%%%%%

%%%%%%%%%%%%%%%
\newlength{\seplinewidth}
\newlength{\seplinesep}
\setlength{\seplinewidth}{8pt}
\setlength{\seplinesep}{.75in}
\colorlet{sepline}{blue}
\newcommand*{\sepline}{%
  \par
  \vspace{\dimexpr\seplinesep+.5\parskip}%
  \cleaders\vbox{%
    \begingroup % because of color
      \color{sepline}%
      \hrule width 2in height\seplinewidth
    \endgroup
  }\vskip\seplinewidth
  \vspace{\dimexpr\seplinesep-.5\parskip}%
}
% %%%%%%%%%%%%%%%


% \setlength{\headheight}{60pt}
%\renewcommand{\sectionmark}[1]{\gdef\currsection{#1}}
%\renewcommand{\subsectionmark}[1]{\markright{\currsection\ \textbullet\ #1}}
%\fancyhead[L]{ \nouppercase{\rightmark} \\}

% \rhead{\ifthenelse{\value{page}=1}{firstpage \\}{second page and after \\}}

\fancypagestyle{firstpage}{
  \fancyhf{}
  \fancyhead[R]{{\raisebox{\dimexpr-\height+\baselineskip}[0pt][0pt]{\includegraphics[width=2.5in]{GHELI_Logo1.png}}} \sepline}
}

\fancypagestyle{otherpages}{

%\pagestyle{fancy}
\fancyhf{}

\let\runtitle\@title
\lhead{\ifthenelse{\value{page}=1}{}{\runtitle} \vspace{8pt}}

% \rhead{\ifthenelse{\value{page}=1}{\includegraphics[width=6cm]{GHELI_Logo1.png}}{}}

\renewcommand{\headrulewidth}{8pt}
%\renewcommand{\headrule}{\hbox to \paperwitdh{\color{red}\leaders\hrule height \headrulewidth\hfill}}

%\rhead{\begin{picture}(0,0) \put(0,0){\includegraphics[width=6cm]{GHELI_Logo1.png}} \end{picture}}

% Length to control the \fancyheadoffset and the calculation of \headline
% simultaneously
\newlength\FHoffset
\setlength\FHoffset{1cm}

\addtolength\headwidth{2\FHoffset}

\fancyheadoffset{\FHoffset}

% these lengths will control the headrule trimming to the left and right 
\newlength\FHleft
\newlength\FHright

% here the trimmings are controlled by the user
\setlength\FHleft{-1in}
\setlength\FHright{-1in}

% The new definition of headrule that will take into acount the trimming(s)
\newbox\FHline
\setbox\FHline=\hbox{\color{red}\hsize=\paperwidth%
  \hspace*{\FHleft}%
  \rule{\dimexpr\headwidth-\FHleft-\FHright\relax}{\headrulewidth}\hspace*{\FHright}%
}
\renewcommand\headrule{\vskip-.7\baselineskip\copy\FHline}
}

\pagestyle{otherpages}
%%%%%%%%%%%%%%%%%% Header/Footer end %%%%%%%%%%%%%%%%%%%%%

\setlength{\parindent}{0pt}
% \setlength{\parskip}{3pt}

\setcounter{secnumdepth}{0}

\renewcommand{\familydefault}{\sfdefault}
% can be \rmdefault \sfdefault \ttdefault


\titleformat{\section}
{\color{red}\normalfont\LARGE\bfseries}
{\color{red}\thesection}{1em}{}
\titleformat{\subsection}
{\color{red}\normalfont\large\bfseries}
{\color{red}\thesubsection}{1em}{}
\begin{comment}
% not sure if i can do this: \titleformat{\title}
\end{comment}

Here is my .tex file:

\documentclass[twoside]{article}


 \title{\color{red} Section Guide 3}
 \author{Global Health Teaching Fellows Series 2018-19}
 \date{}

\usepackage{SectionStyle1}

\begin{document}

\captionsetup[table]{name=Box}

\maketitle
\thispagestyle{firstpage}

\tableofcontents

\section{Lesson Details}

\subsection{Purpose}

The purpose of this section guide is to help Teaching Fellows (TFs) lead their third 50-minute discussion section of the semester with their students.

\subsection{Section Outline}

\begin{enumerate} % [noitemsep]
%  \item Graphical Literacy Warm-Up (10 minutes)
  \item Check-In and Review (10 minutes)
  \item Zika Debate (40 minutes)
\end{enumerate}

\subsection{Required Student Preparation}

Students should read or prepare the following items:

\begin{itemize} % [noitemsep]
%  \setlength{\itemsep}{1pt}
%  \setlength{\parskip}{0pt}
%  \setlength{\parsep}{0pt}
  \item Zika Virus. World Health Organization 2016. \url{http://who.int/mediacentre/factsheets/zika/en/}.
  \item Landry C. Zika is Driving Up Demand for Abortion. Here's why it shouldn't. The Washington Post 2016; Nov 22. \url{http://washingtonpost.com/posteverything/wp/2016/11/22/zika-is-driving-up-demand-for-abortion-heres-why-it-shouldnt}.
  \item Double Trouble: Many of the Areas at Greatest Risk for the Zika Virus Score Low on Reproductive Health Indicators. Population Institute 2016. \url{http://populationinstitute.org/external/Zika_Report_Double_Trouble.pdf}.
  \item Learn additional information about assigned region.
  \item Consider the reproductive rights landscape of your assigned region based on the reading and brainstorm implications for the transmission or control of Zika virus.
\end{itemize}

\subsection{TF Preparation Checklist}

\begin{itemize}
  \item Prepare for the Zika Debate by assigning a region to the students. 
\end{itemize}

\section{Learning Goals}

\begin{enumerate}
  \item Describe the determinants of health (type and level) associated with emerging infectious diseases, such as zika.
  \item Participate in a policy debate about how health systems can respond to infectious disease threats.
  \item Provide examples of how contributions can be made in tackling infectious diseases from both the health and non-health sectors.
\end{enumerate}

\section{Procedure}

\subsection{Before Section Begins}

In section, students will debate about the issue of abortion services in one particular region or country. At the time that students are assigned to read the "Double Trouble" report to prepare for this section meeting, they should also be assigned a region to focus on for the debate activity that will occur in section. A number of regions are covered in Part 3 of the ``Double Trouble'' reading, any of which could be reasonably used in the debate. The TF can decide which region the entire section will focus on (or students could vote at the previous meeting). The rest of this guide is written with examples from the U.S. states of Texas and Florida, but the TF can easily adapt the provided procedure to another region. \\

This section guide is written for students to debate the following resolution: ``Increased access to abortion services is a critical health systems response to the spread of Zika virus in Texas and Florida.'' \\

TFs can use this topic with their students or choose a different one for the students to debate. TFs should become familiar beforehand with possible arguments for and against the debated-upon resolution. \\

Half of the students will argue for the resolution and half will argue against it. TFs can decide to assign students to teams ahead of time, such that students would only need to come prepared to argue for their own team; or TFs can assign students to teams in the section meeting itself, meaning that students would need to come prepared to debate both for or against the resolution. 

\subsection{Part 1: Check-In and Review}
(10 minutes)



\begin{shaded*}

\textbf{Activity goals}
\begin{itemize}
  \item Review any items from class or the reading assignment.
\end{itemize}

\end{shaded*}

Touch base with students to see if they have any questions about homeworks or major concepts that were discussed in class. This is meant to just be a chance for TFs to take the temperature of the room, so if people have a lot of burning questions, keep track of them and consider following up by e-mail, or if you have time after you get through today's activities, you can return to them. You could also spend this time reviewing a selected concept from class that you feel would be useful. \\

Students may also have questions about the report they read in preparation for the section, which you can answer during this time.


\subsection{Part 2:  Zika Debate}
(40 minutes)

\begin{shaded*}
\textbf{Activity goals}
\begin{itemize}
  \item Practice taking sides of a global health debate, understanding all viewpoints, and arguing in favor of or against a particular resolution or policy. 
  \item Understand how infectious disease control can intersect with other major health issues (in this case, Zika and reproductive rights)
\end{itemize}
\end{shaded*}

In this portion of the class, students will participate in a debate based on the assigned reading. An example based on the issue of abortion services in the U.S. states of Texas and Florida is provided below. However, TFs could use the same procedure to facilitate a debate on any topic or region of their choosing.  

\begin{enumerate}
  \item In class, present the following resolution: 

  \textbf{Increased access to abortion services is a critical health systems response to the spread of Zika virus in the Americas.} 

  \item Divide the class into a group in support of this resolution (called the ``pro'' or ``for'' team) and another in opposition (called the ``con'' or ``against'' team).

  \item Give the students 10-15 minutes to prepare their arguments. Remind students that all team members must present part of their team's argument or rebuttal. 

  \item Facilitate a debate between the two teams according to the following schedule:

  \begin{itemize}
    \item 3 minutes: Group in favor of the resolution (for) presents their case
    \item 3 minutes: Group in opposition (against) presents their case
    \item 5 minutes: Groups huddle to prepare rebuttal points
    \item 2 minute: Rebuttal by against team.
    \item 2 minute: Rebuttal by for team.
  \end{itemize}

  \item Once the debate is over, facilitate a group discussion addressing the key take away messages you want students to leave with. These include:

  \begin{itemize}
    \item The difference between primary and secondary prevention.

    \textit{In this case, primary prevention would be the availability of and access to contraception, whereas abortion would be a form of secondary prevention.}

    \item The trade-offs involved in a policy decision.

    \textit{Should funds go towards increased access to abortion services, blocking some of the social and environmental determinants of Zika, or to something else altogether?}

    \item How culture and politics influences public health discourse.

    \item The interplay between health and human rights.

    \item How social inequities contribute to the spread of infectious disease.

    \textit{For example, the different social determinants of contraceptive use and unintended pregnancies across different geographies, populations, and social classes.}

  \end{itemize}

\end{enumerate}


\end{document}

marked as duplicate by Andrew Swann, Phelype Oleinik, TeXnician, CarLaTeX, Bobyandbob Mar 13 '18 at 17:26

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2

You should never misuse headers for a title. Here a suggeesteion using package sclayer-scrpage.

dfwTitelpage

I moved a few packages around, but left them mostly untouched.

\documentclass[twoside]{article}


\usepackage{blindtext}
\usepackage[margin=1.0in, headheight=21pt]{geometry}
\usepackage[table,xcdraw,dvipsnames]{xcolor}
\usepackage{scrlayer-scrpage}
\KOMAoptions{headsepline=8pt:1.4\textwidth}
\setkomafont{headsepline}{\color{red}}
\ohead{\doctitle}
\usepackage{titlesec}
\usepackage{makecell}
\usepackage{framed, ifthen}
\usepackage{caption,seqsplit, graphicx,soul,color,verbatim, }
\usepackage[T1]{fontenc}
\usepackage{wrapfig,lipsum,booktabs,tabularx,bookman,enumitem}
% \usepackage[none]{hyphenat}


\definecolor{shadecolor}{HTML}{FFEFEF}



\usepackage[colorlinks = true,
            linkcolor = black,
            urlcolor  = blue,
            citecolor = blue,
            anchorcolor = black]{hyperref}

\setlength{\parindent}{0pt}
% \setlength{\parskip}{3pt}

\setcounter{secnumdepth}{0}

\renewcommand{\familydefault}{\sfdefault}
% can be \rmdefault \sfdefault \ttdefault


\titleformat{\section}
{\color{red}\normalfont\LARGE\bfseries}
{\color{red}\thesection}{1em}{}
\titleformat{\subsection}
{\color{red}\normalfont\large\bfseries}
{\color{red}\thesubsection}{1em}{}

\renewcommand{\maketitle}{
\vspace*{-2cm}
\thispagestyle{empty}
  \hfill\includegraphics[width=4cm,height=4cm]{example-image-16x9}
  {\color{red}\rule{1.2\textwidth}{8pt}}
  \begin{center}%
  \let \footnote \thanks
    {\LARGE \color{red} \sectitle \par}%
    \vskip 1.5em%
    {\large
      \doctitle
      \lineskip .5em%
      \par}%
  \end{center}%
  \par
  \vskip 1.5em
}

\newcommand{\sectitle}{Section Guide 3}
\newcommand{\doctitle}{Global Health Teaching Fellows Series 2018-19}
\begin{document}
\maketitle
\tableofcontents

\section{Lesson Details}

\subsection{Purpose}

The purpose of this section guide is to help Teaching Fellows (TFs) lead their third 50-minute discussion section of the semester with their students.
\blinddocument
\end{document}
  • Thanks for your help. This looks perfect except that I also want the very same red line on the first page, underneath the image. You made a 2x1cm image in the example code. Let's say I want a 4x4cm image on the first page and under that, the same 8pt red line that's on all the other pages (but of course lower down on the page). Please advise on how to add that line (I understand how to change the image size)! – DFW Mar 10 '18 at 23:18
  • @DFW See the edit. – Johannes_B Mar 18 '18 at 8:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.