To add a salutation to a letter in LaTeX, use the built-in letter class and place the greeting in \opening{} inside the letter environment, for example \opening{Dear Dr.\ Lee,}. The argument is the full greeting, including its punctuation. The rest of a formal letter, from the sender’s address to the closing and signature, uses a few more commands. This guide covers them in order.
The letter class at a glance
The letter class ships with LaTeX, so there is nothing extra to install. It lays out a letter page: the sender’s address at the top, the recipient block, the greeting, the body, the closing, the signature and any enclosures. You supply the content in order, and the class handles the placement.
A complete letter
The body text below is sample wording. Replace it with your own.
\documentclass[11pt]{letter}
\address{Jane Doe \\ 12 Example Road \\ Leeds LS1 1AA}
\signature{Jane Doe}
\begin{document}
\begin{letter}{Dr.\ Alex Lee \\ Head of Admissions \\ Example University \\ 1 Campus Way \\ Leeds LS2 2BB}
\opening{Dear Dr.\ Lee,}
I am writing to ask about the placement programme in your department. I am a second-year student in computer science, and I would welcome the chance to learn more about it.
Thank you for considering my request. I would be glad to send any further details you need.
\closing{Yours sincerely,}
\encl{Curriculum vitae}
\end{letter}
\end{document}
\address in the preamble sets the sender’s return address. \signature sets the name printed under the closing. The letter environment takes the recipient’s address as its one argument, and \\ starts a new line inside it. Inside the environment, \opening prints the greeting, \closing prints the sign-off, and \encl adds an enclosure line.
The salutation
\opening{...} prints whatever you put in its argument, so the greeting and its punctuation are yours to choose:
\opening{Dear Dr.\ Lee,}when you know the recipient’s name.\opening{Dear Hiring Manager,}when you do not know the name.\opening{Dear Sir or Madam,}is an older form. Some recruiters prefer a role title instead.
Commonly, UK letters put a comma after the greeting and US letters use a colon, but check the convention for the country you are writing to.
The backslash and space in Dr.\ Lee stop LaTeX from adding the wider space it uses after a full stop that ends a sentence. Without it, the gap after Dr. can look too large.
Closing, signature and enclosures
- Closing. British usage pairs “Dear Dr. Lee,” with “Yours sincerely,” and “Dear Sir or Madam,” with “Yours faithfully,”. Check the convention where you are applying.
- Signature.
\signature{...}sets the name. Use\\to put a job title or a second line under the name. - Enclosures.
\encl{...}adds an “Enclosure” line. List the documents you are attaching. - Copies and postscripts.
\cc{...}adds a copy line, and\psstarts a postscript.
Writing a letter without the letter class
If you do not need the letter layout, a salutation is just a line of text. Start the body with the greeting, leave a blank line, then write the paragraphs.
\documentclass[11pt]{article}
\pagestyle{empty}
\setlength{\parindent}{0pt}
\begin{document}
Dear Dr.\ Lee,
I am writing to ask about the placement programme in your department.
Yours sincerely,
Jane Doe
\end{document}
A blank line starts a new paragraph. The article class indents new paragraphs by default, and \setlength{\parindent}{0pt} removes that indent, which suits most letters. The parskip package is an alternative: it adds space between paragraphs in place of the indent. See how to change line spacing in LaTeX for paragraph spacing.
Line breaks in addresses
\\ ends a line without starting a new paragraph. It is the right tool for address blocks, signatures and other multi-line details. Between body paragraphs, use a blank line instead, since \\ only ends a line.
Tildes, bold text and accents
People often ask how to type a few characters in a letter, so here are the commands for the common cases. For more text styles, see how to format text in LaTeX.
| Need | Command | Example output |
|---|---|---|
| Tilde character in text | \textasciitilde |
~ |
| Tilde in a formula | $\sim$ |
∼ |
| Bold text | \textbf{text} |
bold text |
| Bold symbol in a formula | $\mathbf{x}$ |
x |
| Accent in text | \'e, \^o, \"u |
é, ô, ü |
| Macron in text (bar over a letter) | \=a |
ā |
| Bar over a symbol in a formula | $\bar{x}$ |
x̄ |
Recent LaTeX installations read UTF-8, so you can often type é or ü directly. The commands above are still useful for symbols that are hard to type, and for matching older documents.
Common problems
- The greeting is missing from the PDF. Check that
\openingsits inside\begin{letter}and\end{letter}, after the recipient block. - Undefined control sequence. A command name is misspelt. Compare it with the examples above.
- Odd spacing after an abbreviation. Use
Dr.\ Leerather thanDr. Lee, as shown earlier.
A job application letter uses the same commands. The cover letter guide shows how to set the job title and company once at the top and reuse the file. For the CV that goes with a letter, see the CV guide.