5

I found a nice Latex template here and I would like to include an image to to the header which is aligned in the right side. I like the template, which is why I would like to adapt it.

I included a blue test image for demo purposes. What happens then is that on the following pages, the space occupied by the header on the first page is included as white space in the second page. I marked this space with a red rectangle in the picture. Note that in the document, this space is just white.

The document with the image

How can I include the image and remove the white space from the second page? I tried to introduce pagestyles for the fancy header, but it does not work.

\fancypagestyle{firststyle}
{
   \fancyhf{}
  \rhead{\raisebox{-2.2\height}{\includegraphics[height=30mm]{testimage}}}
}

\fancypagestyle{second}{%
 \fancyhead{}

}

Using two page styles as described here does not work as expected, the second style does not have any effect. Either the image is removed or the space is occupied. You can see the complete source code below and try it here on overleaf.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Large Colored Title Article
% LaTeX Template
% Version 1.1 (25/11/12)
%
% This template has been downloaded from:
% http://www.LaTeXTemplates.com
%
% Original author:
% Frits Wenneker (http://www.howtotex.com)
%
% License:
% CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%----------------------------------------------------------------------------------------
%   PACKAGES AND OTHER DOCUMENT CONFIGURATIONS
%----------------------------------------------------------------------------------------

\documentclass[DIV=calc, paper=a4, fontsize=11pt, twocolumn]{scrartcl}   % A4 paper and 11pt font size

\usepackage{lipsum} % Used for inserting dummy 'Lorem ipsum' text into the template
\usepackage[english]{babel} % English language/hyphenation
\usepackage[utf8]{inputenc}
\usepackage[protrusion=true,expansion=true]{microtype} % Better typography
\usepackage{amsmath,amsfonts,amsthm} % Math packages
\usepackage[svgnames,dvipsnames]{xcolor} % Enabling colors by their 'svgnames'
\usepackage[hang, small,labelfont=bf,up,textfont=it,up]{caption} % Custom captions under/above floats in tables or figures
\usepackage{booktabs} % Horizontal rules in tables
\usepackage{fix-cm}  % Custom font sizes - used for the initial letter in the document
\usepackage{framed, color}
\usepackage{url}

%%%%%%%%%%%%%%%%% Farbige box
\usepackage{tcolorbox}

%%%%%%%%%%%%%%%%%



\usepackage{sectsty} % Enables custom section titles
\allsectionsfont{\usefont{OT1}{phv}{b}{n}} % Change the font of all section commands

\usepackage{fancyhdr} % Needed to define custom headers/footers

\pagestyle{fancy} % Enables the custom headers/footers
\usepackage{lastpage} % Used to determine the number of pages in the document (for "Page X of Total")

% Headers - all currently empty
\lhead{}
\chead{}
\rhead{}

% Footers
\lfoot{}
\cfoot{}
\rfoot{\footnotesize Page \thepage\ of \pageref{LastPage}} % "Page 1 of 2"

\renewcommand{\headrulewidth}{0.0pt} % No header rule
\renewcommand{\footrulewidth}{0.4pt} % Thin footer rule

\usepackage{lettrine} % Package to accentuate the first letter of the text
\newcommand{\initial}[1]{ % Defines the command and style for the first letter
\lettrine[lines=3,lhang=0.3,nindent=0em]{
\color{OliveGreen}
{\textsf{#1}}}{}}



%----------------------------------------------------------------------------------------
%   TITLE SECTION
%----------------------------------------------------------------------------------------

\usepackage{titling} % Allows custom title configuration

\newcommand{\HorRule}{\color{OliveGreen} \rule{\linewidth}{1pt}} % Defines the gold horizontal rule around the title

\pretitle{\vspace{-30pt} \begin{flushleft} \HorRule \fontsize{50}{50} \usefont{OT1}{phv}{b}{n} \color{RawSienna} \selectfont} % Horizontal rule before the title


\title{Test Article} % Your article title

\posttitle{\par\end{flushleft}\vskip 0.5em} % Whitespace under the title

\preauthor{\begin{flushleft}\large \lineskip 0.5em \usefont{OT1}{phv}{b}{sl} \color{Black}} % Author font configuration

\author{John Doe\\} % Your name

\postauthor{\footnotesize \usefont{OT1}{phv}{m}{sl} \color{Black} % Configuration for the institution name
Sample Institute of Technology\\
% Your institution

%% logo
%\rhead{\raisebox{-2.0\height}{\includegraphics[height=40mm]{images/logo2}}}

\par\end{flushleft}\HorRule} % Horizontal rule after the title

\date{\today} % Add a date here if you would like one to appear underneath the title block

%----------------------------------------------------------------------------------------


\fancypagestyle{firststyle}
{
   \fancyhf{}
  \rhead{\raisebox{-2.2\height}{\includegraphics[height=30mm]{testimage}}}
}

\fancypagestyle{second}{%
 \fancyhead{}


}




\begin{document}

\maketitle % Print the title

\thispagestyle{firststyle} % Enabling the custom headers/footers for the first page 

%----------------------------------------------------------------------------------------
%   ABSTRACT
%----------------------------------------------------------------------------------------

% The first character should be within \initial{}
\textbf{\lipsum[1-2]}

%----------------------------------------------------------------------------------------
%   ARTICLE CONTENTS
%----------------------------------------------------------------------------------------


\section*{Section 1}
\lipsum[1-4]




\section*{Section 2}
\lipsum[1-4]
\thispagestyle{second} % Enabling the custom headers/footers for the first page 
\section*{Section 2}
\lipsum[1-4]

%----------------------------------------------------------------------------------------

\end{document}
0

3 Answers 3

1

It makes just as much sense to overlay an image from the bottom up as from the top down.

enter image description here

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Large Colored Title Article
% LaTeX Template
% Version 1.1 (25/11/12)
%
% This template has been downloaded from:
% http://www.LaTeXTemplates.com
%
% Original author:
% Frits Wenneker (http://www.howtotex.com)
%
% License:
% CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%----------------------------------------------------------------------------------------
%   PACKAGES AND OTHER DOCUMENT CONFIGURATIONS
%----------------------------------------------------------------------------------------

\documentclass[DIV=calc, paper=a4, fontsize=11pt, twocolumn]{scrartcl}   % A4 paper and 11pt font size

\usepackage{lipsum} % Used for inserting dummy 'Lorem ipsum' text into the template
\usepackage[english]{babel} % English language/hyphenation
\usepackage[utf8]{inputenc}
\usepackage[protrusion=true,expansion=true]{microtype} % Better typography
\usepackage{amsmath,amsfonts,amsthm} % Math packages
\usepackage[svgnames,dvipsnames]{xcolor} % Enabling colors by their 'svgnames'
\usepackage[hang, small,labelfont=bf,up,textfont=it,up]{caption} % Custom captions under/above floats in tables or figures
\usepackage{booktabs} % Horizontal rules in tables
\usepackage{fix-cm}  % Custom font sizes - used for the initial letter in the document
\usepackage{framed, color}
\usepackage{url}

%%%%%%%%%%%%%%%%% Farbige box
\usepackage{tcolorbox}

%%%%%%%%%%%%%%%%%



\usepackage{sectsty} % Enables custom section titles
\allsectionsfont{\usefont{OT1}{phv}{b}{n}} % Change the font of all section commands

\usepackage{fancyhdr} % Needed to define custom headers/footers

\pagestyle{fancy} % Enables the custom headers/footers
\usepackage{lastpage} % Used to determine the number of pages in the document (for "Page X of Total")

\usepackage{mwe}% for example-image

% Headers - all currently empty
\lhead{}
\chead{}
\rhead{}

% Footers
\lfoot{}
\cfoot{}
\rfoot{\footnotesize Page \thepage\ of \pageref{LastPage}} % "Page 1 of 2"

\renewcommand{\headrulewidth}{0.0pt} % No header rule
\renewcommand{\footrulewidth}{0.4pt} % Thin footer rule

\usepackage{lettrine} % Package to accentuate the first letter of the text
\newcommand{\initial}[1]{ % Defines the command and style for the first letter
\lettrine[lines=3,lhang=0.3,nindent=0em]{
\color{OliveGreen}
{\textsf{#1}}}{}}

%----------------------------------------------------------------------------------------
%   TITLE SECTION
%----------------------------------------------------------------------------------------

\usepackage{titling} % Allows custom title configuration

\newcommand{\HorRule}{\color{OliveGreen} \rule{\linewidth}{1pt}} % Defines the gold horizontal rule around the title

\pretitle{\vspace{-30pt} \begin{flushleft} \HorRule \fontsize{50}{50} \usefont{OT1}{phv}{b}{n} \color{RawSienna} \selectfont} % Horizontal rule before the title


\title{Test Article} % Your article title

\posttitle{\par\end{flushleft}\vskip 0.5em} % Whitespace under the title

\preauthor{\begin{flushleft}\large \lineskip 0.5em \usefont{OT1}{phv}{b}{sl} \color{Black}} % Author font configuration

\author{John Doe\\} % Your name

\postauthor{\footnotesize \usefont{OT1}{phv}{m}{sl} \color{Black} % Configuration for the institution name
Sample Institute of Technology\\
% Your institution

%% logo
%\rhead{\raisebox{-2.0\height}{\includegraphics[height=40mm]{images/logo2}}}

\par\end{flushleft}\HorRule} % Horizontal rule after the title

\date{\today} % Add a date here if you would like one to appear underneath the title block

%----------------------------------------------------------------------------------------


\begin{document}
\maketitle % Print the title
\noindent\raisebox{29mm}[0pt][0pt]{\rlap{\makebox[\textwidth][r]{\includegraphics[height=30mm]{example-image}}}}

%----------------------------------------------------------------------------------------
%   ABSTRACT
%----------------------------------------------------------------------------------------

% The first character should be within \initial{}
\textbf{\lipsum[1-2]}

%----------------------------------------------------------------------------------------
%   ARTICLE CONTENTS
%----------------------------------------------------------------------------------------


\section*{Section 1}
\lipsum[1-4]

\section*{Section 2}
\lipsum[1-4]
\section*{Section 3}
\lipsum[1-4]

%----------------------------------------------------------------------------------------

\end{document}
1

There are many possibilities, here are two of them

.
.
.
.
%--- one way
%\usepackage{eso-pic}

%\newcommand\AtPageUpperMyright[1]{\AtPageUpperLeft{%
% \put(\LenToUnit{0.7\paperwidth},\LenToUnit{-5.7cm}){%
%     \parbox{0.26055\textwidth}{\raggedleft#1}}%
% }}%
%\newcommand{\mylogo}[1]{%
%\AddToShipoutPictureBG*{%
%\AtPageUpperMyright{#1}
%}
%}

%%-- another way
\usepackage{tikzpagenodes}
\newcommand{\mylogo}[1]{%
\tikz[remember picture,overlay] {%
  \node[inner sep=0pt,anchor=east] at ([yshift=-4.05cm]current page text area.north east){#1};}
  }


\begin{document}
\maketitle % Print the title
\mylogo{\includegraphics[height=30mm]{example-image-a}}
.
.
.
.
.

enter image description here

tikzpagenodes way needs at least 2-3 compilation runs to settle down.

Full code:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Large Colored Title Article
% LaTeX Template
% Version 1.1 (25/11/12)
%
% This template has been downloaded from:
% http://www.LaTeXTemplates.com
%
% Original author:
% Frits Wenneker (http://www.howtotex.com)
%
% License:
% CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%----------------------------------------------------------------------------------------
%   PACKAGES AND OTHER DOCUMENT CONFIGURATIONS
%----------------------------------------------------------------------------------------

\documentclass[DIV=calc, paper=a4, fontsize=11pt, twocolumn]{scrartcl}   % A4 paper and 11pt font size

\usepackage{lipsum} % Used for inserting dummy 'Lorem ipsum' text into the template
\usepackage[english]{babel} % English language/hyphenation
\usepackage[utf8]{inputenc}
\usepackage[protrusion=true,expansion=true]{microtype} % Better typography
\usepackage{amsmath,amsfonts,amsthm} % Math packages
\usepackage[svgnames,dvipsnames]{xcolor} % Enabling colors by their 'svgnames'
\usepackage[hang, small,labelfont=bf,up,textfont=it,up]{caption} % Custom captions under/above floats in tables or figures
\usepackage{booktabs} % Horizontal rules in tables
\usepackage{fix-cm}  % Custom font sizes - used for the initial letter in the document
\usepackage{framed, color}
\usepackage{url}

%%%%%%%%%%%%%%%%% Farbige box
\usepackage{tcolorbox}

%%%%%%%%%%%%%%%%%



\usepackage{sectsty} % Enables custom section titles
\allsectionsfont{\usefont{OT1}{phv}{b}{n}} % Change the font of all section commands

\usepackage{fancyhdr} % Needed to define custom headers/footers

\pagestyle{fancy} % Enables the custom headers/footers
\usepackage{lastpage} % Used to determine the number of pages in the document (for "Page X of Total")

% Headers - all currently empty
\lhead{}
\chead{}
\rhead{}

% Footers
\lfoot{}
\cfoot{}
\rfoot{\footnotesize Page \thepage\ of \pageref{LastPage}} % "Page 1 of 2"

\renewcommand{\headrulewidth}{0.0pt} % No header rule
\renewcommand{\footrulewidth}{0.4pt} % Thin footer rule

\usepackage{lettrine} % Package to accentuate the first letter of the text
\newcommand{\initial}[1]{ % Defines the command and style for the first letter
\lettrine[lines=3,lhang=0.3,nindent=0em]{
\color{OliveGreen}
{\textsf{#1}}}{}}



%----------------------------------------------------------------------------------------
%   TITLE SECTION
%----------------------------------------------------------------------------------------

\usepackage{titling} % Allows custom title configuration

\newcommand{\HorRule}{\color{OliveGreen} \rule{\linewidth}{1pt}} % Defines the gold horizontal rule around the title

\pretitle{\vspace{-30pt} \begin{flushleft} \HorRule \fontsize{50}{50} \usefont{OT1}{phv}{b}{n} \color{RawSienna} \selectfont} % Horizontal rule before the title


\title{Test Article} % Your article title

\posttitle{\par\end{flushleft}\vskip 0.5em} % Whitespace under the title

\preauthor{\begin{flushleft}\large \lineskip 0.5em \usefont{OT1}{phv}{b}{sl} \color{Black}} % Author font configuration

\author{John Doe\\} % Your name

\postauthor{\footnotesize \usefont{OT1}{phv}{m}{sl} \color{Black} % Configuration for the institution name
Sample Institute of Technology\\
% Your institution

%% logo
%\rhead{\raisebox{-2.0\height}{\includegraphics[height=40mm]{images/logo2}}}

\par\end{flushleft}\HorRule} % Horizontal rule after the title

\date{\today} % Add a date here if you would like one to appear underneath the title block

%----------------------------------------------------------------------------------------


%--- one way
%\usepackage{eso-pic}

%\newcommand\AtPageUpperMyright[1]{\AtPageUpperLeft{%
% \put(\LenToUnit{0.7\paperwidth},\LenToUnit{-5.7cm}){%
%     \parbox{0.26055\textwidth}{\raggedleft#1}}%
% }}%
%\newcommand{\mylogo}[1]{%
%\AddToShipoutPictureBG*{%
%\AtPageUpperMyright{#1}
%}
%}

%%-- another way
\usepackage{tikzpagenodes}
\newcommand{\mylogo}[1]{%
\tikz[remember picture,overlay] {%
  \node[inner sep=0pt,anchor=east] at ([yshift=-4.05cm]current page text area.north east){#1};}
  }


\begin{document}
\maketitle % Print the title
\mylogo{\includegraphics[height=30mm]{example-image-a}}



%\thispagestyle{firststyle} % Enabling the custom headers/footers for the first page

%----------------------------------------------------------------------------------------
%   ABSTRACT
%----------------------------------------------------------------------------------------

% The first character should be within \initial{}
\textbf{\lipsum[1-2]}

%----------------------------------------------------------------------------------------
%   ARTICLE CONTENTS
%----------------------------------------------------------------------------------------

\section*{Section 1}
\lipsum[1-4]




\section*{Section 2}
\lipsum[1-4]
%\thispagestyle{second} % Enabling the custom headers/footers for the first page
\section*{Section 2}
\lipsum[1-4]

%----------------------------------------------------------------------------------------

\end{document}

As a side note, you have packages, which, are not ideal to be used with koma classes, like sectsty. koma classes have their own way of providing these functionalities.

1
  • Hi. Your suggestion was the fastest and it also works. I decided to accept the answer from John Kormylo as it is more compact. Thank you very much as well!
    – Stefan
    Commented Apr 15, 2015 at 8:36
1

I understand that the desired image only should appear inside title, so following solution makes use of \maketitlehook commands from titling package to build the title within two vertically centered minipages, one for title and author and the second one for the image. This way there's no need for setting different pages styles.

\maketitle command is redefined by titling package like

\renewcommand{\maketitle}{%
\vspace*{\droptitle}
\maketitlehooka
{\pretitle \title \posttitle}
\maketitlehookb
{\preauthor \author \postauthor}
\maketitlehookc
{\predate \date \postdate}
\maketitlehookd
}

\maketitlehook{a|b|c|d}´ are initially defined as empty commands but can be used to introduce more formatting options. In this case,\maketitlehooka` is used to draw toprule and start a minipage where title and authors will be written

\renewcommand{\maketitlehooka}{\HorRule\\[2ex]\begin{minipage}[c]{.7\linewidth}}

and \maketitlehookc is used to close left minipage and create a right one where figure is placed:

\renewcommand{\maketitlehookc}{\end{minipage}\begin{minipage}[c]{.3\linewidth}%
      \includegraphics[width=\textwidth]{example-image}%
      \end{minipage}\\[2ex]\HorRule}

In previous command, example-image must be replaced by the desired one. Also space between rules and title ([2ex]) and minipages width can be adjusted as needed.

The result looks like:

enter image description here

The complete code is:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Large Colored Title Article
% LaTeX Template
% Version 1.1 (25/11/12)
%
% This template has been downloaded from:
% http://www.LaTeXTemplates.com
%
% Original author:
% Frits Wenneker (http://www.howtotex.com)
%
% License:
% CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%----------------------------------------------------------------------------------------
%   PACKAGES AND OTHER DOCUMENT CONFIGURATIONS
%----------------------------------------------------------------------------------------

\documentclass[DIV=calc, paper=a4, fontsize=11pt, twocolumn]{scrartcl}   % A4 paper and 11pt font size

\usepackage{lipsum} % Used for inserting dummy 'Lorem ipsum' text into the template
\usepackage[english]{babel} % English language/hyphenation
\usepackage[utf8]{inputenc}
\usepackage[protrusion=true,expansion=true]{microtype} % Better typography
\usepackage{amsmath,amsfonts,amsthm} % Math packages
\usepackage[svgnames,dvipsnames]{xcolor} % Enabling colors by their 'svgnames'
\usepackage[hang, small,labelfont=bf,up,textfont=it,up]{caption} % Custom captions under/above floats in tables or figures
\usepackage{booktabs} % Horizontal rules in tables
\usepackage{fix-cm}  % Custom font sizes - used for the initial letter in the document
\usepackage{framed, color}
\usepackage{url}

%%%%%%%%%%%%%%%%% Farbige box
\usepackage{tcolorbox}

%%%%%%%%%%%%%%%%%

\usepackage{sectsty} % Enables custom section titles
\allsectionsfont{\usefont{OT1}{phv}{b}{n}} % Change the font of all section commands

\usepackage{fancyhdr} % Needed to define custom headers/footers

\pagestyle{fancy} % Enables the custom headers/footers
\usepackage{lastpage} % Used to determine the number of pages in the document (for "Page X of Total")

% Headers - all currently empty
\lhead{}
\chead{}
\rhead{}

% Footers
\lfoot{}
\cfoot{}
\rfoot{\footnotesize Page \thepage\ of \pageref{LastPage}} % "Page 1 of 2"

\renewcommand{\headrulewidth}{0.0pt} % No header rule
\renewcommand{\footrulewidth}{0.4pt} % Thin footer rule

\usepackage{lettrine} % Package to accentuate the first letter of the text
\newcommand{\initial}[1]{ % Defines the command and style for the first letter
\lettrine[lines=3,lhang=0.3,nindent=0em]{
\color{OliveGreen}
{\textsf{#1}}}{}}

%----------------------------------------------------------------------------------------
%   TITLE SECTION
%----------------------------------------------------------------------------------------

\usepackage{titling} % Allows custom title configuration

\newcommand{\HorRule}{\color{OliveGreen} \rule{\linewidth}{1pt}} % Defines the gold horizontal rule around the title

\setlength{\droptitle}{30pt}
\renewcommand{\maketitlehooka}{\HorRule\\[2ex]
\begin{minipage}[c]{.7\linewidth}}

\renewcommand{\maketitlehookc}{\end{minipage}\begin{minipage}[c]{.3\linewidth}\includegraphics[width=\textwidth]{example-image}\end{minipage}\\[2ex]\HorRule}

\pretitle{\begin{flushleft}\fontsize{50}{50} \usefont{OT1}{phv}{b}{n} \color{RawSienna} \selectfont} % Horizontal rule before the title

\title{Test Article} % Your article title

\posttitle{\par\end{flushleft}\vskip 0.5em} % Whitespace under the title

\preauthor{\begin{flushleft}\large \lineskip 0.5em \usefont{OT1}{phv}{b}{sl} \color{Black}} % Author font configuration

\author{John Doe\\} % Your name

\postauthor{\footnotesize \usefont{OT1}{phv}{m}{sl} \color{Black} % Configuration for the institution name
Sample Institute of Technology\\
% Your institution

%% logo
%\rhead{\raisebox{-2.0\height}{\includegraphics[height=40mm]{images/logo2}}}
\end{flushleft}} % Horizontal rule after the title

\date{\today} % Add a date here if you would like one to appear underneath the title block

%----------------------------------------------------------------------------------------


%\fancypagestyle{firststyle}
%{
%  \fancyhf{}
%%  \rhead{\raisebox{-2.2\height}{\includegraphics[height=30mm]{example-image}}}
%}

%\fancypagestyle{second}{%
 \fancyhead{}
%}

\begin{document}

\maketitle % Print the title

%\thispagestyle{firststyle} % Enabling the custom headers/footers for the first page 

%----------------------------------------------------------------------------------------
%   ABSTRACT
%----------------------------------------------------------------------------------------

% The first character should be within \initial{}
\textbf{\lipsum[1-2]}

%----------------------------------------------------------------------------------------
%   ARTICLE CONTENTS
%----------------------------------------------------------------------------------------


\section*{Section 1}
\lipsum[1-4]




\section*{Section 2}
\lipsum[1-4]
%\thispagestyle{second} % Enabling the custom headers/footers for the first page 
\section*{Section 2}
\lipsum[1-4]

%----------------------------------------------------------------------------------------

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .