5

I use this class definition in the preamble of my document:

\documentclass[template, 
           backaddress=off, 
           foldmarks=false, 
           enlargefirstpage,
           pagenumber=off,
           parskip=half
           ]{scrlttr2}

I set the header with logo on the left and information on the right like this:

\firsthead{ 
\parbox[b]{\textwidth}{\raggedleft{ 
\rlap{\usekomavar{fromlogo}}
  \addfontfeature{LetterSpace=20.0}\fontsize{12}{17}\selectfont\scshape \usekomavar{fromname}\\[3mm]
     \fontsize{11}{11}\selectfont\scshape \usekomavar{position} \\ \usekomavar{department}
     }%
   }% 
}%

Yet the logo and return address are not aligned. In any other class I could use the fancyhdr package to specify left and right head like this:

\usepackage{fancyhdr}
\setlength{\headheight}{1cm}
\setlength{\headwidth}{\textwidth}
\fancyhead[L]{ % left
\addfontfeature{LetterSpace=20.0}\fontsize{12}{17}\selectfont\scshape
\usekomavar{fromname}\\[3mm]
    \fontsize{11}{11}\selectfont\scshape \usekomavar{position} \\
\usekomavar{department}
}
 \fancyhead[R]{ % right
 \includegraphics[width=4cm]{kuleuven_zwart.eps}
}
\pagestyle{fancy}

yet this won't work for the letter class. How can I achieve something similar?


Template code:

\ProvidesFile{template.lco}

\usepackage{graphicx}   
\usepackage{fontspec}
\usepackage{marvosym}
\usepackage{eso-pic}
\usepackage{geometry} 
\geometry{a4paper, textwidth=17cm, textheight=22cm, marginparsep=16cm, marginparwidth=1cm}

\newkomavar{department}
\newkomavar{position}
\setkomavar{fromlogo}{\includegraphics[width=4cm]{kuleuven_zwart.eps}}

% ===  FORMATTING STUFF
\@setplength{backaddrheight}{0cm}

% shift the page body on the left to make room for data and logo
\setlength{\oddsidemargin}{\useplength{toaddrhpos}}
\addtolength{\oddsidemargin}{-1in}
\l@addto@macro{\@typearea@end}{
\setlength{\oddsidemargin}{\useplength{toaddrhpos}}
\addtolength{\oddsidemargin}{-1in}
}%

%set the font size and leading
\renewcommand{\normalsize}{\fontsize{10.0}{17}\selectfont}

% === HEADER DEFINITION
\firsthead{ 

 \parbox[b]{\textwidth}{\raggedleft{ 

    \rlap{\usekomavar{fromlogo}}

      \addfontfeature{LetterSpace=20.0}\fontsize{12}{17}\selectfont\scshape \usekomavar{fromname}\\[5mm]
         \fontsize{11}{11}\selectfont\scshape \usekomavar{position} \\ \usekomavar{department}

    }%
  }%

}%

\endinput

Document:

\documentclass[template, 
               backaddress=off, 
               foldmarks=false, 
               pagenumber=off,
               ]{scrlttr2}

\usepackage{lipsum}   

\setkomavar{fromname}{this}
\setkomavar{position}{is not}
\setkomavar{department}{aligned}
\begin{document}

\begin{letter}{%
       Yeti\\%
      from Himalayah\\%
}

\opening{Dear,}

\lipsum

\closing{Regards,}


\end{letter}
\end{document}
3

I would suggest you to use two \parboxes (one for the logo and the other one for the information on the right), and the \adjustbox commad from the adjust box package to control the vertical alignment with respect to the logo; also beware of superfluous blank spaces:

\ProvidesFile{template.lco}

\usepackage{graphicx}   
\usepackage{fontspec}
\usepackage{marvosym}
\usepackage{eso-pic}
\usepackage{geometry} 
\usepackage{adjustbox}
\geometry{a4paper, textwidth=17cm, textheight=22cm, marginparsep=16cm, marginparwidth=1cm}

\newkomavar{department}
\newkomavar{position}
\setkomavar{fromlogo}{\adjustbox{valign=t}{\includegraphics[width=4cm]{kuleuven_zwart.eps}}}

% ===  FORMATTING STUFF
\@setplength{backaddrheight}{0cm}

% shift the page body on the left to make room for data and logo
\setlength{\oddsidemargin}{\useplength{toaddrhpos}}
\addtolength{\oddsidemargin}{-1in}
\l@addto@macro{\@typearea@end}{
\setlength{\oddsidemargin}{\useplength{toaddrhpos}}
\addtolength{\oddsidemargin}{-1in}
}%

%set the font size and leading
\renewcommand{\normalsize}{\fontsize{10.0}{17}\selectfont}

% === HEADER DEFINITION
\firsthead{% 
 \parbox[t]{0.5\textwidth}{% 
    \usekomavar{fromlogo}}\parbox[t]{0.5\textwidth}{\raggedleft{
      \addfontfeature{LetterSpace=20.0}\fontsize{12}{17}\selectfont\scshape \usekomavar{fromname}\\[5mm]
         \fontsize{11}{11}\selectfont\scshape \usekomavar{position} \\ \usekomavar{department}%
    }%
  }%
}%

\endinput

Here's a partial image of the result of your example code, using the CTAN lion (drawing by Duane Bibby) as image:

enter image description here

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.