![格式化 newlfm 文档:(1)顶部对齐,和(2)消失边距](https://linux22.com/image/352615/%E6%A0%BC%E5%BC%8F%E5%8C%96%20newlfm%20%E6%96%87%E6%A1%A3%EF%BC%9A%EF%BC%881%EF%BC%89%E9%A1%B6%E9%83%A8%E5%AF%B9%E9%BD%90%EF%BC%8C%E5%92%8C%EF%BC%882%EF%BC%89%E6%B6%88%E5%A4%B1%E8%BE%B9%E8%B7%9D.png)
我正在尝试使用 newlfm 类来格式化一封信。我有两个问题:
- 如何将第一页正文顶部与页边距文本对齐?
- 如何生成出现在第二页及后续页面上的边距文本?
这是一个最小的工作示例,显示了我遇到的问题:
\documentclass{newlfm}
\usepackage{blindtext}
\newlfmP{busletternofrom,noLines,nolines,dateskipbefore=0in}
\leftmarginskipleft{0.5in}
\leftmarginskipright{0.25in}
\rightmarginsize{1in}
\nameto{John Doe}
\addrto{P.O.~Box 1000 \\ Athens, AK 11111}
\namefrom{Mary Moe}
\closeline{Regards,}
\greetto{Dear Sir or Madam:}
\newsavebox{\Lfirstpagelet}
\sbox{\Lfirstpagelet}{%
\parbox[t]{1.75in}{%
\raggedleft
\printnamefrom}}
\newsavebox{\Lpagelet}
\sbox{\Lpagelet}{%
\parbox[t]{1.75in}{%
\raggedleft
Page \thepage}}
\Lmargin{\usebox{\Lfirstpagelet}}
\lmargin{\usebox{\Lfirstpagelet}}
\begin{document}
\begin{newlfm}
\PhrRe{This is a test}
\Blindtext[5]
\end{newlfm}
\end{document}
请注意,在第一页上,“Mary Moe”和日期没有垂直对齐。我希望它们对齐。
还请注意,在第二页的左边距中没有显示任何内容。我希望那里显示一些内容(最好是页码)。
答案1
我会使用默认article
类,而不是尝试“让事情正常运作”newlfm
。
下面的示例使用了以下内容:
默认
article
类geometry
用于调整文本块尺寸eso-pic
用于将Page X
第二页及以后的页码放置在文本块左上角的左侧datatool
提供一种编写一封有多个发件人/收件人(以及其他任何需要的内容)的信件的方法,符合 提供的“信件数据库功能”newlfm
。
\documentclass{article}
\usepackage{filecontents,datatool}
% Set up your database of mail merge content (in CSV)
\begin{filecontents*}{mail_merge.csv}
letternum, fromperson, toperson, toaddress
1, Mary Moe, John Doe, PO Box 1000 \\ {Athens, AK 11111}
2, Jane Doe, Rumplestiltskin, Castle ABC \\ {Neverland, NL 54321}
\end{filecontents*}
\usepackage{lipsum}% Just for this example
\sloppy% Just for this example
% Set up your document layout
\usepackage[margin=1in,left=2in,includeheadfoot]{geometry}
\usepackage{eso-pic}% Used to place the page number
\setlength{\parindent}{0pt}% Remove paragraph indent
\setlength{\parskip}{1\baselineskip plus 2pt minus 1pt}% Big skip between paragraphs
% Placement of the page number...
\AddToShipoutPictureFG{%
\AtTextUpperLeft{%
\ifnum\value{page}>1 % ...only on pages 2, 3, ...
\raisebox{-.85\baselineskip}{\makebox[0pt][r]{Page \thepage~~~}}%
\fi
}%
}
\pagestyle{empty}% Don't place anything in the header/footer
% Load the mail merge database
\DTLloaddb[keys={letternum,fromperson,toperson,toaddress}]{mailmerge}{mail_merge.csv}
% Extract a record of choice...
\DTLassign{mailmerge}{2}% ... like record 2 in this case
{\letternum=letternum,\fromperson=fromperson,\toperson=toperson,\toaddress=toaddress}
\begin{document}
\makebox[0pt][r]{\fromperson~~~}%
\today
\bigskip
\begin{tabular}{@{} l}
\toperson \\
\toaddress
\end{tabular}
\bigskip
Dear Sir or Madam:
\bigskip
\lipsum[1-6]
\bigskip
Regards,
\vspace{4\baselineskip}
\fromperson
\end{document}
由于地址中可能有逗号,因此请将属于同一标题的内容{
括起来。}