LaTeX/信函
有時平凡的事情是最痛苦的。但是,由於不斷發展且使用者友好的模板,不必如此。值得慶幸的是,LaTeX 允許快速撰寫信函,且幾乎沒有麻煩。
要撰寫信函,請使用標準文件類 letter。
您可以在一個 LaTeX 檔案中撰寫多封信函 - 每封信函以 \begin{letter}{''收件人''} 開頭,並以 \end{letter} 結尾。您可以將 收件人 留空。每封信函包含四個部分。
- 開頭(如
\opening{尊敬的先生/女士,}或\opening{親愛的凱特,})。 - 主體(在 LaTeX 中照常編寫)。如果您希望所有信函都使用相同的主體,則可以考慮將整個主體放在一個新命令中,例如
\newcommand{\BODY}{實際主體},然後在所有信函中使用\BODY。 - 結尾(如
\closing{此致敬禮,})。- LaTeX 將在結尾後留出一些空間供您手寫簽名;然後,如果已宣告姓名和姓氏,則會顯示姓名和姓氏。
- 其他元素:附言、抄送和附件清單。
如果您希望姓名、地址和電話號碼顯示在信函中,則必須首先宣告它們:簽名、地址和電話。
輸出信函將如下所示

以下是示例程式碼
\documentclass{letter}
\usepackage{hyperref}
\signature{Joe Bloggs}
\address{21 Bridge Street \\ Smallville \\ Dunwich DU3 4WE}
\begin{document}
\begin{letter}{Director \\ Doe \& Co \\ 35 Anthony Road
\\ Newport \\ Ipswich IP3 5RT}
\opening{Dear Sir or Madam:}
I am writing to you on behalf of the Wikipedia project (http://www.wikipedia.org/),
an endeavour to build a fully-fledged multilingual encyclopaedia in an entirely
open manner, to ask for permission to use your copyrighted material.
% The \ldots command produces dots in a way that will not upset
% the typesetting of the document.
\ldots
That said, allow me to reiterate that your material will be used to the noble end of
providing a free collection of knowledge for everyone; naturally enough, only if you
agree. If that is the case, could you kindly fill in the attached form and post it
back to me? We shall greatly appreciate it.
Thank you for your time and consideration.
I look forward to your reply.
\closing{Yours Faithfully,}
\ps
P.S. You can find the full text of GFDL license at
\url{http://www.gnu.org/copyleft/fdl.html}.
\encl{Copyright permission form}
\end{letter}
\end{document}
要將結尾和簽名部分移到左側,請在 \begin{document} 之前插入以下內容
\longindentation=0pt
左側的空間量可以透過增加 0pt 進行調整。
envlab 包為 \makelabels 命令提供了自定義功能,允許使用者在各種標籤或信封尺寸上列印。例如,以下面的方式開始您的 LaTeX 檔案,即可生成一個文件,其中包含信函和下一頁的商務尺寸(#10)信封。
\documentclass{letter}
\usepackage[businessenvelope]{envlab}
\makelabels
|
有關此功能強大的軟體包的更多資訊,請參閱 envlab 使用者指南。請注意,envlab 包在顯示基本 ASCII 字元集之外的字元時存在問題,有關更多資訊,請參閱 此錯誤報告。
這是一個相對簡單的信封,它使用 geometry 包,因為該包極大地簡化了重新排列頁面上內容(以及頁面本身)的任務。
% envelope.tex
\documentclass{letter}
\usepackage[left=1in,top=0.15in,papersize={4.125in,9.5in},landscape,twoside=false]{geometry}
\setlength\parskip{0pt}
\pagestyle{empty}
\begin{document}
FROM-NAME
FROM-STREET ADDRESS
FROM-CITY, STATE, \ ZIP
\vspace{1.0in}\large
\setlength\parindent{3.6in}
TO-NAME
TO-STREET ADDRESS
TO-CITY, STATE, \ ZIP
\end{document}
|

以上內容當然可以處理間距,但實際列印則取決於您和您的印表機。一位使用者報告說,使用 envlab 建立的信封相對容易列印。如果您使用 geometry 包,您可能會發現以下命令對列印信封很有用。
$ pdflatex envelope.tex $ pdf2ps envelope.pdf $ lpr -o landscape envelope.ps
或者,您可以使用 latex dvi 輸出驅動程式。
在第一行中,dvips 命令將 latex 生成的 .dvi 檔案轉換為 .ps(PostScript)檔案。在第二行中,PostScript 檔案將傳送到印表機。
$ latex envelope.tex && dvips -t unknown -T 9.5in,4.125in envelope.dvi $ lpr -o landscape envelope.ps
據報道pdflatex建立正確的頁面尺寸,但dvips儘管在 geometry 手冊中有所說明,但它卻無法正常工作。除非印表機設定調整為正確的頁面樣式,否則它將永遠無法工作。這些設定取決於您使用的印表機過濾器,在 CUPS 中可能在lpr命令列上可用。
使用 KOMA 包中的 letter 類是分別在信封上列印地址的另一種方法。它支援其他功能,例如摺疊標記和帶視窗信封的正確地址放置。使用 KOMA 包中的 scrlttr2 文件類,示例信函程式碼為
% koma_env.tex
\documentclass[a4paper]{scrlttr2}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{url}
\setkomavar{fromname}{Joe Bloggs}
\setkomavar{fromaddress}{21 Bridge Street\\ Smallville\\ Dunwich DU3 4WE}
\setkomavar{fromphone}{0123 45679}
\begin{document}
\begin{letter}{Director \\ Doe \& Co \\ 35 Anthony Road
\\ Newport \\ Ipswich IP3 5RT}
\KOMAoptions{fromphone=true,fromfax=false}
\setkomavar{subject}{Wikipedia}
\setkomavar{customer}{2342}
\opening{Dear Sir or Madam,}
I am writing to you on behalf of the Wikipedia project
(\url{http://www.wikipedia.org/}), an endeavour to build a
fully-fledged multilingual encyclopaedia in an entirely open
manner, to ask for permission to use your copyrighted material.
\ldots
That said, allow me to reiterate that your material will be used
to the noble end of providing a free collection of knowledge for
everyone; naturally enough, only if you agree. If that is the
case, could you kindly fill in the attached form and post it back
to me? We shall greatly appreciate it.
Thank you for your time and consideration.
I look forward to your reply.
\closing{Yours Faithfully,}
\ps{P.S. You can find the full text of GFDL license at
\url{http://www.gnu.org/copyleft/fdl.html}.}
\encl{Copyright permission form}
\end{letter}
\end{document}
輸出透過以下方式生成
$ pdflatex koma_env
根據摺疊標記摺疊生成的 koma_env.pdf 檔案的列印內容,可以將其放入標準化的帶視窗信封 DIN C6/5、DL、C4、C5 或 C6 中。
除了預設設定外,KOMA 包還包括針對不同標準化瑞士和日本信函格式的預定義格式定義。
| 命令 | 描述 |
|---|---|
\name{} |
|
\signature{} |
|
\address{} |
|
\location{} |
|
\telephone{} |
|
\makelabels |
|
\stopbreaks |
|
\startbreaks |
|
\opening{} |
|
\closing{} |
|
\cc{} |
開始一個以 \ccname 引入的 parbox |
\encl{} |
開始一個以 \enclname 引入的 parbox |
\ps |
開始一個新段落,通常在信函結尾處 |
\stopletter |
(空) |
\returnaddress |
(空) |
\startlabels |
|
\mlabel{}{} |
|
\descriptionlabel{} |
|
\ccname |
"抄送" |
\enclname |
"附件" |
\pagename |
"頁" |
\headtoname |
"致" |
\date{} |
更改日期。有關替代格式,請參閱 datetime 包。 |
\today |
長格式日期 |
| 環境 | 描述 |
|---|---|
letter{} |
請參閱主要文章 |
描述 |
|
詩歌 |
|
引用 |
|
引用
|

