# Image in margin beside header

I would like to add an image in the margin beside the header. The bottom of the image should be align with the header baseline. In my MWE (see below) the top of the image is adjusted with the header top.

How can I adjust the image at the baseline?

Do you suggest other improvements? E.g. does it make sense to use marginnote in ihead?

MWE:

\documentclass{scrreprt}

\usepackage{blindtext, graphicx, marginnote}
\usepackage[twoside = true]{geometry}

\marginnote{%
\includegraphics[width=\marginparwidth]{example-image-a}%
}
}

\begin{document}
\Blinddocument
\end{document}


I would not use marginnote but only scrlayer-scrpage:

\documentclass{scrreprt}

\usepackage{mwe,graphicx}
\usepackage[twoside = true]{geometry}

\begin{document}
\Blinddocument
\end{document}


You could also add your own layer to the page style scrheadings and if you want the image also on plain pages to plain.scrheadings:

\documentclass{scrreprt}

\usepackage{mwe,graphicx}
\usepackage[twoside = true]{geometry}

\DeclareNewLayer[background,
width=\marginparwidth,% optional reduce layer width
contents={\includegraphics[width=\marginparwidth]{example-image-a}}]{image}

\begin{document}
\Blinddocument
\end{document}


The result is the same, but you do not need to split of \ihead into \lehead and \rohead. And you just have to activate the single commented line to activate the image for plain pages.

BTW: I would suggest to put the image one time into a box and use the box on each page:

\documentclass{scrreprt}

\usepackage{mwe,graphicx}
\usepackage[twoside = true]{geometry}

\DeclareNewLayer[background,
width=\marginparwidth,

\begin{document}
\Blinddocument
\end{document}


And if the code should place the logo always to the right side in single-side mode:

\documentclass{scrreprt}
%\documentclass[twoside]{scrreprt}

\usepackage{mwe,graphicx}
\usepackage{geometry}

\makeatletter
\DeclareNewLayer[background,
width=\marginparwidth,
\makeatother

\begin{document}
\Blinddocument
\end{document}


But in this case it could be easier to use different layers for left and right pages:

\documentclass{scrreprt}
%\documentclass[twoside]{scrreprt}

\usepackage{mwe,graphicx}
\usepackage{geometry}

\DeclareNewLayer[background,
oddpage,% for right pages in double-side mode or all pages in single-side mode
width=\marginparwidth,
\DeclareNewLayer[background,
evenpage,% for left pages in double-side mode

• Thanks, that works like a charm! Do you have a suggestion to optimise addhoffset for twoside=false? – Dirk Apr 27 '17 at 8:54
• How big is the benefit to use a savebox? – Dirk Apr 27 '17 at 9:03
• @Dirk With the savebox the \includegraphics code is expanded only once while the \sbox. Without it has to be expanded on every page. So if you have only one page there wouldn't be a benefit but if you have thousand pages … I like to do things once and use them often independent from any obvious benefit. – Schweinebacke May 2 '17 at 6:32