-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscrkernel-letterclassoptions.dtx
More file actions
1739 lines (1739 loc) · 58.2 KB
/
scrkernel-letterclassoptions.dtx
File metadata and controls
1739 lines (1739 loc) · 58.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% \iffalse meta-comment
% ======================================================================
% scrkernel-letterclassoptions.dtx
% Copyright (c) Markus Kohm, 2006-2023
%
% This file is part of the LaTeX2e KOMA-Script bundle.
%
% This work may be distributed and/or modified under the conditions of
% the LaTeX Project Public License, version 1.3c of the license.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2005/12/01 or later and of this work.
%
% This work has the LPPL maintenance status "author-maintained".
%
% The Current Maintainer and author of this work is Markus Kohm.
%
% This work consists of all files listed in MANIFEST.md.
% ======================================================================
%%% From File: $Id: scrkernel-letterclassoptions.dtx 4032 2023-04-17 09:45:11Z kohm $
%<option>%%% (run: option)
%<head>%%% (run: head)
%<body>%%% (run: body)
%<*dtx>
\ifx\ProvidesFile\undefined\def\ProvidesFile#1[#2]{}\fi
\begingroup
\def\filedate$#1: #2-#3-#4 #5${\gdef\filedate{#2/#3/#4}}
\filedate$Date: 2023-04-17 11:45:11 +0200 (Mon, 17 Apr 2023) $
\def\filerevision$#1: #2 ${\gdef\filerevision{r#2}}
\filerevision$Revision: 4032 $
\endgroup
\ProvidesFile{scrkernel-letterclassoptions.dtx}
[\filedate\space \filerevision\space
KOMA-Script source (letter configuration options)]
\documentclass[USenglish]{koma-script-source-doc}
\usepackage{babel}
\setcounter{StandardModuleDepth}{2}
\begin{document}
\DocInput{scrkernel-letterclassoptions.dtx}
\end{document}
%</dtx>
% \fi
%
% \changes{v2.95}{2006/03/22}{new by splitting \file{scrclass.dtx}}
% \changes{v3.36}{2022/02/26}{switch over from \cls*{scrdoc} to
% \cls*{koma-script-source-doc}}
% \changes{v3.36}{2022/02/26}{\cs{@setplength} replaced by \cs{setplength}}
% \changes{v3.36}{2022/02/26}{\cs{@addtoplength} replaced by \cs{addtoplength}}
% \changes{v3.36}{2022/02/26}{\cs{@newplength} replaced by \cs{newplength}}
% \changes{v3.36}{2022/02/26}{whole implementation documentation in English}
% \changes{v3.40}{2023/04/17}{guide names changed}
%
%
% \GetFileInfo{scrkernel-letterclassoptions.dtx}
% \title{Handling and Implementation of Letter Configuration Options of
% \href{https://komascript.de}{\KOMAScript} Letter Class and Package}
% \author{\href{mailto:komascript@gmx.info}{Markus Kohm}}
% \date{Revision \fileversion{} of \filedate}
% \maketitle
% \begin{abstract}
% The \KOMAScript{} letter class \cls*{scrlttt2} and the \KOMAScript{}
% letter package \pkg*{scrletter} has something special: the letter
% configuration option files formerly known as letter class option
% files. These are used to setup either layouts or user configurations. Both
% the implementation of these files and the handling of them can be found in
% \file{scrkernel-letterclassoptions.dtx}.
% \end{abstract}
% \tableofcontents
%
% \section{User Manual}
%
% You can find the user documentation the commands and files implemented here
% in the \KOMAScript{} manual, either the German \file{scrguide-de.pdf} or the
% English \file{scrguide-en.pdf}.
%
% \MaybeStop{\PrintIndex}
%
% \section{Implementation of the Handling of Letter Configuration Options}
%
% We need this feature only with letter classes and packages.
%
% \begin{macrocode}
%<*(class|package)&letter>
% \end{macrocode}
%
%
% \subsection{Options for the letter configuration option files}
%
% \begin{macro}{\lco@test}
% \changes{v2.95}{2006/03/22}{added}
% \changes{v2.97c}{2007/09/12}{modified for new option handling}
% \changes{v3.36}{2022/02/26}{deprecated}
% The \KOMAScript{} letter class \cls*{scrlttr2} allows to load a letter
% configuration option file by classic class options to \cs{documentclass},
% \cs{LoadClass} or \cs{PassOptionsToClass}. This is done inside via the
% general \cs{DeclareOption*}, that is used for several other deprecated (and
% some standard) options too. \cs{lco@test} simply tests, if
% \file{\CurrentOption.lco} does exist and in this case load it a the end of
% the class. Note: The \KOMAScript{} letter package \pkg*{scrletter} does not
% support loading of letter configuration option files via global or package
% option. Moreover, from \KOMAScript{} v3.36 loading via class option is also
% deprecated for \cls*{scrlttr2}.
% \begin{macrocode}
%<*class&option>
\newcommand*{\lco@test}{%
\IfFileExists{\CurrentOption.lco}{%
\ClassWarningNoLine{\KOMAClassName}{%
loading of LCO via class option
`\CurrentOption'.\MessageBreak
Note: Loading a LCO via class option is deprecated.\MessageBreak
\space\space\space\space\space\space
You should use
`\string\LoadLetterOption\string{\CurrentOption\string}'\MessageBreak
instead%
}%
\expandafter\AtEndOfClass\expandafter{%
\expandafter\LoadLetterOption\expandafter{\CurrentOption}%
}%
\expandafter\def\expandafter\scr@pti@nerr@r\expandafter{%
\expandafter\def\expandafter\scr@pti@nerr@r\expandafter{%
\scr@pti@nerr@r
}%
}%
}{}%
}
%</class&option>
% \end{macrocode}
% \end{macro}
%
% \file{DIN.lco} is the default and therefore loaded first at the end of the
% class or package.
% \begin{macrocode}
%<*option>
%<class>\AtEndOfClass
%<package>\AtEndOfPackage
{\LoadLetterOption{DIN}}
%</option>
% \end{macrocode}
%
%
% \subsection{Makros für Letter-Class-Options}
%
% \begin{command}{\LoadLetterOption}
% \changes{v2.8q}{2001/10/08}{added}
% \changes{v3.14}{2014/10/04}{ignoring white spaced}
% \changes{v3.26}{2018/08/29}{\cs{KV@@sp@def} replaced by \cs{scr@sp@def}}
% Command
% \begin{quote}
% \cs{LoadLetterOption}\marg{letter configuration option}
% \end{quote}
% loads \file{\meta{letter configuration option}.lco}. The \cs{catcode} of
% ``|@|'' is changed to letter for loading the file. But because \file{lco}
% files can load other \file{lco} files using \cs{LoadLetterOption} this has
% to be reset only for the outer \cs{LoadLetterOption}.
% \begin{description}
% \item[ToDo:] can't we do this more simply just using either some
% \cs{expandafter} magic or an internal stack?
% \end{description}
% \begin{macrocode}
%<*body>
\newcommand*{\LoadLetterOption}[1]{%
\@ifundefined{@restore@catcode@level}%
{\let\@restore@catcode@level=\z@}{}%
\ifnum\@restore@catcode@level =\z@
\ifnum\catcode`\@=11
\let\@restore@catcode\relax
\else
\@tempcnta=\catcode`\@
\edef\@restore@catcode{%
\noexpand\catcode`\noexpand\@=\the\@tempcnta}%
\makeatletter
\fi
\fi
\@tempcnta=\@restore@catcode@level\relax
\advance\@tempcnta by \@ne\relax
\edef\@restore@catcode@level{\the\@tempcnta}%
\scr@sp@def\reserved@a{#1}%
\edef\reserved@a{%
\noexpand\edef\noexpand\scr@currentlco{\reserved@a}%
% \end{macrocode}
% \changes{v3.99}{2022/10/25}{local definition of \cs{scr@compatibility}}
% For compatibility of old \file{lco} files with \KOMAScript~4 we locally
% define \cs{scr@compatibility} to the highest possible number.
% \begin{macrocode}
%<*v4>
\ifdefined\scr@compatibility\else
\noexpand\edef\noexpand\scr@compatibility{\the\maxdimen}%
\fi
%</v4>
\noexpand\InputIfFileExists{\reserved@a.lco}{%
%<class> \noexpand\ClassInfo{scrlttr2}%
%<package> \noexpand\PackageInfo{scrletter}%
{Letter-Class-Option `#1' loaded}%
}{%
%<class> \noexpand\ClassError{scrlttr2}%
%<package> \noexpand\PackageError{scrletter}%
{%
Letter-Class-Option file `#1.lco' not found%
}{%
You've told me to load the Letter-Class-Option `#1'. So I have
to load\noexpand\MessageBreak
the file `#1.lco'. But the file isn't available.}%
}%
%<*v4>
\ifdefined\scr@compatibility
\noexpand\def\noexpand\scr@compatibility{\scr@compatibility}%
\else
\unexpanded{\let\scr@compatibility\undefined}%
\fi
%</v4>
\scr@ifundefinedorrelax{scr@currentlco}{%
\unexpanded{\let\scr@currentlco\relax}%
}{%
\noexpand\def\noexpand\scr@currentlco{\scr@currentlco}%
}%
}%
% \end{macrocode}
% \changes{v3.18}{2015/06/03}{manage \cs{RequirePackage} and \cs{usepackage}
% inside \texttt{lco}-files after \cs{begin\{document\}}}
% \changes{v3.28}{2019/11/24}{\cs{usepackage} typo fixed}
% \begin{description}
% \item[ToDo:] I don't think, that the following really works. So maybe it
% should simple be removed to get the usual error message using
% \cs{RequirePackage} or \cs{usepackage} inside a document.
% \end{description}
% \begin{macrocode}
\if@atdocument
\edef\reserved@a{%
\unexpanded\expandafter{\reserved@a}%
\ifx\RequirePackage\@notprerr
\unexpanded{\let\RequirePackage\@notprerr}%
\else
\noexpand\def\noexpand\RequirePackage{%
\unexpanded\expandafter{\RequirePackage}%
}%
\fi
\ifx\usepackage\@notprerr
\unexpanded{\let\usepackage\@notprerr}%
\else
\noexpand\def\noexpand\usepackage{%
\unexpanded\expandafter{\usepackage}%
}%
\fi
}%
\let\RequirePackage\lco@RequirePackage
\let\usepackage\lco@RequirePackage
\expandafter\reserved@a
\else \expandafter\reserved@a
\fi
\@tempcnta=\@restore@catcode@level\relax
\advance\@tempcnta by \m@ne\relax
\edef\@restore@catcode@level{\the\@tempcnta}%
\ifnum\@tempcnta =\z@
\@restore@catcode
\fi
}
% \end{macrocode}
% \begin{macro}{\lco@RequirePackage}
% \changes{v3.18}{2015/06/03}{added}
% \changes{v3.26}{2018/08/29}{\cs{KV@@sp@def} replaced by
% \cs{scr@trim@spaces}}
% \begin{description}
% \item[ToDo:] See the note above.
% \end{description}
% \begin{macrocode}
\newcommand*{\lco@RequirePackage}[2][]{%
\begingroup
\@for\reserved@a:=#2\do{%
\scr@trim@spaces\reserved@a
\scr@ifundefinedorrelax{ver@\reserved@a.\scr@pkgextension}{%
%<class> \ClassError{\KOMAClassName}{%
%<package> \PackageError{scrletter}{%
lco-file `\scr@currentlco' can be used only in preamble%
}{%
The lco-file `\scr@currentlco' uses \string\RequirePackage\space or
\string\usepackage\space to load\MessageBreak
package `\reserved@a'. This means you have to either load
`\reserved@a'\MessageBreak
or lco-file `\scr@currentlco' in the document preamble.
}%
}{}%
}%
\endgroup
\scr@gobbleopt
}
% \end{macrocode}
% \end{macro}^^A \lco@RequirePackage
% \end{command}^^A \LoadLetterOption
%
% \begin{command}{\LoadLetterOptions}
% \changes{v3.14}{2014/10/04}{added}
% \changes{v3.26}{2018/08/29}{\cs{scr@trim@spaces} added}
% \changes{v3.26}{2018/08/29}{special treatment of space entries not needed
% any more}
% Similar to \cs{LoadLetterOption} but with \meta{list of letter configuration
% options} instead of a single \meta{letter configuration option}.
% \begin{macrocode}
\newcommand*{\LoadLetterOptions}[1]{%
\begingroup
\def\reserved@a{\endgroup}%
\@for\reserved@b:=#1\do{%
\scr@trim@spaces\reserved@b
\ifx\reserved@b\@empty\else
\edef\reserved@a{\expandafter\unexpanded\expandafter{\reserved@a
\LoadLetterOption}{\reserved@b}\relax}%
\fi
}%
\reserved@a
}
% \end{macrocode}
% \end{command}^^A \LoadLetterOptions
%
% \begin{command}{\LetterOptionNeedsPapersize}
% \changes{v2.8q}{2001/10/17}{added}
% With
% \begin{quote}
% \cs{LetterOptionNeedsPapersize}\marg{letter configuration
% option}\marg{paper size}
% \end{quote}
% inside a \meta{letter configuration option} file we can define a \meta{paper
% size} to be used. This does not change the paper size, but adds a test to
% \cs{opening}, that warns if another paper size is used.
% \begin{macro}{\@PapersizeWarning}
% \changes{v2.8q}{2002/03/25}{added}
% \changes{v3.12}{2013/11/05}{differences of +/- 1\,mm are tolerated}
% \changes{v3.23}{2017/02/22}{using \cs{PaperNameToSize}}
% \begin{macro}{\@@PapersizeWarning,\LOPNP@size,\LOPNP@option}
% \changes{v2.8q}{2002/03/25}{added}
% \begin{macrocode}
\newcommand*{\LOPNP@option}{}
\newcommand*{\LOPNP@size}{}
\newcommand*{\@PapersizeWarning}{%
\begingroup%
\edef\@tempc{\noexpand\@tempswafalse
\noexpand\ifdim\paperwidth<\the\dimexpr\paperwidth-.1mm\relax
\relax
\noexpand\else
\noexpand\ifdim\paperwidth>\the\dimexpr\paperwidth+.1mm\relax
\relax
\noexpand\else
\noexpand\ifdim\paperheight<\the\dimexpr\paperheight-.1mm\relax
\relax
\noexpand\else
\noexpand\ifdim\paperheight>\the\dimexpr\paperheight+.1mm\relax
\relax
\noexpand\else
\noexpand\@tempswatrue
\noexpand\fi
\noexpand\fi
\noexpand\fi
\noexpand\fi
\noexpand\@@PapersizeWarning
}%
\def\@tempb{letter}\ifx\LOPNP@size\@tempb%
\setlength{\paperheight}{11in}\setlength{\paperwidth}{8.5in}%
\else\def\@tempb{legal}\ifx\LOPNP@size\@tempb%
\setlength{\paperheight}{14in}\setlength{\paperwidth}{8.5in}%
\else\def\@tempb{executive}\ifx\LOPNP@size\@tempb%
\setlength{\paperheight}{10.5in}\setlength{\paperwidth}{7.25in}%
\else%
\PaperNameToSize[letter]{\LOPNP@size}%
\fi
\fi
\fi
\@tempc
\endgroup%
}
%<class>\AfterPackage*{typearea}{%
\ProvideUnknownPaperSizeError{letter}{%
%<class> \ClassError{scrlttr2}{%
%<package> \PackageError{scrletter}{%
papersize `\LOPNP@size' undefined}{%
You've told me to check for paper size
`\LOPNP@size'\MessageBreak
at letter option file `\LOPNP@option.lco',\MessageBreak
but this paper size is not supported.\MessageBreak
See the KOMA-Script manual for informations about known
paper sizes.}%
}
%<class>}
\newcommand*{\@@PapersizeWarning}{%
\if@tempswa\else%
%<class> \ClassWarningNoLine{scrlttr2}%
%<package> \PackageWarningNoLine{scrletter}%
{%
Letter option file `\LOPNP@option.lco'\MessageBreak
needs paper size `\LOPNP@size'.\MessageBreak
Current paper size is not `\LOPNP@size'!\MessageBreak
\scr@ifundefinedorrelax{KOMAClassName}{%
You should load package `typearea' either\MessageBreak
with option `paper=\LOPNP@size,paper=portrait' or
additionally\MessageBreak
}{%
You should add `paper=\LOPNP@size,paper=portrait' at the\MessageBreak
option list of `\string\documentclass' or\MessageBreak
}%
add `\string\KOMAoptions{paper=\LOPNP@size,paper=portrait}'\MessageBreak
before starting this letter!\MessageBreak
Maybe you know what you are doing,\MessageBreak
so I do not change this myself%
}%
\fi
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macrocode}
\newcommand*{\LetterOptionNeedsPapersize}[2]{%
\edef\LOPNP@size{#2}\edef\LOPNP@option{#1}%
}
%</body>
% \end{macrocode}
% \end{command}
%
% \begin{macrocode}
%</(class|package)&letter>
% \end{macrocode}
%
% \section{Implementation of the Letter Configuration Option Files}
%
% Most of the predefined letter configuration option files define a letter
% layout, e.g, depending on a norm. The main thing in this case is to setup
% pseudo-lengths. Sometimes additionally macros or commands are (re-)defined.
%
% \begin{macrocode}
%<*lco>
% \end{macrocode}
%
% \subsection{The file header}
%
% The head has to identify the file:
% \changes{v3.04}{2009/04/21}{\file{NF.lco} by Jean-Marie Pacquet added}
% \changes{v3.04}{2009/06/26}{\file{USletter2w.lco} with contribution of
% Engelbert Buxbaum and Richard Ar\`es}
% \changes{v3.04}{2009/06/29}{\file{UScommercial9DW-lco} for paper formats
% letter or legal and envelopes with format no.\,9 with two windows}
% \changes{v3.04}{2009/06/30}{\file{UScommercial9} for paper formats
% letter or legal and envelopes with format commercial No.\,9 with one
% window based on \url{http://www.envelopesuperstore.com/}}
% \changes{v3.04}{2009/06/26}{long existing \file{visualize.lco} added}
% \changes{v3.17}{2015/02/17}{\file{DIN5008A.lco} and \file{DIN5008B.lco} added}
% \begin{macrocode}
%<*head>
\ProvidesFile{%
%<visualize> visualize%
%<DIN> DIN%
%<5008> 5008%
%<A> A%
%<B> B%
%<DINmoretext> DINmtext%
%<SN> SN%
%<SNold> SNold%
%<SwissLeft> SNleft%
%<KOMAold> KOMAold%
%<NF> NF%
%<USletter2w> USletter2w
%<UScommercial9> UScommercial9
%<UScommercial9DW> UScommercial9DW
.lco}[\KOMAScriptVersion\space letter-class-option]
% \end{macrocode}
%
% Some of the \file{LCO} files need others:
% \begin{macrocode}
%<*5008>
\LoadLetterOption{%
%<A> DINmtext%
%<B> DIN%
}
%</5008>
% \end{macrocode}
%
% \begin{command}{\LCOWarningNoLine,\LCOWarning}
% \changes{v2.95}{2006/03/24}{added}
% These are similar to \cs{PackageWarningNoLine} and \cs{PackageWarning} but
% for \file{lco} files.
% \begin{macrocode}
%<*!5008>
\providecommand*\LCOWarningNoLine[2]{%
\LCOWarning{#1}{#2\@gobble}%
}
\providecommand*\LCOWarning[2]{%
\GenericWarning{%
(#1)\@spaces\@spaces\@spaces\@spaces\@spaces\@spaces\@spaces\@spaces
}{%
Letter configuration option #1 Warning: #2%
}%
}
%</!5008>
%</head>
% \end{macrocode}
% \end{command}
%
%
% \subsection{Main part of layout option files}
%
% The dimensions of some of the options has been researched by others:
% \begin{center}
% \begin{tabular}{ll}
% \texttt{lco} file & source \\\hline\\[-1.6ex]
% DIN & me \\
% DINmtext & me \\
% DIN5008A & me \\
% DIN5008B & me \\
% KOMAold & me \\
% SNleft & Roger Luethi \\
% SN & Roger Luethi \\
% NF & Jean-Marie Pacquet \\
% USletter2w & Engelbert Buxbaum \\
% UScommercial9 & me \\
% UScommercial9DW & me \\
% \end{tabular}
% \end{center}
%
% Test for the correct class or package:
% \begin{macrocode}
%<*body&!visualize>
%<*!5008>
\@ifundefined{scr@fromname@var}{%
\LCOWarningNoLine{%
%<DIN> DIN%
%<DINmoretext> DINmtext%
%<SN> SN%
%<SNold> SNold%
%<SwissLeft> SNleft%
%<KOMAold> KOMAold%
%<NF> NF%
%<USletter2w> USletter2w%
%<UScommercial9> UScommercial9%
%<UScommercial9DW> UScommercial9DW%
}{%
This letter configuration option file was made only\MessageBreak
to be used with KOMA-Script letter class\MessageBreak
`scrlttr2' or letter package `scrletter'.\MessageBreak
Use with other classes and without that package\MessageBreak
can result in a lot of errors%
}%
}{}
% \end{macrocode}
%
% Make sure, the correct paper size has been used:
% \begin{macrocode}
\LetterOptionNeedsPapersize{%
%<DIN> DIN%
%<DINmoretext> DINmtext%
%<SN> SN%
%<SNold> SNold%
%<SwissLeft> SNleft%
%<KOMAold> KOMAold%
%<NF> NF%
%<USletter2w> USletter2w%
%<UScommercial9> UScommercial9%
%<UScommercial9DW> UScommercial9DW%
%<*DIN|DINmoretext|SN|SNold|SwissLeft|KOMAold|NF>
}{a4}
%</DIN|DINmoretext|SN|SNold|SwissLeft|KOMAold|NF>
%<*USletter2w|UScommercial9|UScommercial9DW>
}{letter}
%</USletter2w|UScommercial9|UScommercial9DW>
% \end{macrocode}
%
% And now the dimensions and variables:
% \begin{variable}{fromzipcode}
% \changes{v3.03}{2009/03/04}{change of output name added}
% \begin{macrocode}
%<!KOMAold>\setkomavar*{fromzipcode}{%
%<DIN|DINmoretext> D}
%<SwissLeft|SN> CH}
%<NF> F}
%<USletter2w|UScommercial9|UScommercial9DW> US}
% \end{macrocode}
% \end{variable}
% \begin{pseudolength}{foldmarkhpos,tfoldmarkvpos,mfoldmarkvpos,bfoldmarkvpos,
% lforlmarkhpos}
% \changes{v2.97e}{2007/11/20}{several new fold marks to setup}
% \begin{macrocode}
\setplength{foldmarkhpos}{3.5mm}
\setplength{tfoldmarkvpos}{%
%<DIN|SwissLeft|SN> 105mm}
%<DINmoretext> 87mm}
%<KOMAold> 103.5mm}
%<NF> 99mm}
%<USletter2w|UScommercial9|UScommercial9DW> 3.75in}
\setplength{mfoldmarkvpos}{\z@}
\setplength{bfoldmarkvpos}{%
%<DIN|SwissLeft|SN> 210mm}
%<DINmoretext> 192mm}
%<KOMAold> 202.5mm}
%<NF> 198mm}
%<USletter2w> 7.4in}
%<UScommercial9|UScommercial9DW> 7.375in}
\setplength{lfoldmarkhpos}{\z@}
% \end{macrocode}
% \end{pseudolength}
% \begin{pseudolength}{toaddrvpos,toaddrhpos,toaddrwidth,toaddrheight,
% backaddrheight,specialmainindent,specialmailrightindent}
% \changes{v3.03}{2009/06/25}{the documentation says, the back-address is part
% of the address field}
% \begin{macrocode}
\setplength{toaddrvpos}{%
%<DIN|SN> 45mm}
%<DINmoretext> 27mm}
%<SwissLeft> 35.5mm}
%<KOMAold> 49mm}
%<NF> 35mm}
%<USletter2w> 1.8in}
%<UScommercial9|UScommercial9DW> 2.1875in}
\setplength{toaddrhpos}{%
%<DIN|DINmoretext|SwissLeft> 20mm}
%<SN> -8mm}
%<KOMAold> 1in}
%<KOMAold>\addtoplength{toaddrhpos}{\oddsidemargin}
%<NF> -10mm}
%<USletter2w> .73in}
%<UScommercial9> 0.6875in}
%<UScommercial9DW> .5625in}
\setplength{toaddrwidth}{%
%<DIN|DINmoretext> 85mm}
%<SN> 90mm}
%<SwissLeft|NF> 100mm}
%<KOMAold> 70mm}
%<USletter2w> 3.11in}
%<UScommercial9> 4.5in}
%<UScommercial9DW> 3.625in}
\setplength{toaddrheight}{%
%<DIN|DINmoretext|SN|SwissLeft|KOMAold|NF> 45mm}
%<USletter2w> 1.17in}
%<UScommercial9|UScommercial9DW> 1.125in}
%</!5008>
\setplength{toaddrindent}{%
%<DIN|DINmoretext|SN|SwissLeft|KOMAold|USletter2w|UScommercial9|UScommercial9DW> \z@}
%<5008> 5mm}
%<NF> 10mm}
%<*!5008>
\setplength{backaddrheight}{%
%<DIN|DINmoretext|SN|SwissLeft|KOMAold|NF> 5mm}
%<USletter2w|UScommercial9|UScommercial9DW> \z@}
%<USletter2w|UScommercial9|UScommercial9DW>\KOMAoptions{backaddress=false}
\setplength{specialmailindent}{\fill}
\setplength{specialmailrightindent}{1em}
%</!5008>
%<*5008>
\setplength{specialmailindent}{\useplength{toaddrindent}}
\setplength{specialmailrightindent}{\z@}
%</5008>
% \end{macrocode}
% \end{pseudolength}
% \begin{pseudolength}{locvpos,locwidth,lochpos}
% \begin{macrocode}
%<*5008>
\setplength{locvpos}{%
\dimexpr\useplength{toaddrvpos}+\useplength{backaddrheight}}
%</5008>
\setplength{locwidth}{%
%<DIN|DINmoretext|SN|SwissLeft|KOMAold|NF|USletter2w|UScommercial9|UScommercial9DW> \z@}
%<5008> 75mm}
%<5008>\setplength{lochpos}{10mm}
%<*!5008>
% \end{macrocode}
% \end{pseudolength}
% \begin{pseudolength}{firstheadvpos,firstheadhpos,firstheadwidth}
% \begin{macrocode}
\setplength{firstheadvpos}{%
%<DIN|DINmoretext|SN|SwissLeft> 8mm}
%<KOMAold> 6mm}
%<NF> 15mm}
%<USletter2w> .36in}
%<UScommercial9|UScommercial9DW> .4375in}
%</!5008>
%<*5008>
\setplength{firstheadhpos}{%
\dimexpr \useplength{toaddrhpos}+\useplength{toaddrindent}}
%</5008>
\setplength{firstheadwidth}{%
%<KOMAold> \textwidth}
%<NF> 170mm}
%<*DIN|DINmoretext|SN|SwissLeft|UScommercial9>
\paperwidth}
\ifdim \useplength{toaddrhpos}>\z@
\addtoplength[-2]{firstheadwidth}{\useplength{toaddrhpos}}
\else
\addtoplength[2]{firstheadwidth}{\useplength{toaddrhpos}}
\fi
%</DIN|DINmoretext|SN|SwissLeft|UScommercial9>
%<5008> \dimexpr 125mm-\useplength{firstheadhpos}}
%<*USletter2w>
\paperwidth}
\addtoplength[-]{firstheadwidth}{.68in}
%</USletter2w>
%<*UScommercial9DW>
\paperwidth}
\addtoplength[-]{firstheadwidth}{.25in}
%</UScommercial9DW>
% \end{macrocode}
% \end{pseudolength}
% \begin{pseudolength}{firstfootwidth,firstfootvpos}
% \changes{v2.9u}{2005/03/05}{optional the footer is placed 16\,mm above the
% lower paper edge}
% \begin{macrocode}
%<!5008>\setplength{firstfootwidth}{\useplength{firstheadwidth}}
%<*5008>
\setplength{firstfoothpos}{%
\dimexpr\useplength{toaddrhpos}+\useplength{toaddrindent}}%
\setplength{firstfootwidth}{%
\dimexpr \paperwidth-\useplength{toaddrhpos}-\useplength{firstfoothpos}}%
%</5008>
%<KOMAold>\setplength{firstfootvpos}{\paperheight}
%<KOMAold>\addtoplength{firstfootvpos}{-2cm}
%<!KOMAold&!NF>\setplength{firstfootvpos}{\paperheight}
%<!KOMAold&!NF>\addtoplength{firstfootvpos}{-16mm}
%<!KOMAold&!NF>\scr@ifundefinedorrelax{scr@v@is@le}{}{%
%<!KOMAold&!NF> \expandafter\ifnum \scr@v@is@le{2.9t}\relax\else
%<!KOMAold&!NF> \setplength{firstfootvpos}{1in}%
%<!KOMAold&!NF> \addtoplength{firstfootvpos}{\topmargin}%
%<!KOMAold&!NF> \addtoplength{firstfootvpos}{\headheight}%
%<!KOMAold&!NF> \addtoplength{firstfootvpos}{\headsep}%
%<!KOMAold&!NF> \addtoplength{firstfootvpos}{\textheight}%
%<!KOMAold&!NF> \addtoplength{firstfootvpos}{\footskip}%
%<!KOMAold&!NF> \fi
%<!KOMAold&!NF>}%
%<NF>\setplength{firstfootvpos}{266.679mm}
% \end{macrocode}
% \end{pseudolength}
% \begin{pseudolength}{refvpos,refaftervskip,refwidth}
% \begin{macrocode}
%<!(5008&B)>\setplength{refvpos}{%
%<DIN|SN> 98.5mm}
%<DINmoretext> 80.5mm}
%<5008&A> 79.4mm}
%<SwissLeft> 89mm}
%<KOMAold> 89.5mm}
%<NF> \useplength{tfoldmarkvpos}}
%<USletter2w> 3.1in}
%<UScommercial9|UScommercial9DW> 3.4375in}
\setplength{refaftervskip}{%
%<!KOMAold&!5008> \baselineskip}
%<KOMAold> 2\baselineskip}
%<5008> 8.46mm}
%<*!5008>
% \end{macrocode}
% The width of the reference line is somehow special, because setting of
% option \opt{refline=wide} or \opt{refline=narrow} should be possible after
% loading a \file{lco} file. So we use the initial special value 0 and
% calculate it inside \cs{opening} if it is still 0.
% \begin{macrocode}
\setplength{refwidth}{0pt}
% \end{macrocode}
% \end{pseudolength}
% \begin{pseudolength}{sigindent,sigbeforevskip}
% \begin{macrocode}
\setplength{sigindent}{0mm}
\setplength{sigbeforevskip}{2\baselineskip}
%<DIN|DINmoretext|SN|SwissLeft>\let\raggedsignature=\centering
%<KOMAold|NF|USletter2w|UScommercial9|UScommercial9DW>\let\raggedsignature=\raggedright
% \end{macrocode}
% \end{pseudolength}
% \begin{macro}{\scr@default@firsthead@fromaddress@hook}
% \changes{v3.13b}{2014/04/02}{added}
% \changes{v3.27}{2019/04/02}{removed}
% \end{macro}
%
% \begin{command}{\yourref,\yourmail,\myref,\customer,\invoice,\defaultfields,
% \toname,\toaddress,\branch,\signature,\fromsig,\name,
% \fromname,\location,\fromlocation,\backaddress,
% \frombackaddress,\telephone,\telephonenum,\specialmail,
% \title,\subject,\place,\fromplace,\ccnameseparator,
% \enclnameseparator,\foldmarkson,\foldmarksoff,\addrfieldon,
% \addrfieldoff,\subjecton,\subjectoff,\subjectafteron,
% \subjectafteroff}
% \begin{macro}{\@title,\@subject}
% \begin{variable}{refitemi,refitemii,refitemiii,branch}
% We have also to do the compatibility commands and variables for
% \file{KOMAold.lco}.
% \begin{macrocode}
%<*KOMAold>
\def\yourref{\setkomavar{yourref}}
\def\yourmail{\setkomavar{yourmail}}
\def\myref{\setkomavar{myref}}
\def\customer{\setkomavar{customer}}
\def\invoice{\setkomavar{invoice}}
\@ifundefined{scr@refitemi@var}{\newkomavar{refitemi}}{}
\def\refitemi{\setkomavar{refitemi}}
\def\refitemnamei{\setkomavar*{refitemi}}
\@ifundefined{scr@refitemii@var}{\newkomavar{refitemii}}{}
\def\refitemii{\setkomavar{refitemii}}
\def\refitemnameii{\setkomavar*{refitemii}}
\@ifundefined{scr@refitemiii@var}{\newkomavar{refitemiii}}{}
\def\refitemiii{\setkomavar{refitemiii}}
\def\refitemnameiii{\setkomavar*{refitemiii}}
\l@addto@macro{\defaultreffields}{%
\addtoreffields{refitemi}%
\addtoreffields{refitemii}%
\addtoreffields{refitemiii}%
}
\addtoreffields{refitemi}%
\addtoreffields{refitemii}%
\addtoreffields{refitemiii}%
\def\toname{\usekomavar{toname}}
\def\toaddress{\usekomavar{toaddress}}
\@ifundefined{scr@branch@var}{\newkomavar{branch}}{}
\def\branch{\setkomavar{branch}}
\def\frombranch{\usekomavar{branch}}
\def\signature{\setkomavar{signature}}
\def\fromsig{\usekomavar{signature}}
\def\name{\setkomavar{fromname}}
\def\fromname{\usekomavar{fromname}}
\def\address{\setkomavar{fromaddress}}
\def\fromaddress{\usekomavar{fromaddress}}
\def\location{\setkomavar{location}}
\def\fromlocation{\usekomavar{location}}
\def\backaddress{\setkomavar{backaddress}}
% \end{macrocode}
% \changes{v3.28}{2019/11/15}{\cs{ifkomavarempty} replaced by
% \cs{Ifkomavarempty}}
% Note: This is dangerous if someone uses a new \KOMAScript{} but copies the
% wrong code.
% \begin{macrocode}
\def\@tempa{%
\Ifkomavarempty{fromname}{}{%
\strut\ignorespaces\usekomavar{fromname}%
\Ifkomavarempty{fromaddress}{}{\\}}%
\Ifkomavarempty{fromaddress}{}{%
\strut\ignorespaces\usekomavar{fromaddress}}%
}
\ifx\@tempa\scr@backaddress@var%
\setkomavar{backaddress}{}
\else
\def\@tempa{%
\ifkomavarempty{fromname}{}{%
\strut\ignorespaces\usekomavar{fromname}%
\ifkomavarempty{fromaddress}{}{\\}}%
\ifkomavarempty{fromaddress}{}{%
\strut\ignorespaces\usekomavar{fromaddress}}%
}
\ifx\@tempa\scr@backaddress@var%
\setkomavar{backaddress}{}
\fi
\fi
\def\frombackaddress{\usekomavar{backaddress}}
\def\telephone{\setkomavar{fromphone}}
\def\telephonenum{\usekomavar{fromphone}}
\def\specialmail{\setkomavar{specialmail}}
\def\@specialmail{\usekomavar{specialmail}}
\def\title{\setkomavar{title}}
\def\@title{\usekomavar{title}}
\def\subject{\setkomavar{subject}}
\def\@subject{\usekomavar{subject}}
\def\place{\setkomavar{place}}
\def\fromplace{\usekomavar{place}}
\let\ccnameseparator=\scr@ccseparator@var
\setkomavar{ccseparator}{\ccnameseparator}
\let\enclnameseparator=\scr@enclseparator@var
\setkomavar{enclseparator}{\enclnameseparator}
\setkomafont{fromname}{\scshape}
\def\foldmarkson{\@ObsoleteCommand{\foldmarkson}{foldmarks=on}}
\def\foldmarksoff{\@ObsoleteCommand{\foldmarksoff}{foldmarks=off}}
\def\addrfieldon{\@ObsoleteCommand{\addrfieldon}{addrfield=on}}
\def\addrfieldoff{\@ObsoleteCommand{\addrfieldoff}{addrfield=off}}
\def\subjecton{\@ObsoleteCommand{\subjecton}{subject=titled}}
\def\subjectoff{\@ObsoleteCommand{\subjectoff}{subject=untitled}}
\def\subjectafteron{%
\@ObsoleteCommand{\subjectafteron}{subject=afteropening}}
\def\subjectafteroff{%
\@ObsoleteCommand{\subjectafteroff}{subject=beforeopening}}
%</KOMAold>
% \end{macrocode}
% \end{variable}
% \end{macro}
% \end{command}
%
%
% \begin{pseudolength}{specialmailheight}
% \begin{macro}{\@PapersizeWarning}
% For \file{DIN5008a.lco} and \file{DIN5008b.lco} we need additional settings:
% \changes{v3.30}{2020/02/25}{white spaces and end of warning removed}
% \begin{macrocode}
%</!5008>
%<*5008>
\newplength{specialmailheight}
\setplength{specialmailheight}{12.7mm}
\areaset[5mm]{165mm}{233mm}
\KOMAoptions{%
fromalign=locationleft,
addrfield=topaligned,
refline=narrow,
parskip=full
}
\l@addto@macro\@PapersizeWarning{%
\begingroup
\@tempswafalse
\ifdim\oddsidemargin<\dimexpr 25mm-1in-1pt\relax\@tempswatrue\else
\ifdim\oddsidemargin>\dimexpr 25mm-1in+1pt\relax\@tempswatrue\fi\fi
\ifdim\textwidth<\dimexpr \paperwidth-45mm-1pt\relax\@tempswatrue\else
\ifdim\textwidth>\dimexpr \paperwidth-45mm+1pt\relax\@tempswatrue\fi\fi
\if@tempswa
\LCOWarning{DIN5008%
%<A> A%
%<B> B%
}{%
DIN5008 orders exact margins and text\MessageBreak
width. Without following these values,\MessageBreak
your document does not conform DIN5008.\MessageBreak
You should use, e.g.,\MessageBreak
\space\string\areaset[5mm]{%
\the\dimexpr \paperwidth-45mm\relax}{%
\the\dimexpr 1.414\dimexpr \paperwidth-45mm\relax\relax}\MessageBreak
to follow the norm%
}%
\fi
\ifdim \dimexpr\parskip\relax=\dimexpr\baselineskip\relax\else
\LCOWarning{DIN5008%
%<A> A%
%<B> B%
}{%
DIN5008 orders paragraph separation by\MessageBreak
exactly one line. Without this, your\MessageBreak
document does not conform DIN5008.\MessageBreak
You shoud use, e.g.,\MessageBreak
\space\string\KOMAoption{parskip}{full}\MessageBreak
to follow the norm%
}%
\fi
\endgroup
}
% \end{macrocode}
% \end{macro}
% \end{pseudolength}
% \begin{macro}{\backaddr@format}
% \changes{v3.25}{2017/11/15}{using \cs{scr@endstrut} instead of
% \cs{unskip}\cs{strut}}
% Multi line back address without underline.
% \begin{macrocode}
\renewcommand{\backaddr@format}[1]{\hspace*{\useplength{toaddrindent}}%
\parbox[t][\useplength{backaddrheight}][t]%
{\dimexpr\useplength{toaddrwidth}-\useplength{toaddrindent}}%
{\strut\ignorespaces #1\ifhmode\scr@endstrut\fi}%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\specialmail@format}
% \changes{v3.25}{2017/11/15}{using \cs{scr@endstrut} instead of
% \cs{unskip}\cs{strut}}
% Multi line special sending.
% \begin{macrocode}
\renewcommand{\specialmail@format}[1]{%
\parbox[t][\useplength{specialmailheight}][t]%
{\dimexpr\useplength{toaddrwidth}
-\useplength{specialmailindent}
-\useplength{specialmailrightindent}}%
{\strut\ignorespaces #1\ifhmode\scr@endstrut\fi}%
}
% \end{macrocode}
% \end{macro}
% \begin{fontelement}{specialmail,backaddress,addressee,fromname,fromaddress,refvalue}
% Some font settings.
% \begin{macrocode}
\setkomafont{specialmail}{\sffamily\fontsize{10pt}{12pt}\selectfont}
\setkomafont{backaddress}{\sffamily\fontsize{8pt}{10pt}\selectfont}
\setkomafont{addressee}{\sffamily\fontsize{10pt}{12pt}\selectfont}
\setkomafont{fromname}{\sffamily\fontsize{10pt}{12pt}\selectfont}
\setkomafont{fromaddress}{\sffamily\fontsize{10pt}{12pt}\selectfont}
\setkomafont{refvalue}{\sffamily\fontsize{10pt}{12pt}\selectfont}
\let\raggedsignature\raggedright
%</5008>
%</body&!visualize>
% \end{macrocode}
% \end{fontelement}
%
%
% \subsection{Visualizing several fields of a letter}
%
% These macros are using be \file{visualize.lco} only.
%
% It needs \pkg{eso-pic}.
% \changes{v3.18}{2015/06/03}{loading \textsf{eso-pic} always}
% \begin{macrocode}
%<*visualize&body>
\RequirePackage{eso-pic}
% \end{macrocode}
%
% \begin{command}{\showfields}
% \changes{v3.26}{2018/08/29}{\cs{scr@trim@spaces} added}
% Command
% \begin{quote}
% \cs{showfields}\marg{field list}
% \end{quote}
% is used to visualize fields of the note paper. The \meta{field list} is a
% comma-separated list of field names. Unknown fields do not result in errors
% but warnings only. The visualization is done in the background using
% \pkg{eso-pic}. A visualized field cannot be un-visualized.
% \begin{macrocode}
\newcommand*{\showfields}[1]{%
\AtBeginLetter{%
\begingroup
\@for \@tempa:=#1\do{%
\scr@trim@spaces\@tempa
\ifx\@tempa\@empty\else
\@ifundefined{showfield@\@tempa}{%
\LCOWarning{visualize}{Unknown field `\@tempa' ignored}%
}{%