[Tex/LaTex] Position a full width logo in scrlttr2 header

header-footerscrlttr2

How can I position a fullwidth logo in the top left corner of my scrlttr2 document? The following code leaves a small but noticable gap.

\documentclass[12pt,ngerman]{scrlttr2}
\usepackage{babel}
\setkomavar{fromname}{Just me}

\makeatletter
\@setplength{firstheadhpos}{0mm}
\@setplength{firstheadvpos}{0mm}
\makeatother

\firsthead{
\rule{\paperwidth}{3cm}
}

\begin{document}
\begin{letter}{John Doe \\ Berlin}
\opening{Dear John,}

\closing{Mit freundlichen Scherzen,}

\end{letter}
\end{document}

scrlttr2

Best Answer

The problem is that

\firsthead{
\rule{\paperwidth}{3cm}
}

adds horizontal space if you don't avoid it putting a % after \firsthead{, so you would have to write

\firsthead{%
\rule{\paperwidth}{3cm}
}

Moreover, the use of \firsthead is deprecated. You should use the following syntax instead:

\setkomavar{firsthead}{%
\rule{\paperwidth}{3cm}%
}

Complete MWE

\documentclass[12pt,ngerman]{scrlttr2}
\usepackage{babel}
\setkomavar{fromname}{Just me}

\makeatletter
\@setplength{firstheadhpos}{0mm}
\@setplength{firstheadvpos}{0mm}
\makeatother

\setkomavar{firsthead}{%
\rule{\paperwidth}{3cm}%
}

\begin{document}
\begin{letter}{John Doe \\ Berlin}
\opening{Dear John,}

\closing{Mit freundlichen Scherzen,}

\end{letter}
\end{document} 

Output:

enter image description here