11

I would like to include a graphics file with a logo in the header of all pages of a twoside document (left and right side). The logo should be left-justified on the left side and right-justified on the right side. The header line and the document title should begin beside the logo. There are two 2 Problems:

  • Moving the beginning of header line and document title a litte to the right (left side) and left (right side) to create space for the logo
  • Include the logo

Do you have any suggestions? Here is my code:

\documentclass[
   12pt,               
   a4paper,             
   twoside,                         
   headinclude,         
   headsepline,                 
   BCOR12mm,                        
   DIV12,               
   openright,             
   bibliography=totoc,            
   listof=totoc,                
   numbers=noenddot,
   fleqn,               
        ]{scrbook}

\usepackage[latin1]{inputenc}    
\usepackage[T1]{fontenc}         
\usepackage[ngerman, english]{babel}        
\usepackage{lipsum}

\usepackage{xcolor}                     
\definecolor{grey} {RGB} {132,130,132}

\usepackage{scrpage2}             

\setkomafont{pageheadfoot}{\color{grey}{\normalfont\sffamily}}
\setkomafont{pagenumber}{\color{grey}{\normalfont\sffamily}}
\setheadsepline{1pt}[\color{grey}]

\clearscrheadfoot                                                       
\pagestyle{scrheadings}
\rehead[ ]{Document title}              
\lohead[ ]{Document title}              
\lehead[ ]{\headmark}                   
\rohead[ ]{\headmark}                        
\refoot[\pagemark]{\pagemark}     
\lofoot[\pagemark]{\pagemark}     

\begin{document}

\section{section title}

\lipsum[1-9]

\end{document}

Thank your for your comments and answers. I have already tried the above solution (just including the graphics), but was not happy with the result because:

  • the line is also unter the logo
  • document title and section title have different heights

This time I include a layout draft (the picture in the layout is a substitute for the logo). The measurements of the final logo will be: height=15 mm, width=20 mm (or 79x61 pixel).

enter image description here

The Document title is "Yaacomo". In the header there should be no text and no line under the logo.

2
  • Could you provide a link to the logo or otherwise say something about the image dimensions? I would include it into \rehead resp. \lohead, but very likely the headheight must be enlarged.
    – Speravir
    Oct 29, 2012 at 17:11
  • 1
    Related Question: Place a TikZ picture on every page. You can use \ifoddpage to adjust the location of the logo depending on which type of page you are on. Oct 29, 2012 at 18:18

2 Answers 2

7

A first try can be to include package graphicx for macro \includegraphics and change your configuration for the header to:

\usepackage{graphicx} % for macro \includegraphics
\rehead[ ]{Document title \includegraphics[height=8mm]{example-image-A.jpg}}              
\lohead[ ]{\includegraphics[height=8mm]{example-image-A.jpg} Document title} 

Btw: example-image-A.jpg is part of the package MWE, very useful for building MWEs ...

2
  • Exactly my intention, cf. my comment under the question.
    – Speravir
    Oct 29, 2012 at 17:34
  • See my answer now.
    – Speravir
    Nov 1, 2012 at 22:16
3

My solution:

I added the packages graphicx for image inclusion, calc to be able to do some calculation, and adjustbox for adding some margin, which is needed, because otherwise the headsepline would touch the logo.

I defined some lengthes; see under %Logo, perhaps you want to change them. This is also the place for your actual logo.

The head itself is now only in \cehead resp. \cohead. So it is ensured, that everything is in the same line.

All together, the package blindtext is only for, ehem, blindtext (\Blinddocument here):

\documentclass[
  paper=a4, % it's the default anyway
  fontsize=12pt,
  twoside,
  headinclude,
  headsepline,
  BCOR=12mm,
  DIV=12,
  openright,
  bibliography=totoc,
  listof=totoc,
  numbers=noenddot,
  fleqn,
  ]{scrbook}

\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman, english]{babel}

\usepackage{blindtext} % provides blindtext with sectioning

\usepackage{calc} % for some calculation

\usepackage{xcolor}
\definecolor{grey} {RGB} {132,130,132}

\usepackage{graphicx}% for loading images
\usepackage[calc]{adjustbox} % we need some margin around the logo, for option see manual

% Logo
\newlength{\logoheight}\setlength{\logoheight}{15mm} % Adjust height of logo here
\newlength{\logowidth}\setlength{\logowidth}{20mm} % Adjust width of logo here

\newcommand*{\logo}{\raisebox{-5pt}% The bigger the amount of the negative number the more the header is raised!
{\includegraphics[height=\logoheight,width=\logowidth]{example-image-4x3.png}}}

\newlength{\extramargin}\setlength{\extramargin}{5pt} % Change to your needs

\setlength{\headheight}{\logoheight}
% This won't work (!!!):
%%% \KOMAoptions{headheight=\logoheight}

\usepackage{scrpage2}

\setkomafont{pageheadfoot}{\color{grey}{\normalfont\sffamily}}
\setkomafont{pagenumber}{\color{grey}{\normalfont\sffamily}}
\setheadsepline{1pt}[\color{grey}]

\setheadwidth[\logowidth+\extramargin]{\textwidth-\logowidth-\extramargin} % for calculation "calc" is needed

\clearscrheadfoot
\pagestyle{scrheadings}
%\rehead[]{Yaacomo}
\cehead[]{\headmark\hfill Yaacomo \rlap{\adjustbox{margin={\extramargin} 0pt 0pt 0pt}{\logo}}}
%\lohead[]{Yaacomo}
\cohead[]{\llap{\adjustbox{margin=0pt 0pt {\extramargin} 0pt}{\logo}}\ Yaacomo\hfill\headmark}
%\lehead[]{\headmark}
%\rohead[]{\headmark}
\refoot[\pagemark]{\pagemark}
\lofoot[\pagemark]{\pagemark}

\begin{document}

\Blinddocument

\end{document}

appearance

You must log in to answer this question.

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