1

I am using the below code for a document, but I am running into an error whereby the page header (code below)

\rhead{\large\centering{\textit{title at top of all pages}}}

overlaps with headings for subsections (code below)

\subsection{subsection}
    \label{text}

How can I make the page header appear only on the first page, (which would hopefully solve the problem), or stop subsection headings from overlapping with the page header on later pages

Main document code below

     \documentclass[11pt]{article}
\usepackage[tmargin=1.25in,bmargin=1.25in,lmargin=1.5in,rmargin=1.5in]{geometry}
\usepackage{times}               % Times Roman
\usepackage[scaled=0.86]{helvet} % Helvetica
\usepackage{sectsty}             
\sectionfont{\large\sffamily}    
\usepackage{fancyhdr}
\usepackage{mathptmx}            %used to make Title larger

%% Packages used for Algorithms
\usepackage[fleqn]{amsmath}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{graphicx}
\usepackage{subfig}
%% Packages used for referencing
\usepackage[nosectionbib,numberedbib]{apacite}
\AtBeginDocument{\renewcommand\refname{REFERENCES}}


\begin{document}
\raggedright

\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\rhead{\large\centering{\textit{top page header}}}
\rfoot{Copyright $\textcopyright$ 2018}
\cfoot{}
\sffamily
\noindent\rule{14cm}{1pt}


\begin{center}


\Huge\bfseries\sffamily {\fontsize{35}{60}\selectfont Title}
%\par
\vspace{5mm}
\end{center}
\vspace{-\baselineskip}
\noindent\rule{14cm}{1pt}
\fontfamily{ptm}\selectfont

\begin{flushleft}
\vspace{7mm}
\par
\large{\textbf{authors}}
\vspace{5mm}
\par
\large{\textit{text}}
\par
%\vspace{5mm}
\section*{ABSTRACT}

text
\vspace{5mm}
\par 
\textit{Keyword:  text.} 
\par  
\vspace{5mm}
\noindent\rule{14cm}{1pt}
\vspace{5mm}
\par


\section{INTRODUCTION}
\label{introduction}
\vspace{-3mm}

text
\par
\vspace{2mm}

text
\par
\vspace{2mm}
text

\begin{enumerate}
\item text;
\item text;
\item text. 
\end{enumerate}


\vspace{2mm}
\par

\section{RELATED WORK}
\label{relatedwork}
\vspace{-3mm}

text
\vspace{5mm}
\par

\subsection{text}
\label{text}

text

\subsection{text}
\label{text}

text

\subsection{text}
\label{text}

text

\vspace{2mm}
\par


\section{text}
\label{text}
%\vspace{-3mm}

text

%\vspace{7mm}
%\par

\subsection{text}
\label{text}

%\vspace{5mm}
%\par
\begin{figure}[h!]
    \centering
    \includegraphics[width=0.75\textwidth]{IMG/pic.pdf}
    \caption{txt}
    \label{text}
\end{figure}




text

\begin{center}
\begin{minipage}{0.7\textwidth}
\begin{algorithm}[H]
    \centering
    \caption{Example Algorithm}\label{algorithm}
    \begin{algorithmic}[1]
        \State \text{dataProcessing (dataset)} 
        \State $\textit{unitToDrop} \gets \text{25\%}$
        \State \text{text}
        \State \text{text}
        \Repeat
        \State \text{/*text*/}
        \For{$i\gets 1, rows$}
        \State $\text{text}$ 
        \State $\text{text}$ 
        \State $\text{text}$ 
        \State \text{text}
        \State $\text{text}$
        \EndFor
        \Until {text}
        \State \text{text}
        \Repeat
        \State \text{text}
        \For{$i\gets 1, rows$}
        \State $\text{text}$ 
        \State $\text{v}$ 
        \EndFor
        \Until {text}
        \State \textbf{Return}  \text{text, text}
    \end{algorithmic}
\end{algorithm}
\end{minipage}
\end{center}



\subsection{text}
\label{text}
\vspace{-3mm}
text
\vspace{5mm}
\par


\subsubsection{text}
\vspace{-3mm}
text
\vspace{5mm}
\par

\subsubsection{text}
\vspace{-3mm}
text
\vspace{5mm}
\par

\subsection{text}
\label{text}
\vspace{1mm}


text

\begin{center}
\begin{minipage}{0.7\textwidth}
\begin{algorithm}[H]
    \centering
    \caption{Example Algorithm}\label{algorithm}
    \begin{algorithmic}[1]
        \State \text{dataProcessing (dataset)} 
        \State $\textit{unitToDrop} \gets \text{25\%}$
        \State \text{text}
        \State \text{text}
        \Repeat
        \State \text{/*text*/}
        \For{$i\gets 1, rows$}
        \State $\text{text}$ 
        \State $\text{text}$ 
        \State $\text{text}$ 
        \State \text{text}
        \State $\text{text}$
        \EndFor
        \Until {text}
        \State \text{text}
        \Repeat
        \State \text{text}
        \For{$i\gets 1, rows$}
        \State $\text{text}$ 
        \State $\text{v}$ 
        \EndFor
        \Until {text}
        \State \textbf{Return}  \text{text, text}
    \end{algorithmic}
\end{algorithm}
\end{minipage}
\end{center}

text



\vspace{5mm}
\par


\subsubsection{text}
\vspace{-3mm}
text
\vspace{5mm}
\par

\begin{center}
\begin{minipage}{0.7\textwidth}
\begin{algorithm}[H]
    \centering
    \caption{Example Algorithm}\label{algorithm}
    \begin{algorithmic}[1]
        \State \text{dataProcessing (dataset)} 
        \State $\textit{unitToDrop} \gets \text{25\%}$
        \State \text{text}
        \State \text{text}
        \Repeat
        \State \text{/*text*/}
        \For{$i\gets 1, rows$}
        \State $\text{text}$ 
        \State $\text{text}$ 
        \State $\text{text}$ 
        \State \text{text}
        \State $\text{text}$
        \EndFor
        \Until {text}
        \State \text{text}
        \Repeat
        \State \text{text}
        \For{$i\gets 1, rows$}
        \State $\text{text}$ 
        \State $\text{v}$ 
        \EndFor
        \Until {text}
        \State \textbf{Return}  \text{text, text}
    \end{algorithmic}
\end{algorithm}
\end{minipage}
\end{center}

\subsubsection{text}
\vspace{-3mm}
text
\vspace{5mm}
\par

\begin{table*}[h!]
    \fontsize{9}{11}\selectfont
    \centering
    \caption{text}
    \label{text}
    \begin{tabular}{|p{4.2cm}|p{1.0cm}|p{1.1cm}|p{2.2cm}|p{1.5cm}|}
        \hline

    \textbf{\begin{tabular}[c]{@{}l@{}}\end{tabular}} & \textbf{\begin{tabular}[c]{@{}l@{}}text\end{tabular}} & \textbf{\begin{tabular}[c]{@{}l@{}}text\end{tabular}} & \textbf{\begin{tabular}[c]{@{}l@{}}text\end{tabular}} & 
\textbf{\begin{tabular}[c]{@{}l@{}}text\end{tabular}}
  \\  \hline
        text & text   & 208418  & 99.998992 & 0.000809  \\ \hline
        text & 391002    & 210540    & 98.582144 & 0.125630   \\ \hline
        text & 411384 & 221515 & 93.765198 & 0.858700   \\ \hline
        text & 391622 & 210874 & 98.488289 & 0.116453  \\ \hline
        text & 419887   & 226094 & 91.951002 & 0.841303  \\ \hline
        text & 395564    & 212996 &  97.521033 & 0.115293  \\ \hline
        text & 468534 & 252289 & 92.243513 & 0.161890  \\ \hline

    \end{tabular}
\end{table*}



\begin{figure}[h!]%
    \centering
    \subfloat[text]{{\includegraphics[width=6.5cm]{IMG/text.pdf} }}%
    \qquad
    \subfloat[text]{{\includegraphics[width=6.5cm]{IMG/text.pdf} }}%
    \caption{text}%
    \label{usa_canada}%
\end{figure}


blh blah blah




\section{text}
\label{text}
\vspace{-3mm}
text
\vspace{7mm}
\par




\section{text}
\label{text}
\vspace{-3mm}
text
\vspace{7mm}
\par

\section{text}
\label{text}
\vspace{-3mm}
text
\vspace{7mm}
\par








\bibliographystyle{apacite}
\bibliography{sa.bib}

%\vspace{7mm}
%\par
\section*{text}
\label{key}
\vspace{-7mm}
\par
\noindent\rule{14cm}{1pt}
\vspace{-3mm}
\par
text
\vspace{7mm}
\par

%\vspace{7mm}
%\par
\section*{text}
\label{bio}
\vspace{-7mm}
\par
\noindent\rule{14cm}{1pt}
\vspace{-3mm}
\par
\textbf{text} 

text

\vspace{7mm}
\par

\textbf{text} 

text


\vspace{7mm}
\par


%\vspace{7mm}
%\par
\section*{text}
\label{text}
\vspace{-7mm}
\par
\noindent\rule{14cm}{1pt}
\vspace{-3mm}
\par
\textbf{text}: text

\vspace{7mm}
\par

\end{flushleft}
\end{document}
  • 1
    the markup in the document is very strange (why all the vspaces???) but it does not appear to be an example of the problem you ask about. There is only one subsection and its title comes towards the bottom of page 1 and does not overlap the page head. – David Carlisle Aug 30 '18 at 19:58
  • @DavidCarlisle yes the document is a little strange (it wasn't me who created it but need to use it). In my full document I have several subsections but I have only put one here as a MWE – Bat Aug 30 '18 at 20:16
  • 1
    the example has to be an example of the problem, otherwise there is no point in posting it!!! So far all we know is that some document that you have not shown has some overprinting. If like the document that is here it is full of negative vspaces then overprinting is not that surprising but without seeing any example how can anyone offer any help? – David Carlisle Aug 30 '18 at 20:23
  • 1
    yes you should post a MWE not the full original document but the E in MWE means it should be an example of the problem posting code that does not show the problem is not useful. The edited version is not a MWE as it fails with ! Package pdftex.def Error: File `IMG/text.pdf' not found: but it is better as it does show that the log warns of your problem and how to correct it: Package Fancyhdr Warning: \headheight is too small (12.0pt): Make it at least 14.0pt. We now make it that large for the rest of the document. This may cause the page layout to be inconsistent, however. – David Carlisle Aug 30 '18 at 20:57
  • 1
    the example also is still not an example of the problem as stated, it does not show any subsection overprinting the page header – David Carlisle Aug 30 '18 at 20:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.