2

I'd like to create a very basic letter template with a "heading" part (address information, location and date) and a text part. The heading part should always have the same height and the same format. I'd like to put these formatting information in a macro which should use some auxiliary macros containing the sender and receiver data.

If you compile the LaTeX example below to PDF, and open it with a PDF reader and put the two pages next to each other, you will notice that the position of the corresponding lines perfectly match. However if you enable the dummy texts after the heading macro the the heading lines do not match anymore. The largest difference (about 0.5 line height) is by the "extra line1" at the receiver field.

How can I force LaTeX to use the same line height for the heading part, independently from the text part?

What I have tried so far:

  • Push the lines to the right using flushright and makebox.
  • Push the lines to the right using hspace.
  • Put everything on a minipage with fixed height.
  • Put the groups (sender data, and receiver data) on a minipage and put the minipages in a tabular.
  • Put every lines separately in a tabular line.

None of these worked for me. I get uneven line position in all cases when the texts are enabled. Does any of you have an idea what else can I try? :)

I would be grateful for any hint.

\documentclass[11pt,a4paper]{letter}

% include standard packages
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\absndA}{Sender Name}
\newcommand{\absndB}{Sender Address 01}
\newcommand{\absndC}{POSTCODE City}
\newcommand{\absndD}{extra line1}
\newcommand{\absndE}{extra line2}

\newcommand{\empfgA}{Receiver Company}
\newcommand{\empfgB}{Receiver Name}
\newcommand{\empfgC}{Receiver street 12}
\newcommand{\empfgD}{POSTCODE City}
\newcommand{\empfgE}{extra line1}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% set the the 2 offsets to 0
\addtolength\voffset      {-1.0  in}
\addtolength\hoffset      {-1.0  in}

\setlength\oddsidemargin  { 2.5  cm}
\setlength\evensidemargin { 2.5  cm}

\setlength\topmargin      { 0.5  cm}
\setlength\headheight     { 0.5  cm}
\setlength\headsep        { 0.5  cm}

\setlength\textheight     {27.2  cm}
\setlength\textwidth      {16.0  cm}

\addtolength\parskip      { 3.0  mm}
\setlength\parindent      { 0.0  mm}

\newlength{\tabcolsepTmp}

% set default font to sans
\renewcommand{\familydefault}{\sfdefault}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\headerTypeB}{%
\setlength{\tabcolsepTmp}{\tabcolsep}%
\setlength{\tabcolsep}{0pt}%
\begin{tabular}{p{0.7\textwidth}p{0.3\textwidth}}%
%& \begin{minipage}[t][7\normalbaselineskip][t]{\textwidth}%
& \absndA\\%
& \absndB\\%
& \absndC\\%
& \absndD\\%
& \absndE\\%
%\end{minipage}\\%
\multicolumn{2}{l}{%
\begin{minipage}[t][7\normalbaselineskip][t]{\textwidth}%
\empfgA\\%
\empfgB\\%
\empfgC\\%
\empfgD\\%
\empfgE%
\end{minipage}%
} \\%
\multicolumn{2}{r}{Location, \today}\\%
\end{tabular}%
\setlength{\tabcolsep}{\tabcolsepTmp}%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\headerTypeB

%\large{Greeting}
%
%text
%
%text2

\newpage

\headerTypeB

%some text
%
%more text

\end{document}
2

You misuse the \large macro. It does not take an argument, as in \large{Greeting}, but is a declaration that sets the new font size for all subsequent text to the end of the current group.

To limit its scope, enclose the scope in braces. Also, an end-of-paragraph \par is needed in the group to bring the \large into force. Thus, you will see that the prior usage has been modified to {\large Greeting\par}.

In effect, the original incorrect invocation changed the size of the text to \large for the remainder of the document. See pp. 115-116 of the LaTeX user Guide and Reference Manual.

\documentclass[11pt,a4paper]{letter}

% include standard packages
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\absndA}{Sender Name}
\newcommand{\absndB}{Sender Address 01}
\newcommand{\absndC}{POSTCODE City}
\newcommand{\absndD}{extra line1}
\newcommand{\absndE}{extra line2}

\newcommand{\empfgA}{Receiver Company}
\newcommand{\empfgB}{Receiver Name}
\newcommand{\empfgC}{Receiver street 12}
\newcommand{\empfgD}{POSTCODE City}
\newcommand{\empfgE}{extra line1}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% set the the 2 offsets to 0
\addtolength\voffset      {-1.0  in}
\addtolength\hoffset      {-1.0  in}

\setlength\oddsidemargin  { 2.5  cm}
\setlength\evensidemargin { 2.5  cm}

\setlength\topmargin      { 0.5  cm}
\setlength\headheight     { 0.5  cm}
\setlength\headsep        { 0.5  cm}

\setlength\textheight     {27.2  cm}
\setlength\textwidth      {16.0  cm}

\addtolength\parskip      { 3.0  mm}
\setlength\parindent      { 0.0  mm}

\newlength{\tabcolsepTmp}

% set default font to sans
\renewcommand{\familydefault}{\sfdefault}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\headerTypeB}{%
\setlength{\tabcolsepTmp}{\tabcolsep}%
\setlength{\tabcolsep}{0pt}%
\begin{tabular}{p{0.7\textwidth}p{0.3\textwidth}}%
%& \begin{minipage}[t][7\normalbaselineskip][t]{\textwidth}%
& \absndA\\%
& \absndB\\%
& \absndC\\%
& \absndD\\%
& \absndE\\%
%\end{minipage}\\%
\multicolumn{2}{l}{%
\begin{minipage}[t][7\normalbaselineskip][t]{\textwidth}%
\empfgA\\%
\empfgB\\%
\empfgC\\%
\empfgD\\%
\empfgE%
\end{minipage}%
} \\%
\multicolumn{2}{r}{Location, \today}\\%
\end{tabular}%
\setlength{\tabcolsep}{\tabcolsepTmp}%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\headerTypeB

{\large Greeting\par}

text

text2

\newpage

\headerTypeB

some text

more text

\end{document}
  • You are right I simply overlooked that. If I use large correctly it works correctly. Sorry to bother you with such an amateur failure. :) – Bence Jun 29 '16 at 11:27
  • @Bence Often, just a different set of eyes are needed to spot such annoying things, but I was glad to help. – Steven B. Segletes Jun 29 '16 at 12:07

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.