Debian Codegraph @

texmf-dist/source/latex/rwth-ci/rwth-letter.dtx

raw
1 % \iffalse meta-comment
2 %
3 % RWTH-CI -- Corporate Design for RWTH Aachen University
4 % ----------------------------------------------------------------------------
5 %
6 % Copyright (C) 2025–2026 by Marei Peischl <[email protected]> and Lukas C. Bossert
7 %
8 % ============================================================================
9 % This work may be distributed and/or modified under the
10 % conditions of the LaTeX Project Public License, either version 1.3c
11 % of this license or (at your option) any later version.
12 % The latest version of this license is in
13 % http://www.latex-project.org/lppl.txt
14 % and version 1.3c or later is part of all distributions of LaTeX
15 % version 2008/05/04 or later.
16 %
17 % This work has the LPPL maintenance status `maintained'.
18 %
19 % The Current Maintainer of this work is
20 % Marei Peischl [email protected]
21 %
22 % The development repository can be found at
23 % https://gitlab.git.nrw/rwth-it-center/rwth-latex-templates/rwth-ci
24 % Please use the issue tracker for feedback!
25 %
26 % ============================================================================
27 %
28 % \fi
29 % \iffalse
30 %<*driver>
31 \ProvidesFile{rwth-letter.dtx}
32 [2026-04-03 v1.2 Letters for RWTH-CI, Corporate Design of RWTH Aachen University]
33 %</driver>
34 %<@@=ptxcd>
35 %<*identification>
36 %<*package>
37 \NeedsTeXFormat{LaTeX2e}[2022-10-01]
38 \ProvidesExplPackage{rwth-letter}{2026-04-03}{1.2}{Letters for RWTH-CI, Corporate Design of RWTH Aachen University}
39 %</package>
40 %</identification>
41 %<*driver>
42 \providecommand*{\PtxcdDocDTXfiles}{rwth-letter.dtx}
43 \providecommand*{\PtxcdDocTitle}{\pkg{rwth-letter}~--~\LaTeX{}~Letter~setup~for~RWTH-CI}
44 \input{rwth-ci.dtx}
45 %</driver>
46 %<*initialization>
47 % \fi
48 % \begin{documentation}
49 % \section{Letters – \pkg{rwth-letter.sty}}
50 % The letter package is based on \pkg{scrletter} and supports all elements described in the KOMA-Script documentation.
51 % The corresponding demo file is called \file{DEMO-RWTHLetter.tex} and there also is a lco file to show a global configuration for address data.
52 %
53 % \subsection{Package specific options}
54 % \end{documentation}
55 % \begin{implementation}
56 % \begin{variable}{\g_@@_wide_letter_bool}
57 % \begin{macrocode}
58 \bool_new:N \g_@@_wide_letter_bool
59 % \end{macrocode}
60 % \end{variable}
61 % \begin{macrocode}
62 \keys_define:nn {ptxcd/letter} {
63 % \end{macrocode}
64 % \end{implementation}
65 % \begin{documentation}
66 % \DescribeKeyOption*{letterheadfile=\meta{file name/path}}{}
67 % There are logo files including the blue separation line for letters.
68 % These have to be scaled differently.
69 % This option allows to select those by passing it to the global \option{logofile} option and will adjust the scaling accordingly.
70 % The demo logo repository provides the file \file{rwth_briefkopf_cmyk.pdf} which could be enabled using the following setting:
71 % \begin{examplecode}
72 % \usepackage[
73 % letterheadfile=rwth_briefkopf
74 % ]{rwth-letter}
75 % \end{examplecode}
76 % \end{documentation}
77 % \begin{implementation}
78 % \changes{v1.0}{2025-12-18}{Add support for letterheadfile}
79 % \begin{optionenv}{logo-is-letterhead,letterheadfile}
80 % \begin{macrocode}
81 logo-is-letterhead .bool_gset:N = \g_@@_logo_is_letterhead_bool,
82 letterheadfile .code:n = \keys_set:nn {ptxcd/letter} {logofile=#1,logo-is-letterhead=true},
83 % \end{macrocode}
84 % \end{optionenv}
85 % \end{implementation}
86 % \begin{documentation}
87 % \DescribeKeyOption{letterhooks=\meta{boolean}}{false}
88 % Add support for different document configuration which does not match the RWTH-CI settings outside of letters.
89 % \end{documentation}
90 % \begin{implementation}
91 % \begin{optionenv}{letterhooks}
92 % \begin{macrocode}
93 letterhooks .bool_gset:N = \g_@@_letterhooks_bool,
94 letterhooks .initial:n = false,
95 letterhooks .default:n = true,
96 letterhooks .usage:n = load,
97 % \end{macrocode}
98 % \end{optionenv}
99 % \end{implementation}
100 % \begin{documentation}
101 % \DescribeKeyOption{grayscale=\meta{boolean}}{false}
102 % Can be used to create the non-colored letter layout.
103 % This will use \pkg{xcolor}'s gray color model and convert all colores within the letter.
104 % If \option{letterhooks} is not enabled this would affect the whole document.
105 % \end{documentation}
106 % \begin{implementation}
107 % \begin{optionenv}{grayscale}
108 % \begin{macrocode}
109 grayscale .bool_gset:N = \g_@@_grayscale_bool,
110 grayscale .initial:n = false,
111 grayscale .default:n = true,
112 grayscale .usage:n = load,
113 % \end{macrocode}
114 % \end{optionenv}
115 % \end{implementation}
116 % \begin{documentation}
117 % \DescribeKeyOption{payment-data=\meta{boolean}}{false}
118 % \end{documentation}
119 % \begin{implementation}
120 % \begin{optionenv}{payment-data}
121 % \begin{macrocode}
122 payment-data .bool_gset:N = \g_@@_payment_data_bool,
123 payment-data .initial:n = false,
124 payment-data .default:n = true,
125 payment-data .usage:n = load,
126 % \end{macrocode}
127 % \end{optionenv}
128 % \end{implementation}
129 % \begin{documentation}
130 % \DescribeKeyOption{textwidth=narrow/wide}{narrow}
131 % Switch between the two available letter layouts.
132 %
133 % \end{documentation}
134 % \begin{implementation}
135 % \begin{optionenv}{textwidth}
136 % \begin{macrocode}
137 textwidth .choice:,
138 textwidth / narrow .code:n = \bool_gset_false:N \g_@@_wide_letter_bool,
139 textwidth / wide .code:n = \bool_gset_true:N \g_@@_wide_letter_bool,
140 textwidth .initial:n = narrow,
141 textwidth .usage:n = load,
142 % \end{macrocode}
143 % \end{optionenv}
144 % \iffalse
145 %</initialization>
146 %<*processoptions>
147 % \fi
148 % \begin{macrocode}
149 %<gobble>}
150 \ProcessKeyOptions[ptxcd/letter]
151 % \end{macrocode}
152 % \iffalse
153 %</processoptions>
154 %<*body>
155 % \fi
156 % \begin{macrocode}
157 \bool_if:NF \g_@@_wide_letter_bool {\PassOptionsToPackage{firstfoot=false}{scrletter}}
158 \PassOptionsToPackage{addrfield=topaligned,pagenumber=botright,refline=nodate,numericaldate=true}{scrletter}
159 \RequirePackage{scrletter}
160 % \end{macrocode}
161 % Load the RWTH-colorscheme
162 % \begin{macrocode}
163 \PassOptionsToPackage{cmyk}{rwth-colors}
164 \RequirePackage{rwth-colors}
165 % \end{macrocode}
166 % Load the RWTH font configuration.
167 % This is not changing the documents main font, as this is not document class.
168 % \begin{macrocode}
169 \PassOptionsToPackage{fontdefaults=false}{rwth-fonts}
170 \RequirePackage{rwth-fonts}
171 \bool_if:NTF \g_@@_letterhooks_bool {
172 \AtBeginLetter
173 }{
174 \AtBeginDocument
175 }{%
176 \let\sfdefault\rwth@sffamily
177 \renewcommand*{\familydefault}{\sfdefault}%
178 \normalfont
179 \makeatletter
180 \input{rwth-lettersize11bp.clo}%
181 \makeatother
182 \bool_if:NT \g_@@_grayscale_bool {\selectcolormodel{gray}}
183 \bool_if:NT \g_@@_raggedright_bool {\raggedright}
184 }
185 % \end{macrocode}
186 % \end{implementation}
187 % \begin{documentation}
188 %
189 % \subsection{Additional KOMA variables defined for RWTH-CI}
190 % The letter template requires some additional variables:
191 % \begin{description}
192 % \item[frominstitution] institute/department/group
193 % \item[frominstitution-short] Abbreviated version of frominstitution to be used in the backaddress
194 % \item[frominstitution-id] identifier to be placed right of the backaddress
195 % \item[fromfunction] position or job title of the sender
196 % \item[fromoffice] building and room number
197 % \item[fromvat] VAT ID
198 % \item[fromtax] Tax ID
199 % \end{description}
200 % The RWTH Letter layout also allows to add a second sender.
201 % Therefore this bundle provides also the KOMA variables |fromname2| and |fromfunction2|.
202 % Using more than 2 persons is not allowed.
203 %
204 % The same applies for |frombank| here |frombank2| and |frombank3| have been added.
205 % \end{documentation}
206 % \begin{implementation}
207 % \begin{macrocode}
208 \newkomavar{frominstitution}
209 \newkomavar{frominstitution-short}
210 \newkomavar{frominstitution-id}
211 \newkomavar{fromfunction}
212 \newkomavar{fromname2}
213 \newkomavar{fromfunction2}
214 \newkomavar{fromoffice}
215 \newkomavar[\VatIdName]{fromvat}
216 \newkomavar[\TaxIdName]{fromtax}
217 \newkomavar{frombank2}
218 \newkomavar{frombank3}
219 % \end{macrocode}
220 % \changes{1.1-dev}{2026-02-12}{Add captions for VAT and TAX IDs}
221 % \begin{macrocode}
222 \providecaptionname{american,australian,british,canadian,english,newzealand,UKenglish,ukenglish,USenglish,usenglish}\VatIdName{VAT ID}
223 \providecaptionname{american,australian,british,canadian,english,newzealand,UKenglish,ukenglish,USenglish,usenglish}\TaxIdName{Tax ID}
224 \providecaptionname{german,ngerman,austrian,naustrian,swissgerman,nswissgerman}\VatIdName{USt-Identifikationsnummer}
225 \providecaptionname{german,ngerman,austrian,naustrian,swissgerman,nswissgerman}\TaxIdName{Steuernummer}
226 % \end{macrocode}
227 % Letter Layout definitions:
228 % \begin{macrocode}
229 \RequirePackage{geometry}
230 \geometry{left=2cm,top=3.6cm,bottom=1.3cm}
231
232 \bool_if:NTF \g_@@_wide_letter_bool {
233 \geometry{right=7.5mm}
234 }{
235 \geometry{right=6cm}
236 }
237 % \end{macrocode}
238 % TODO: ensure all logo files have the same dimensions.
239 % The 4mm offset is the 8mm offset mentioned in the guideline - the overlab of the secondary logo file.
240 % \begin{macrocode}
241 \setplength{firstheadvpos}{4mm}% 8m zum RWTH logo
242 \setplength{firstheadhpos}{20mm}
243 \setplength{firstheadwidth}{187.5mm}% inkl 5mm logo offset
244
245 \bool_if:NTF \g_@@_wide_letter_bool {
246 \setplength{locwidth}{60mm}
247 } {
248 \setplength{locwidth}{44mm}
249 }
250
251 \setplength{lochpos}{7.5mm}
252 \setplength{locvpos}{36mm}
253 \setplength{locheight}{248mm}
254
255 \setplength{toaddrindent}{0pt}
256 \setplength{toaddrhpos}{2cm}
257 \setplength{toaddrwidth}{85mm}
258 \setplength{toaddrheight}{45mm}
259
260 \setplength{refvpos}{96mm}
261
262 \setplength{toaddrhpos}{20mm}
263 \setplength{tfoldmarkvpos}{105mm}
264 \setplength{bfoldmarkvpos}{210mm}
265
266 \bool_if:NT \g_@@_wide_letter_bool {
267 \setplength{firstfootvpos}{262mm}
268 \setplength{firstfoothpos}{20mm}
269 \setplength{firstfootwidth}{\textwidth}
270 \setkomavar{firstfoot}{
271 \bool_if:NT \g_@@_payment_data_bool {
272 \parbox[t][22mm]{\useplength{firstfootwidth}}{
273 \usekomafont{paymentdata}
274 \parbox{45mm}{
275 \setlength{\parskip}{\z@}
276 \raggedright
277 \clist_map_inline:nn {fromvat,fromtax} {
278 \Ifkomavarempty{##1}{}{%
279 \Ifkomavarempty*{##1}{}{\usekomavar*{##1}\par}
280 \ignorespaces\usekomavar{##1}
281 \par\addvspace{\baselineskip}
282 }
283 }
284 }
285 \clist_map_inline:nn {frombank,frombank2,frombank3} {
286 \hskip1mm
287 \parbox{44mm}{
288 \setlength{\parskip}{\z@}
289 \raggedright
290 \Ifkomavarempty{##1}{}{%
291 \Ifkomavarempty*{##1}{}{\usekomavar*{##1}:\space}
292 \ignorespaces\usekomavar{##1}
293 \par
294 }
295 }
296 }
297 \hfill
298 }
299 }
300 }
301 }
302
303 \RequirePackage{graphicx}
304
305 %^^A Logo-Datei hat 5mm hmargin und 4mm mm vmargin
306 \setkomavar{firsthead}{\hskip 0pt plus 1 fill
307 \_@@_insert_logo:n {
308 \bool_if:NTF \g_@@_logo_is_letterhead_bool {80mm} {32mm}
309 }
310 }
311
312 \newcommand{\ptxcd@location}{
313 % \end{macrocode}
314 % If the payment_data is not displayed, the location field does not need a fixed height.
315 % \begin{macrocode}
316 \bool_if:NTF \g_@@_payment_data_bool
317 {\use:nn} {\use_i:nn}
318 {\parbox}{[t][\useplength{locheight}]}
319 {\useplength{locwidth}}{
320 \usekomafont{fromaddress}
321 \raggedright
322 \setlength{\parskip}{\z@}
323 \setlength{\parindent}{\z@}
324 \Ifkomavarempty{fromname}{}{
325 {\usekomafont{fromname}%
326 \ignorespaces\usekomavar{fromname}\par
327 }
328 \bool_if:NF \g_@@_wide_letter_bool {
329 \Ifkomavarempty{fromfunction}{}{\ignorespaces\usekomavar{fromfunction}}
330 }
331 \par\addvspace{\baselineskip}
332 }
333 \Ifkomavarempty{fromname2}{}{
334 {\usekomafont{fromname}%
335 \ignorespaces\usekomavar{fromname2}\par
336 }
337 \bool_if:NF \g_@@_wide_letter_bool{
338 \Ifkomavarempty{fromfunction2}{}{\ignorespaces\usekomavar{fromfunction2}}
339 }
340 \par\addvspace{\baselineskip}
341 }
342 \bool_if:NTF \g_@@_wide_letter_bool {
343 \clist_set:Nn \l_tmpa_clist {fromaddress}
344 } {
345 \clist_set:Nn \l_tmpa_clist {fromaddress,fromoffice}
346 }
347 \clist_map_inline:Nn \l_tmpa_clist {
348 \Ifkomavarempty{##1}{}{
349 \ignorespaces\usekomavar{##1}
350 \par\addvspace{\baselineskip}
351 }
352 }
353 \clist_map_inline:nn {fromphone,fromfax,frommobilephone} {
354 \Ifkomavarempty{##1}{}{
355 \leavevmode
356 \makebox[.22\linewidth][l]{\usekomavar*{##1}}\hspace{1em}
357 \parbox[t]{\dimexpr.78\linewidth-1em}{
358 \raggedright
359 \strut\ignorespaces\usekomavar{##1}\strut\par
360 }
361 \par
362 }
363 }
364 \par\addvspace{\baselineskip}
365
366 \Ifkomavarempty{fromemail}{}{
367 \ignorespaces\usekomavar{fromemail}
368 \par\addvspace{\baselineskip}
369 }
370 \bool_if:NF \g_@@_wide_letter_bool {
371 \Ifkomavarempty{fromurl}{}{
372 \ignorespaces\usekomavar{fromurl}
373 \par\addvspace{\baselineskip}
374 }
375 }
376 \let\do@set@reffield\ptxcd@set@reffield
377 \@set@reffields%
378 \par
379 \Ifkomavarempty{date}{}{%
380 \begingroup
381 \Ifkomavarempty*{date}{}{\usekomavar*{date}:\space}
382 \usekomafont{letterdate}\ignorespaces\usekomavar{date}
383 \endgroup
384 }
385 \par
386 \bool_if:NF \g_@@_wide_letter_bool {
387 \bool_if:NT \g_@@_payment_data_bool {
388 \vfill
389 \usekomafont{paymentdata}
390 \clist_map_inline:nn {fromvat,fromtax,frombank,frombank2,frombank3} {
391 \Ifkomavarempty{##1}{}{%
392 \Ifkomavarempty*{##1}{}{\usekomavar*{##1}:\space}
393 \ignorespaces\usekomavar{##1}
394 \par\addvspace{\baselineskip}
395 }
396 }
397 }
398 }
399 }
400 }
401
402 \newcommand*{\ptxcd@set@reffield}[1]{%
403 \Ifkomavarempty{#1}{}{%
404 \bool_if:NT \g_@@_wide_letter_bool {\par\addvspace{\baselineskip}}
405 \Ifkomavarempty*{#1}{}{{\usekomafont{refname}\usekomavar*{#1}:\space}}
406 {\usekomafont{refvalue}\strut\usekomavar{#1}}
407 \par
408 }
409 }%
410
411 \setkomavar{location}{
412 \ptxcd@location
413 }
414
415 \setkomafont{backaddress}{\color{rwth-blue-100}\scriptsize}
416 \setkomafont{addressee}{}% normalsize?
417 \setkomafont{fromname}{\usekomafont{fromaddress}\bfseries}
418 \setkomafont{fromaddress}{\small}
419 \setkomafont{refname}{\small}
420 \setkomafont{pagenumber}{\small}
421 \setkomafont{refvalue}{\usekomafont{refname}}
422 \newkomafont{paymentdata}{\footnotesize}
423 \newkomafont{letterdate}{\bfseries}
424
425 % \end{macrocode}
426 % pagestyle configuration
427 % \begin{macrocode}
428
429 \DeclareNewLayer[
430 background,
431 % remove rule if \g_@@_logo_is_letterhead_bool?
432 contents={\color{rwth-blue-25}\rule{\layerwidth}{\layerheight}},
433 hoffset=\dimexpr137.5mm+ 0.47952bp,% 21 cm - 6cm - 0.75cm - .5cm
434 voffset=44mm,
435 width=1bp,
436 height=8cm,
437 align=c,
438 ]{letter.first.rule}
439
440 % \end{macrocode}
441 % \changes{v1.0}{2025-12-18}{Configure letterpagemark}
442 % \begin{macrocode}
443 \renewcommand*{\letterpagemark}{%
444 % get lastpage for this letter if not already done
445 \int_if_exist:cF {c_@@_letter\thisletter _lastpage_int} {
446 \cs_if_exist:cTF {r@\thisletter.lastpage} {
447 \int_const:cn {c_@@_letter\thisletter _lastpage_int} {
448 \exp_args:NNc \expandafter \@secondoffive { r@\thisletter.lastpage}
449 }
450 } {
451 % warning -> rerun latex
452 \int_const:cn {c_@@_letter\thisletter _lastpage_int} {0}
453 }
454 }
455 \int_compare:nT {
456 \int_use:c {c_@@_letter\thisletter _lastpage_int}
457 > 1
458 } {
459 \bool_if:NTF \g_@@_wide_letter_bool {
460 % \setplength{locwidth}{60mm}
461 } {
462 \makebox[\useplength{locwidth}][l]
463 }
464 {\usekomafont{pagenumber}\thepage/\int_to_arabic:n{\int_use:c {c_@@_letter\thisletter _lastpage_int}}}
465 }
466 }
467
468 \renewpairofpagestyles{letter}{%
469 \bool_if:NF \g_@@_wide_letter_bool {\KOMAoptions{footwidth=18.25cm}}
470 \clearpairofpagestyles
471 \lehead{\usekomavar{nexthead}}
472 \lohead{\usekomavar{nexthead}}
473 \lefoot{\usekomavar{nextfoot}}
474 \lofoot{\usekomavar{nextfoot}}
475 \refoot[\pagemark]{}
476 \rofoot[\pagemark]{}
477 }
478
479 \ModifyLayer[
480 voffset=\dimexpr\paperheight-.8cm\relax,
481 hoffset=2cm,
482 width=18.25cm,
483 ]{plain.letter.foot.oneside}
484
485 \ModifyLayer[
486 voffset=\dimexpr\paperheight-.8cm\relax,
487 hoffset=2cm,
488 width=18.25cm,
489 ]{letter.foot.oneside}
490
491 \DeclareNewPageStyleByLayers{letter.first}{plain.letter.foot.oneside,letter.first.rule}
492
493 \AddToHook{cmd/@datefield/before}{
494 \removereffields
495 }
496
497 \AddToHook{cmd/@makelettertitle/after}{
498 \thispagestyle{letter.first}
499 }
500
501 \renewcommand{\backaddr@format}[1]{
502 \makebox[\useplength{toaddrwidth}]{
503 #1
504 \hfill\Ifkomavarempty{frominstitution-id}{}{\textcolor{black}{\usekomavar{frominstitution-id}}}
505 }
506 }
507 \setkomavar{specialmail}{\null}
508 \setkomavar{backaddress}{%
509 \Ifkomavarempty{frominstitution-short}{%
510 \Ifkomavarempty{frominstitution}{}{\textbf{\usekomavar{frominstitution}}\\}%
511 }{\textbf{\usekomavar{frominstitution-short}}\\}%
512 \usekomavar{fromaddress}%
513 }
514 \setkomavar{backaddressseparator}{\space|\space}
515
516 \setkomavar*{date}{}
517
518 % \end{macrocode}
519 % \iffalse
520 %</body>
521 % \fi
522 % \end{implementation}
523 % \Finale
524 \endinput