Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Writing letters in LaTeX

1,321 views
Skip to first unread message

clive...@googlemail.com

unread,
Dec 22, 2012, 5:39:41 AM12/22/12
to
Hello!

I'm having difficulty tweaking -letterclass- to format a letter the way I want it shown. It should look like this:


Mr Clive Nicholas
1 Effing Road
London
E1 1EE
Mr L LaTeX
1 Acacia Avenue
London
N1 1NN 22nd December, 2012

Dear Mr LaTeX,

Re: Formatted Letter

This will not come out well when you view this post, but I want the date to appear - as shown: currently it displays as December 22, 2012 - on the same line as the last line of the sender's address, flush in line with my address, although I am aware that there may an issue with addresses longer than four lines. There should be a considerably large gap between 'Yours sincerely,' and my name to allow for a large enough signature: -letter- does not appear to allow for this. It should also be left-justified, which it is not as present, and appear at least two or three lines after the 'body' of the letter.


Yours sincerely,




Clive Nicholas

PS: I would prefer this to appear on the very last line of the letter, rather than straight after the signature; same goes for encl.

Presently, I'm running this code:

\documentclass{letter}
\usepackage{hyperref,mathptmx}
\signature{Clive Nicholas}
\address{Clive Nicholas \\ 1, Effing Road \\ London \\ E1 1EE}
\begin{document}
\begin{letter}{Mr L LaTeX \\ 1 Acacia Avenue \\ London \\ N1 1NN}
\opening{Dear Mr LaTeX,}
...
\begin{flushleft}
\closing{Yours sincerely,}
\end{flushleft}
\end{letter}
\end{document}

I very much hope somebody can assist with this.

C

Axel Berger

unread,
Dec 22, 2012, 10:45:57 AM12/22/12
to
clive...@googlemail.com wrote:
> I'm having difficulty tweaking -letterclass- to format a letter

Take a look at scrlttr2. It is highly customizable, which of course
means a lot of parameters to learn at first, but well worth it.

Axel

clive...@googlemail.com

unread,
Dec 23, 2012, 12:01:39 AM12/23/12
to
On Saturday, December 22, 2012 3:45:57 PM UTC, Axel Berger replied:

> Take a look at scrlttr2. It is highly customizable, which of course
>
> means a lot of parameters to learn at first, but well worth it.

I also have some initial code from -scrlttr2- as well, so I have played about with it a bit, but without any real satisfication yet.

I will do as you advise, but do you have any exemplar code from -scrlttr2- that may take me further forward?

C

Markus Kohm

unread,
Dec 24, 2012, 8:53:59 AM12/24/12
to
clive...@googlemail.com (Sonntag, 23. Dezember 2012 06:01):

> I will do as you advise, but do you have any exemplar code from -scrlttr2-
> that may take me further forward?

There are a lot of example letters in the KOMA-Script guide. Additional may
be found on komascript.de (in German). An here's one more:

\documentclass[DINmtext]{scrlttr2}% see
%<http://mirrors.ctan.org/macros/latex/contrib/koma-script/doc/scrguien.pdf>
\usepackage[british]{babel}
\usepackage{lipsum}

% You may put all this (until but without \begin{document}) into a lco-file
% of your own:
\KOMAoptions{subject=afteropening,subject=left,backaddress=false,fromalign=right}
\setkomavar{fromname}{Mr Clive Nicholas}
\setkomavar{fromaddress}{1 Effing Rad\\London\\E1 1EE}
\setkomavar{subject}{Re: Formatted Letter}

% Comment this out, if you want to see the effect of fromalign=right
\setkomavar{firsthead}{%
\raggedleft\begin{tabular}{@{}l@{}}
\usekomavar{fromname}\\
\usekomavar{fromaddress}
\end{tabular}
}

\makeatletter% remove this line in lco-file
\@setplength{refvpos}
{\dimexpr\useplength{toaddrvpos}+5.7\baselineskip\relax}
\@setplength{toaddrhpos}{\dimexpr \oddsidemargin+1in\relax}
\@setplength{firstheadwidth}{\textwidth}
\makeatother% remove this line in lco-file

\let\raggedsignature\raggedright

\begin{document}
\begin{letter}{Mr L \LaTeX\\1 Acacia Avenue\\London\\N1 1NN}
\opening{Dear Mr \LaTeX}
\lipsum[1]
\closing{Yours sinverely,}
\end{letter}
\end{document}


Markus Kohm
--
KOMA-Script, a versatile bundle of classes and packages for LaTeX2e
Current: KOMA-Script 3.11b (see <http://www.komascript.de/release> in
German)

Jean-Jacques Rétorré

unread,
Dec 25, 2012, 5:36:26 AM12/25/12
to
clive...@googlemail.com disait le 12/23/12 que :

> On Saturday, December 22, 2012 3:45:57 PM UTC, Axel Berger replied:

> do you have any exemplar code from
> -scrlttr2- that may take me further forward?


This is an example from LyX:

,----
| \documentclass[11pt,english]{scrlttr2}
| \usepackage{mathpazo}
| \usepackage[T1]{fontenc}
| \usepackage[latin9]{inputenc}
| \usepackage{setspace}
| \setstretch{1.15}
|
| %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
| %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
| %% Here you can modify the layout of your letter
| %% Have a look at the KOMA script documentation
| %% for details. Most commands are commented out
| %% here (i.e. we use default settings)
| %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
| %% Load an *.lco style file (see KOMA documentation)
| \LoadLetterOption{DIN}%
|
| %% THE CLASS OPTIONS
| %% Remove preceeding '%' to uncomment an item
| \KOMAoptions{%
| %,headsepline=true% separate the header with a line on page >1
| %,footsepline=true% separate the footer with a line on page >1
| %pagenumber=botcenter% position of the page number (see docu)
| %,parskip=false% Use indent instead of skip (more options cf. docu)
| fromalign=center% alignment of the address
| ,fromrule=aftername% separate the address with a line?
| ,fromphone=true% print sender phone number
| %,fromfax=true% print sender fax number
| ,fromemail=true% print sender e-mail address
| ,fromurl=true% print sender URL
| %,fromlogo=true% print a logo (position depends on fromalign)
| %,addrfield=false% print an address field?
| %,backaddress=false% print the back address?
| %,subject=afteropening,titled% alternative subject layout and position
| %,locfield=narrow% width of the (extra) location field
| %,foldmarks=false% print foldmarks?
| %,numericaldate=true% date layout
| %,refline=wide% layout of the refline
| }
|
| %% Customize Separators
| %\setkomavar{placeseparator}{ -- }
| \setkomavar{backaddressseparator}{ $\cdot$ }
| %\setkomavar{emailseparator}{ --> }
| %\setkomavar{enclseparator}{ > }
| %\setkomavar{faxseparator}{ --> }
| %\setkomavar{phoneseparator}{ --> }
| %\setkomavar{subjectseparator}{ >>> }
|
| %% Customize fonts
| %% Use LaTeX's standard font commands
| %% Modify with \setkomafont or \addtokomafont
| %% (see KOMA documentation)
| \setkomafont{backaddress}{\rmfamily}
| %\setkomafont{descriptionlabel}{}
| \setkomafont{fromaddress}{\small}
| \setkomafont{fromname}{\scshape}
| %\setkomafont{pagefoot}{}
| %\setkomafont{pagehead}{}
| %\setkomafont{pagenumber}{}
| %\setkomafont{subject}{}
| %\setkomafont{title}{}
|
| \usepackage{babel}
| \begin{document}
|
| \setkomavar{fromname}{The LyX Developers Team}
|
| \setkomavar{fromaddress}{140 Map Road\\
| SVN City}
|
| \setkomavar{fromphone}{0011/222\,333}
|
| \setkomavar{fromemail}{lyx-...@lists.lyx.org}
|
| \setkomavar{fromurl}{www.lyx.org}
|
| \setkomavar{backaddress}{The LyX Developers Team\\
| 140 Map Road\\
| SVN City}
|
| \setkomavar{signature}{The LyX{} Team}
|
| \setkomavar{subject}{New KOMA letter layout }
|
| \setkomavar{place}{The Internet}
|
| \setkomavar{date}{\today}
|
| \begin{letter}{Mr X. Ample\\
| 666 Sesame Street\\
| 12345 Nowhere}
|
| \opening{Dear Mr. Ample,}
|
| This template illustrates the use of the new scrlttr2 class (introduced
| with KOMA-script v. 2.9). This letter class is very flexible.
| for the most common parameters. Please consult the KOMA Script documentation%
| \footnote{http://www.ctan.org/tex-archive/macros/latex/contrib/supported/koma-script/scrguien.pdf%
| } for a detailed description.
|
| \closing{Have fun with it,}
|
| \ps{p.\,s.: The blue colored items have to be before the address, the
| magenta colored after it.}
|
| \cc{The LyX{} Users}
| \end{letter}
| \end{document}
`----

--
JJR.

clive...@googlemail.com

unread,
Dec 26, 2012, 12:31:14 PM12/26/12
to
Marcus Kohm replied:

There are a lot of example letters in the KOMA-Script guide. Additional may
be found on komascript.de (in German). An here's one more:

\documentclass[DINmtext]{scrlttr2}% see
%<http://mirrors.ctan.org/macros/latex/contrib/koma-script/doc/scrguien.pdf>
\usepackage[british]{babel}
\usepackage{lipsum}

% You may put all this (until but without \begin{document}) into a lco-file
% of your own:
\KOMAoptions{subject=afteropening,subject=left,backaddress=false,fromalign=right}
\setkomavar{fromname}{Mr Clive Nicholas}
\setkomavar{fromaddress}{1 Effing Rad\\London\\E1 1EE}
\setkomavar{subject}{Re: Formatted Letter}

[...]

Jean-Jacques Rétorré replied:

> This is an example from LyX:
>
>
>
> ,----
>
> | \documentclass[11pt,english]{scrlttr2}
>
> | \usepackage{mathpazo}
>
> | \usepackage[T1]{fontenc}
>
> | \usepackage[latin9]{inputenc}
>
> | \usepackage{setspace}
>
> | \setstretch{1.15}

[...]

Thank both of you very much for your helpful solutions, both of which I've used to knit together a letter format which brings me close to what I want:

-------------------------------------------------------------------------------
\documentclass[foldmarks=true,foldmarks=blmtP,fromalign=false,version=last]{scrlttr2}
\usepackage{mathptmx}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage[british]{babel}
\begin{document}

\setkomafont{fromname}{\scshape}
\setkomafont{fromaddress}{\scshape}
\setkomavar{fromname}{Clive Nicholas, esq.}
\setkomavar{fromaddress}{1, Effing Road, London, E1 1EE\\ \emph{t:} 01234 567890 $\mid$ \emph{e:} {\upshape clive...@gmail.com}}
\setkomavar{backaddress}{}
\setkomavar{signature}{Clive Nicholas}
\setkomavar{date}{26th December, 2012}

\begin{letter}[fontsize=11pt]{%
Dr A. B. Smith\\
100, Buckingham Road\\
London\\
N1 1NN%
}

\opening{Dear Dr Smith,}
\lipsum[1]
\closing{Yours faithfully,\\}

\encl{\emph{curriculum vitae}}
\end{letter}
\end{document}
-------------------------------------------------------------------------------

What I'm now missing is the following:

(1) I want to bring the body of the letter fully left-aligned with the recipient's address: there is an example shown in Figure 4.8 on p148 of the KOMA-Script Guide that comes close to achieving this - thanks for this, Marcus! - but it's not clear from the code displayed on the previous page how this was done;

(2) the date should be fully right-aligned to the end of the letterhead line, if possible; and

(3) I want to impose more spaces between \closing{} and \setkomavar{signature}{} to allow enough space for a handwritten signature, something I did specify in my original post but not implemented properly in the above code.

Thanks very much in further anticipation of your help. :)

C

clive...@googlemail.com

unread,
Dec 26, 2012, 3:14:56 PM12/26/12
to
My apologies!!

Here's the correct code without the errors:

\documentclass[foldmarks=true,foldmarks=blmtP,fromalign=false,version=last]{scrlttr2}
\usepackage{mathptmx}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage[british,english]{babel}
\usepackage{lipsum}
\begin{document}

\setkomafont{fromname}{\scshape}
\setkomafont{fromaddress}{\scshape}
\setkomavar{fromname}{Clive Nicholas, esq.}
\setkomavar{fromaddress}{1, Effing Road, London, E1 1EE\\ \emph{t:} 01234 567890 $\mid$ \emph{e:} {\upshape clive...@gmail.com}}
...
\end{document]

Thanks again.

C

Dr Eberhard W Lisse

unread,
Dec 28, 2012, 2:23:30 AM12/28/12
to
On 2012-12-26 22:14 , clive...@googlemail.com wrote:
[...]
> \setkomavar{fromaddress}{1, Effing Road, London, E1 1EE\\ \emph{t:} 01234 567890 $\mid$ \emph{e:} {\upshape clive...@gmail.com}}
[...]

Why not set the URL as URL :-)-O?

el


--
If you want to email me, replace nospam with el

clive...@googlemail.com

unread,
Dec 28, 2012, 3:54:46 AM12/28/12
to nos...@lisse.na
On Friday, December 28, 2012 7:23:30 AM UTC, Dr Eberhard W Lisse wrote:

> Why not set the URL as URL :-)-O?

Because I would prefer to leave everything in the same font.

C

Axel Berger

unread,
Dec 28, 2012, 6:51:04 AM12/28/12
to
clive...@googlemail.com wrote:
> > Why not set the URL as URL :-)-O?
> Because I would prefer to leave everything in the same font.

The URL-Package offers you "\urlstyle{same}" for just that purpose: get
all the linebreaking specials but keep the normal text font. You could
also write "\def\UrlFont{\rmdefault}" for the same purpose. See the
manual inside url.sty for details.

Axel

clive...@googlemail.com

unread,
Dec 28, 2012, 7:03:44 AM12/28/12
to
Thanks, Axel.

Markus Kohm

unread,
Dec 28, 2012, 7:33:44 AM12/28/12
to
clive...@googlemail.com (Mittwoch, 26. Dezember 2012 18:31):

> (1) I want to bring the body of the letter fully left-aligned with the
> recipient's address:

See the example I've posted on 24th December.

> (2) the date should be fully right-aligned to the end of the letterhead
line

Isn't this, what I've shown in the same example.
You may change the length and position of the reference line. See the pseudo
lengths tabular and documentation in scrguien.pdf.

> (3) I want to impose more spaces between \closing{} and
> \setkomavar{signature}{} to allow enough space for a handwritten
> signature, something I did specify in my original post but not
> implemented properly in the above code.

See figure 17.1 in scrguien.pdf (should be on page 296) and the
documentation of pseudo lengths.

clive...@googlemail.com

unread,
Dec 28, 2012, 7:16:52 PM12/28/12
to
On Friday, December 28, 2012 12:33:44 PM UTC, Markus Kohm wrote:

> > (1) I want to bring the body of the letter fully left-aligned with the
>
> > recipient's address:
>
>
>
> See the example I've posted on 24th December.

Which, if copied wholesale into my text editor (Texmaker 3.2) fails to run, producing errors. That's one of the reasons why I pared it down to code that does work. :)

> > (2) the date should be fully right-aligned to the end of the letterhead
>
> line
>
>
>
> Isn't this, what I've shown in the same example.
>
> You may change the length and position of the reference line. See the pseudo
>
> lengths tabular and documentation in scrguien.pdf.

Ditto.


> > (3) I want to impose more spaces between \closing{} and
>
> > \setkomavar{signature}{} to allow enough space for a handwritten
>
> > signature, something I did specify in my original post but not
>
> > implemented properly in the above code.
>
>
>
> See figure 17.1 in scrguien.pdf (should be on page 296) and the
>
> documentation of pseudo lengths.

Well, you might think that what you've pointed to is clear. To me, it's as clear as mud, and so is the code that is printed around that page. How about a clear working example allowing me to tweak what I want in order to set me straight on a few matters? Then I'll shut up. :)

C

Dr Eberhard Lisse

unread,
Dec 29, 2012, 1:37:39 AM12/29/12
to
Well,

if I copy it wholesale into TexShop it runs without errors.

And, if I may say so, telling the author of the Koma Script package
that you are too lazy to read the manual, is probably going to be
counterproductive.

el
-- if you want to reply, replace nospam with my initials

clive...@googlemail.com

unread,
Dec 29, 2012, 4:03:37 AM12/29/12
to nos...@lisse.na
On Saturday, December 29, 2012 6:37:39 AM UTC, Dr Eberhard Lisse wrote:

> Well,
>
>
>
> if I copy it wholesale into TexShop it runs without errors.
>
>
>
> And, if I may say so, telling the author of the Koma Script package
>
> that you are too lazy to read the manual, is probably going to be
>
> counterproductive.

It wasn't my intention to come across as lazy in any way, and I did actually say that I read the parts referred to by Markus. I'm simply saying that it's not clear enough to me. Perhaps I'm just think (don't answer that), but I think I'm more than entitled to say that, even if it is to the author of the package.

Moreover, I posted up some code that _does_ work for me. Here it is again:

\documentclass[foldmarks=true,foldmarks=blmtP,fromalign=false,version=last]{scrlttr2}
\usepackage{mathptmx}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage[british,english]{babel}
\usepackage{lipsum}
\begin{document}

\setkomafont{fromname}{\scshape}
\setkomafont{fromaddress}{\scshape}
\setkomavar{fromname}{Clive Nicholas, esq.}
\setkomavar{fromaddress}{1, Effing Road, London, E1 1EE\\ \emph{t:} 01234 567890 $\mid$ \emph{e:} {\upshape clive...@gmail.com}}
\setkomavar{backaddress}{}
\setkomavar{signature}{Clive Nicholas}
\setkomavar{date}{26th December, 2012}

\begin{letter}[fontsize=11pt]{%
Dr A. B. Smith\\
100, Buckingham Road\\
London\\
N1 1NN%
}

\opening{Dear Dr Smith,}
\lipsum[1]
\closing{Yours faithfully,\\}

\encl{\emph{curriculum vitae}}
\end{letter}
\end{document}

Let's ignore the justification of the date: that's a minor thing. I've just spotted that bringing the sender's address in line with the body of the letter (or vice versa) can be amended by tweaking

\makeatletter% remove this line in lco-file
\@setplength{refvpos}
{\dimexpr\useplength{toaddrvpos}+7\baselineskip\relax} <======== TWEAK HERE
\@setplength{toaddrhpos}{\dimexpr \oddsidemargin+1in\relax}
\@setplength{firstheadwidth}{\textwidth}
\makeatother% remove this line in lco-file

so I'll work on that. However, increasing the gap between \closing{} and my signature I'm still unclear on

I've gone back to Markus' original code in an attempt to run it again - taking out the first couple of comments - but I get one red error:

l.15 }
You've tried to set the not defined KOMA-Script variable `firsthead'.
You have to define the variable using \newkomavar before
you do this.
(./testletter2.aux)
\openout1 = `testletter2.aux'.

There are two other comments in blue, but we can skip those.

This is the 'offending' piece:

\setkomavar{firsthead}{
\raggedleft\begin{tabular}{@{}l@{}}
\usekomavar{fromname}\\
\usekomavar{fromaddress}
\end{tabular}
}

So, advance on that would be excellent. :)

C

clive...@googlemail.com

unread,
Jan 1, 2013, 4:02:31 PM1/1/13
to
After much digging around, I've now formulated a solution:

Step 1: Generate and save a file called nowindow.lco, amended to taste:

\ProvidesFile{nowindow.lco}%
[2003/01/24 v0.1 unsupported letter-class-option]
\@setplength{firstheadwidth}{\textwidth}
\@setplength{toaddrhpos}{\oddsidemargin}
\@addtoplength{toaddrhpos}{1in}
\KOMAoptions{backaddress=false}
\firstfoot{
\centering
{\Large \emph{t:} 01234 567890 \emph{e:} \upshape clive...@gmail.com}
}
\endinput

Step 2: Compile and run the letter in LaTeX:

\documentclass[UKenglish,fromalign=false,version=last]{scrlttr2}
\usepackage[british,english]{babel}
\usepackage[utf8]{inputenx}
\LoadLetterOption{nowindow}
\usepackage{mathptmx}
\begin{document}

\setkomafont{fromname}{\scshape}
\setkomafont{fromaddress}{\scshape}
\setkomavar{fromname}{\LARGE Clive Nicholas, esq.}
\setkomavar{fromaddress}{\Large 1, Effing Road, London, N1 1NN, England}
\setkomavar{backaddress}{}
\setkomavar{signature}{Clive Nicholas}

\begin{letter}[fontsize=10.5pt]{Herr Markus Kohm\\KOMA-Script Projekt\\Achern\\Deutschland}

\opening{Dear Herr Kohm(!),}

Notice how I've now finally aligned the back address to the body of the letter. Also, the date is now correctly right-aligned and the body of the letter now justifies all across the legend line in the letter header. I've also included a footer as well, although imposing a \hrule above it in the lco-file makes it look ugly (even before the call to \centering), so I removed it.

I've posted this up because I hope that this may be of some interest to you as an example and to others who may wish to use \texttt{scrlttr2} to format their letters in a similar way.

\closing{Yours faithfully,\\}

\ps{It would also be nice to add a comma after the month in the date, which some example code generates automatically, but I guess I'll work on that.}
\end{letter}
\end{document}
0 new messages