当我尝试使用表格来容纳使用字母类的多个收件人时,pdf 会呈现,但会出现错误:
line 32: Argument of \@no@pgbk has an extra }. \end{letter}
line 32: Paragraph ended before \@no@pgbk was complete. \end{letter}
梅威瑟:
\documentclass[letterpaper, 11pt]{letter}
\usepackage{lipsum}
%\def \fromaddress{\null}
\begin{document}
\begin{letter}{\begin{tabular}{p{5cm}p{5cm}}
{addressname\newline{}line1\newline{}line2} &
{addressname2\newline{}line1\newline{}line2}
\end{tabular}}
% \begin{letter}{recip1\\address1\\address2} %<==== This line works
\opening{Dear my addressees:}
\lipsum[1]
\vspace{12pt}
\closing{Yours faithfully,\\
\fromsig{THISISME\\}
\fromname{ME\\Title1\\title2}
}
\end{letter}
\end{document}
请注意,当我注释掉使用表格的 begin{letter} 行并弹出注释的原始行时,一切正常。
对发生的情况有什么了解吗?我是否可以解决它?
更新:
\documentclass[firsthead=no,pagenumber=topleft, headsepline=yes, 11pt,paper=letter,foldmarks=no,refline=nodate,enlargefirstpage=no,parskip=half,DIV=11]{scrlttr2} %refline=nodate
% stolen from https://tex.stackexchange.com/questions/302281/using-mathpazo-with-scrlttr2-not-globally-changing-font
\usepackage[english]{babel}
%\usepackage{scrlayer-scrpage}
\usepackage{blindtext}
\usepackage{tabularx}
\usepackage{tikz}
\KOMAoptions{DIV=last}
%\ihead{Recipient }
\setkomavar{signature}{This is me\\Lord High Muckety Muck}
\setkomavar{enclseparator}{: }
\setkomavar{location}{\par\raggedleft{\usekomavar{date}}}
\LetterOptionNeedsPapersize{letter}{letter}
%\setkomafont{backaddress}{\normalfont}
\KOMAoptions{DIV=last}
\makeatletter
\@setplength{toaddrindent}{10pt } %indent the To Address a little bit
\@setplength{lochpos}{\oddsidemargin } %make date in location area align to text
\@addtoplength{lochpos}{1in}
\@setplength{locvpos}{2in}
\@setplength{locheight}{.5in}
\@setplength{toaddrheight}{3.75in }
\@setplength{refaftervskip}{0in }
\@setplength{refvpos}{5in } % This will move the message body UP or DOWN
\@setplength{subjectbeforevskip}{0pt}
\@setplength{subjectaftervskip}{0pt}
%\@addtoplength{subjectvpos}{-20pt}
\@setplength{sigindent}{3in} %indent of signature
\makeatother
\renewcommand*{\raggedsignature}{\raggedright}
\setlength{\parindent}{1em}
\renewcommand{\pagemark}{{Recipient, page \usekomafont{pagenumber}{\thepage}}} %%Change recipient name here
\begin{document}
% \ThisULCornerWallPaper{1}{letterhead.pdf}
\begin{letter}{\begin{tabularx}{5in}{XX}
a&b % <====== This works
% a&b \\
% c&d <+++++++++ Two row tabular doesn't work
\end{tabularx}}
% \setkomavar{subject}{Subject}fDIV=
\KOMAoptions{DIV=last}
\opening{Respected marmots,}
\blindtext
{\begin{tabularx}{5in}{XX}
a&b \\
c&d
\end{tabularx}}
\Blindtext
\closing{Sincerely}
\end{letter}
\end{document}
我尝试了下面描述的 scrlttr2 选项。它对地址的 1 行 tabularx 工作得很好,但对 2 行的地址就崩溃了(您可以通过注释 1 行表格并取消注释 2 行表格来查看)。这给出了(第一个)错误消息
\TX@get@body 的参数有一个额外的 }。\opening{尊敬的土拨鼠,},接下来又是一片混乱。
答案1
你想要一些非样板的东西,letter
班级并非为此而构建的,主要是因为它对你提供的内容做出了一些假设。具体来说,(第一个)参数letter
是处理为了提炼信息,例如收件人的姓名和地址。一旦你开始在那里做其他事情,你可能会遇到问题。
一个可能的解决方案是从头开始创建一封信件 - 这很简单:
\documentclass[11pt]{article}
\usepackage{geometry,lipsum}
\geometry{
margin=1in % or whatever suits you
}
\setlength{\parindent}{0pt}% Remove paragraph indent
\begin{document}
\pagestyle{empty}% Remove page headers/footers
\mbox{}\hfill
\begin{tabular}{l @{}}
Address \\
of \\
Sender \\ \\
\today
\end{tabular}
\bigskip % Vertical skip between sender/receiver address
\begin{tabular}[t]{@{} l}
Name and \\
Address \\
of \\
Receiver 1
\end{tabular} \quad
\begin{tabular}[t]{@{} l}
Name and \\
Address \\
of \\
Receiver 2
\end{tabular}
\bigskip % Vertical skip between receive address and letter opening
Dear adressees,
\medskip % Vertical skip between letter opening and letter body
\lipsum[1]
\medskip % Vertical skip between letter body and closing
%\hspace*{.5\linewidth}% ...for a middle-left-aligned closing
Yours faithfully,
\medskip % Vertical skip between letter closing and signature start
\vspace{5\baselineskip} % Content that includes your signature, or space for it
My signature
\bigskip % Vertical skip between signature and attachment references
cc: % people this letter is cc-ed to
\medskip
encl: % list of anything enclosed
\medskip
ps: % any post scriptums
\end{document}
答案2
这不是一个解决方案,而是一个变通方法。
\documentclass[letterpaper, 11pt]{letter}
\usepackage{lipsum}
\begin{document}
\begin{letter}{{\makebox[5cm][l]{marmot1}}\makebox[5cm][l]{marmot2}\\
\makebox[5cm][l]{address1}\makebox[5cm][l]{address2}\\
\makebox[5cm][l]{mountain1}\makebox[5cm][l]{mountain2}
}
\opening{Dear my addressees:}
\lipsum[1]
\vspace{12pt}
\closing{Yours faithfully,\\
\fromsig{THISISME\\}
\fromname{ME\\Title1\\title2}
}
\end{letter}
\end{document}
编辑/更新如果你愿意接受不同的文档类别,你可以尝试
\documentclass{scrlttr2}
% stolen from https://tex.stackexchange.com/questions/302281/using-mathpazo-with-scrlttr2-not-globally-changing-font
\usepackage{blindtext}
\LoadLetterOption{DIN}
\setkomavar{fromname}{From Name}
\setkomavar{fromaddress}{From Street\\00000 From City}
\setkomavar{fromphone}{+49 0000 0\,00\,00\,00}
\setkomavar{fromemail}{[email protected]}
\setkomavar{backaddressseparator}{\enspace\textperiodcentered\enspace}
\setkomavar{signature}{(From Name)}
\setkomavar{place}{From City}
\setkomavar{date}{\today}
\setkomavar{enclseparator}{: }
\setkomafont{backaddress}{\normalfont}
\begin{document}
\begin{letter}{\begin{tabular}{p{4cm}p{4cm}}
Murmeltier\newline Saas Fee\newline Switzerland &
Marmot\newline Vancouver Island\newline Canada
\end{tabular}}
\setkomavar{subject}{Subject}
\opening{Respected marmots,}
\blindtext
\closing{Sincerely,}
\end{letter}
\end{document}
好的,又一轮。我发现tabularx
如果使用\cr
(不推荐使用,对吧;-) 代替 ,也可以\\
。
\documentclass[firsthead=no,pagenumber=topleft, headsepline=yes, 11pt,paper=letter,foldmarks=no,refline=nodate,enlargefirstpage=no,parskip=half,DIV=11]{scrlttr2} %refline=nodate
% stolen from https://tex.stackexchange.com/questions/302281/using-mathpazo-with-scrlttr2-not-globally-changing-font
%\usepackage[english]{babel} % I had to comment this out.
%\usepackage{scrlayer-scrpage}
\usepackage{blindtext}
\usepackage{tabularx}
\usepackage{tikz}
\KOMAoptions{DIV=last}
%\ihead{Recipient }
\setkomavar{signature}{This is me\\Lord High Muckety Muck}
\setkomavar{enclseparator}{: }
\setkomavar{location}{\par\raggedleft{\usekomavar{date}}}
\LetterOptionNeedsPapersize{letter}{letter}
%\setkomafont{backaddress}{\normalfont}
\KOMAoptions{DIV=last}
\makeatletter
\@setplength{toaddrindent}{10pt } %indent the To Address a little bit
\@setplength{lochpos}{\oddsidemargin } %make date in location area align to text
\@addtoplength{lochpos}{1in}
\@setplength{locvpos}{2in}
\@setplength{locheight}{.5in}
\@setplength{toaddrheight}{3.75in }
\@setplength{refaftervskip}{0in }
\@setplength{refvpos}{5in } % This will move the message body UP or DOWN
\@setplength{subjectbeforevskip}{0pt}
\@setplength{subjectaftervskip}{0pt}
%\@addtoplength{subjectvpos}{-20pt}
\@setplength{sigindent}{3in} %indent of signature
\makeatother
\renewcommand*{\raggedsignature}{\raggedright}
\setlength{\parindent}{1em}
\renewcommand{\pagemark}{{Recipient, page \usekomafont{pagenumber}{\thepage}}} %%Change recipient name here
\begin{document}
% \ThisULCornerWallPaper{1}{letterhead.pdf}
\begin{letter}{\begin{tabularx}{5in}{XX}
a & b\cr
c & d % <+++++++++ Two row tabular doesn't work
\end{tabularx}}
% \setkomavar{subject}{Subject}fDIV=
\KOMAoptions{DIV=last}
\opening{Respected marmots,}
\blindtext
{\begin{tabularx}{5in}{XX}
a&b \\
c&d
\end{tabularx}}
\Blindtext
\closing{Sincerely}
\end{letter}
\end{document}