如何从 KOMA-Script 的 scrlttr2 类中获取美国字母输出?

如何从 KOMA-Script 的 scrlttr2 类中获取美国字母输出?

我几乎用 KOMA-Script 来处理所有事情,包括信件。当我使用 A4 纸时,这很轻松,但当我尝试使用美国信纸时,问题就开始了。

有了scrartcl类,\KOMAoptions{paper=letter}就可以达到目的。

scrlttr2班级一起:

如果使用默认的类选项文件(DIN.lco我相信),则\KOMAOptions{paper=letter}无效。该文档编译时出现以下警告:

Class scrlttr2 Warning: Letter option file `DIN.lco'
(scrlttr2) needs paper size `a4'.
(scrlttr2) Current paper size is not `a4'!
(scrlttr2) You should add `paper=a4' at the
(scrlttr2) option list of \documentclass!
(scrlttr2) Maybe you know what you are doing,
(scrlttr2) so I do not change this myself.

输出为 A4。

如果我使用UScommercial9.lco 没有 paper=letter,编译时会出现以下警告:

Class scrlttr2 Warning: Letter option file `UScommercial9.lco'
(scrlttr2)              needs paper size `letter'.
(scrlttr2)              Current paper size is not `letter'!
(scrlttr2)              You should add `paper=letter' at the
(scrlttr2)              option list of \documentclass!
(scrlttr2)              Maybe you know what you are doing,
(scrlttr2)              so I do not change this myself.

如果我使用UScommercial9.lco,如在这个 MWE 中:

\documentclass[UScommercial9]{scrlttr2}
\usepackage[english]{babel}

\listfiles

\KOMAoptions{paper=letter,fromphone=true,fromfax=false}

\begin{document}

\setkomavar{fromname}{Stephen Bosch}
\setkomavar{fromaddress}{10 Lemon Lane \\ Sour Orchards BC V0E 0B0}
\setkomavar{fromphone}{+1 250 377 4141}

\begin{letter}{Tremulor Nocharme \\ Compliance Officer \\ Special TPS Police
\\ Fram Jammer Building \\ 320, 220 -- 4 Street \\ Treacleton AB T0M 0M0}

\setkomavar{subject}{Late TPS reports 2008, 2009, 2010, 2011, 2012}

\opening{Dear Mr. Nocharme,}

Attached please find the TPS reports you requested. Please accept my apologies for the delay.\\

\closing{Sincerely,}

\end{letter}

\end{document}

我不再收到警告,但输出是仍然A4。

此外,当我尝试通过删除

\usepackage[english]{babel}

行,我收到一系列非常奇怪的错误:

! Undefined control sequence.
\select@language ... \@empty }\languageshorthands 
                                                  {none}\babel@beginsave \cs...
l.8 \begin{document}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Undefined control sequence.
\select@language ...me \relax \babel@savevariable 
                                                  \lefthyphenmin \babel@save...
l.8 \begin{document}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Undefined control sequence.
\select@language ...hyphenmin \babel@savevariable 
                                                  \righthyphenmin \expandaft...
l.8 \begin{document}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

Class scrlttr2 Info: used language is `english'.
(scrlttr2)           Supported languages are `english', `UKenglish',
(scrlttr2)           `british', `american', `USenglish',
(scrlttr2)           `german', `ngerman', `austrian', `naustrian',
(scrlttr2)           `dutch', `italian', `spanish',
(scrlttr2)           `croatian', `finnish', `norsk' on input line 8.

注意:即使我删除了所有输出文件(包括 aux),我还是会收到此错误!据我所知,KOMA-ScriptDIN.lco不需要 babel,但错误消息表明某处有 babel 残留。如果是这样,我不知道在哪里,因为我在编译之前删除了所有我能看到的。我读过这个帖子这个帖子已经。

所用文件(来自\listfiles)为:

 *File List*
scrlttr2.cls    2012/07/29 v3.11b KOMA-Script document class (letter)
scrkbase.sty    2012/07/29 v3.11b KOMA-Script package (KOMA-Script-dependent ba
sics and keyval usage)
 scrbase.sty    2012/07/29 v3.11b KOMA-Script package (KOMA-Script-independent 
basics and keyval usage)
  keyval.sty    1999/03/16 v1.13 key=value parser (DPC)
scrlfile.sty    2012/06/15 v3.12 KOMA-Script package (loading files)
scrsize12pt.clo    2012/07/29 v3.11b KOMA-Script font size class option (12pt)
typearea.sty    2012/07/29 v3.11b KOMA-Script package (type area)
     DIN.lco    2012/07/29 v3.11b KOMA-Script letter-class-option
UScommercial9.lco
 ***********

如果相关的话,我在编译时使用 XeTeX。

答案1

请尝试以下 MWE(我稍微更改了您的 MWE)。它应该可以满足您的要求:

\documentclass[UScommercial9,paper=letter]{scrlttr2} % <==== changed
\usepackage[english]{babel}
\usepackage[pass]{geometry}                          % <==== changed

\KOMAoptions{fromphone=true,fromfax=false}           % <==== changed

\begin{document}

\setkomavar{fromname}{Stephen Bosch}
\setkomavar{fromaddress}{10 Lemon Lane \\ Sour Orchards BC V0E 0B0}
\setkomavar{fromphone}{+1 250 377 4141}

\begin{letter}{Tremulor Nocharme \\ Compliance Officer \\ Special TPS Police
\\ Fram Jammer Building \\ 320, 220 -- 4 Street \\ Treacleton AB T0M 0M0}

\setkomavar{subject}{Late TPS reports 2008, 2009, 2010, 2011, 2012}

\opening{Dear Mr. Nocharme,}

Attached please find the TPS reports you requested. Please accept my apologies for the delay.\\

\closing{Sincerely,}

\end{letter}

\end{document}

诀窍在于您的tex发行版具有 A4 标准纸张尺寸。使用命令,\usepackage[pass]{geometry}您可以建议 LaTeX 使用 MWE 给定的纸张尺寸。使用 pdfLaTeX 和 XeTeX 它可以工作。

更新: 我不知道 KOMA-Script 选项pagesize(感谢 @Josef),它还会强制 LaTeX 用给定的纸张大小(这里是 letter)编写 pdf 文件。因此,您可以将我的 MWE 更改为(仅更改第一行):

\documentclass[%
  paper=letter  % paper size
 ,pagesize      % force given paper size in pdf
 ,UScommercial9 % Beta version for testing
]{scrlttr2}
\usepackage[english]{babel}

\KOMAoptions{fromphone=true,fromfax=false}

更新 2: 由于 KOMA-Script 3.17 选项pagesize是默认选项。因此您无需明确设置或加载它geometry(@Schweinebacke 的评论)。

相关内容