2

I am using scrlttr2 to write the letter (code below). The header and footer appear correctly on the first page but on the second page and so on, the layout is not the way it should be ... that is header is scrambled and footer is in italics and is at incorrect position.

Can anyone help correct the code? Thanks

\documentclass[
    fontsize=11pt,          % fontsize
    paper=a4,               % page size a4
    firsthead=on,           % display header on first page
    firstfoot=on,           % display footer on first page
    pagenumber=off,         % position of the page number
    parskip=half,           % Use indent instead of skip, half, false
    enlargefirstpage=on,    % more space on first page
    fromalign=left,         % placement of name in letter head
    fromrule=afteraddress,  % separate the address with a line in letter head, false or aftername
    fromemail=off,          % turn on email of sender
    fromurl=off,            % print URL of sender
    fromphone=off,          % turn on phone of sender
    fromlogo=off,           % turn on logo of sender
    addrfield=on,           % address field for envelope with window, on or true
    subject=titled,         % placement of subject, beforeopening or titled
    foldmarks=off,          % print foldmarks
    numericaldate=off,      % display date in numbers only
    KOMAold]{scrlttr2}

% http://mirrors.ctan.org/macros/latex/contrib/koma-script/doc/scrguien.pdf

\usepackage[T1]{fontenc}
\usepackage[dvips]{graphicx}
\usepackage[english]{babel}
\usepackage{lipsum}
\usepackage{lmodern}
\usepackage{lastpage}
\usepackage[rgb]{xcolor}
\usepackage{hyperref}
\hypersetup{%
    pdfborder=0 0 0,
    pdfauthor={},
    pdftitle={},
    pdfsubject={},
    pdfkeywords={},
    pdfpagemode={UseOutlines},
    bookmarksopen,
    pdfstartview={FitH},
    colorlinks,
    linkcolor={blue},
    citecolor={red},
    urlcolor={blue}
  }

% Information in the header
\firsthead{\parbox[b]{\linewidth}{\noindent
    \fbox{
%        \includegraphics[width=0.1\linewidth]{logo.eps}
    }
  \hfill
    \fbox{
        \parbox[b]{0.5\linewidth}{\centering University \\ 123 Street, \\ City, State 12345}
    }
  \hfill
    \fbox{
%        \includegraphics[width=0.1\linewidth]{logo.eps}
    }
    }
    \vspace*{0.5ex}
%    \hrule\hrule
    \vspace*{0.5ex}
    \centering\scriptsize{Institute or Corporation}}

\nexthead{\parbox[b]{\linewidth}{\noindent
    \fbox{
%        \includegraphics[width=0.1\linewidth]{logo.eps}
    }
  \hfill
    \fbox{
        \parbox[b]{0.5\linewidth}{\centering University \\ 123 Street, \\ City, State 12345}
    }
  \hfill
    \fbox{
%        \includegraphics[width=0.1\linewidth]{logo.eps}
    }
    }
    \vspace*{0.5ex}
%    \hrule\hrule
    \vspace*{0.5ex}
    \centering\scriptsize{Institute or Corporation}}

% Information in the footer
\firstfoot{\parbox[b]{\linewidth}{\hrule\vspace*{0.5ex}\centering\scriptsize{name | organization | phone | email | web | copyright number: 12\,345\,678 \hfill \textcolor{blue}{\thepage}/\pageref{LastPage}}}}
\nextfoot{\parbox[b]{\linewidth}{\hrule\vspace*{0.5ex}\centering\scriptsize{name | organization | phone | email | web | copyright number: 12\,345\,678 \hfill \textcolor{blue}{\thepage}/\pageref{LastPage}}}}

% \removereffields % removes reference fields
% \makeatletter
% \@setplength{refvpos}{\useplength{toaddrvpos}}
% \makeatletter

\setkomavar{location}{\hspace{4em}\parbox[b]{\textwidth}{\today \\  Ref. No.}}
\setkomavar{customer}[]{Through proper channel}
\setkomavar{date}[]{} % Removes date

\makeatletter
\@setplength{sigbeforevskip}{8ex} % 0ex space after the signature
\makeatother

\makeatletter
\@addtoplength{firstheadvpos}{0mm} % 4.5mm position of header
\@addtoplength{firstfootvpos}{0mm} % -8mm or -1ex position of footer
\makeatother

\setkomavar{subject}{title of the subject}

% \setkomafont{title}{\normalfont\rmfamily\bfseries\Large} % changes the font of title
% \setkomavar{title}{\MakeUppercase{To whom it may concern}}

\begin{document}
\pagestyle{myheadings}

\setkomavar{fromname}{Your Name,\newline 123 Street, \newline City, State 12345 \\[0.5ex] Email: username@domain.com \\ Phone: +00-123-456-7890} % Your name
\setkomavar{fromaddress}{123 Street, \\ City, State 12345}
\setkomavar{fromemail}{username@domain.com}
\setkomavar{fromphone}{+00-123-456-7890}
\setkomavar{signature}{\usekomavar{fromname}}

\begin{letter}{Director, \\ Corporation, \\ 123 Street, \\ City, State 12345} % Addressee name and address
\vspace*{0ex} % Correct for vertical displacement
\opening{Dear Sir/Madam,}

\lipsum[3-8] % generates dummy text, scratch that and write the letter contents

\closing{Sincerely,}

\cc{Chancellor, 123 Street, City, State 12345}

\end{letter}
\end{document} 
2

Use scrpage2 package instead of \nexthead or \nextfoot to solve the problem.

\usepackage{scrpage2}
\pagestyle{scrheadings}
\clearscrheadfoot
\ohead{\headbox}
\ofoot{\footbox}

Head height can be adjusted with the following command;

\setlength{\headsep}{4.5cm}

Whereas text height is adjusted in case the text overlaps the footer with following command;

\setlength{\textheight}{8in}

Modified Code;

\documentclass[
    fontsize=11pt,          % fontsize
    paper=a4,               % page size a4
    firsthead=on,           % display header on first page
    firstfoot=on,           % display footer on first page
    pagenumber=off,         % position of the page number
    parskip=half,           % Use indent instead of skip, half, false
    enlargefirstpage=on,    % more space on first page
    fromalign=left,         % placement of name in letter head
    fromrule=afteraddress,  % separate the address with a line in letter head, false or aftername
    fromemail=off,          % turn on email of sender
    fromurl=off,            % print URL of sender
    fromphone=off,          % turn on phone of sender
    fromlogo=off,           % turn on logo of sender
    addrfield=on,           % address field for envelope with window, on or true
    subject=titled,         % placement of subject, beforeopening or titled
    foldmarks=off,          % print foldmarks
    numericaldate=off,      % display date in numbers only
    KOMAold]{scrlttr2}

% http://mirrors.ctan.org/macros/latex/contrib/koma-script/doc/scrguien.pdf

\usepackage[T1]{fontenc}
\usepackage[dvips]{graphicx}
\usepackage[english]{babel}
\usepackage{lipsum}
\usepackage{lmodern}
\usepackage{lastpage}
\usepackage[rgb]{xcolor}
\usepackage{hyperref}
\hypersetup{%
    pdfborder=0 0 0,
    pdfauthor={},
    pdftitle={},
    pdfsubject={},
    pdfkeywords={},
    pdfpagemode={UseOutlines},
    bookmarksopen,
    pdfstartview={FitH},
    colorlinks,
    linkcolor={blue},
    citecolor={red},
    urlcolor={blue}
  }

% Information in the header
\newcommand*{\headbox}{
\usekomafont{pagenumber}
  \parbox[b]{\linewidth}{\noindent
  \fbox{
%    \includegraphics[width=0.12\linewidth]{logo.eps}
    }
  \hfill
  \fbox{
    \parbox[b]{0.5\linewidth}{\centering University \\ 123 Street, \\ City, State 12345}
    }
  \hfill
  \fbox{
%    \includegraphics[width=0.12\linewidth]{logo.eps}
   } 
}
  \newline
   \vspace*{1.5ex}
    \centering
   \scriptsize{Institute or Corporation}
}
\firsthead{\headbox}

% Information in the footer
\newcommand*{\footbox}{
\usekomafont{pagenumber}
\parbox[b]{\linewidth}{\hrule\vspace*{0.5ex}\centering\scriptsize{name | organization | phone | email | web | copyright number: 12\,345\,678 \hfill \textcolor{blue}{\thepage}/\pageref{LastPage}}}
}
\firstfoot{\footbox}

\setlength{\headsep}{4.5cm}
\setlength{\textheight}{8in}

\usepackage{scrpage2}
\pagestyle{scrheadings}
\clearscrheadfoot
\ohead{\headbox}
\ofoot{\footbox}

% \removereffields % removes reference fields
% \makeatletter
% \@setplength{refvpos}{\useplength{toaddrvpos}}
% \makeatletter

\setkomavar{location}{\hspace{4em}\parbox[b]{\textwidth}{\today \\  Ref. No.}}
\setkomavar{customer}[]{Through proper channel}
\setkomavar{date}[]{} % Removes date

\makeatletter
\@setplength{sigbeforevskip}{8ex} % 0ex space after the signature
\makeatother

\makeatletter
\@addtoplength{firstheadvpos}{0mm} % 4.5mm position of header
\@addtoplength{firstfootvpos}{0mm} % -8mm or -1ex position of footer
\makeatother

\setkomavar{subject}{title of the subject}

% \setkomafont{title}{\normalfont\rmfamily\bfseries\Large} % changes the font of title
% \setkomavar{title}{\MakeUppercase{To whom it may concern}}

\begin{document}

\setkomavar{fromname}{Your Name,\newline 123 Street, \newline City, State 12345 \\[0.5ex] Email: username@domain.com \\ Phone: +00-123-456-7890} % Your name
\setkomavar{fromaddress}{123 Street, \\ City, State 12345}
\setkomavar{fromemail}{username@domain.com}
\setkomavar{fromphone}{+00-123-456-7890}
\setkomavar{signature}{\usekomavar{fromname}}

\begin{letter}{Director, \\ Corporation, \\ 123 Street, \\ City, State 12345} % Addressee name and address
\vspace*{0ex} % Correct for vertical displacement
\opening{Dear Sir/Madam,}

\lipsum[3-18] % generates dummy text, scratch that and write the letter contents

\closing{Sincerely,}

\cc{Chancellor, 123 Street, City, State 12345}

\end{letter}
\end{document}
2

Just add the option

headheight=3cm,

to your long list of options of scrlttr2.

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.