Procrastiblog

November 25, 2007

LaTeX Letters

Filed under: LaTeX, Tech — Chris @ 4:42 pm

I was trying to write a letter in LaTeX the other day:

\documentclass{letter}

\address{Nowheresville}

\signature{Me}

\begin{document}
\begin{letter}

\opening{To Whom It May Concern:}

Hello, there.

\closing{Sincerely,}

\end{letter}
\end{document}

This led to the following two errors, which shed little light on the situation:

! LaTeX Error: There's no line here to end.

See the LaTeX manual or LaTeX Companion for explanation.
Type H  for immediate help.
 ...

l.10 \opening{To Whom It May Concern:}

and (on a different example)

! Incomplete \iffalse; all text was ignored after line 66.

                \fi
l.16 \end{letter}

Runaway text?
\@mlabel{}{\unhbox \voidb@x \ignorespaces \global \let

The problem, as it was gently explained to me, is I had omitted the second mandatory argument of \begin{letter}, which is the address of the recipient. The following is correct:

\documentclass{letter}

\address{Nowheresville}

\signature{Me}

\begin{document}
\begin{letter}{Foo Corp.}

\opening{To Whom It May Concern:}

Hello, there.

\closing{Sincerely,}

\end{letter}
\end{document}

[UPDATE] I just realized that the reason I got so confused about this is that I was working off a previous business letter that was formatted like:

\begin{document}
\begin{letter}
{
Foo Corp. \\
... \\
ATTN: Warranty Dept.}
...

I’m not sure if I intended it to be the case (probably not), but LaTeX picked up the braces around the address as the argument to letter. When I used this as the template for a personal letter and deleted the address, all hell broke loose.

Advertisement

4 Comments

  1. Thanks for posting. I was having a similar errors (using a different class) and my solution was the same.

    Comment by fs — July 8, 2008 @ 1:22 pm

  2. This blog post is up for nearly a full year, and then it suddenly receives two responses within four days of each other. Go figure.

    Anyhow, thank you for sharing this solution. I am using the LyX editor on OS X, and you described my problem (and solution) perfectly. Thanks again.

    Comment by Rockwell — July 12, 2008 @ 7:46 pm

  3. As a follow-up to my own comment #2, I just came across an alternate way of defining a letter, using the \letter command. It formats the letter slightly differently, and it appears that you can only include one such command per document.

    \begin{document}

    \address{Sender’s address}

    \letter{Recipient’s Address}

    \opening{Dear Recipient,}

    Letter content goes here

    \closing{Sincerely,\\
    The Procrastiblog}

    \end{document}

    Comment by Rockwell — July 12, 2008 @ 7:58 pm

  4. fs, Rockwell, Glad to be helpful.

    Rockwell, Hmm… A letter document class, environment, and command? I need to look into this…

    Comment by Chris — July 12, 2008 @ 11:26 pm


RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Blog at WordPress.com.

%d bloggers like this: