Debian Codegraph @

texmf-dist/source/latex/sblarticle/sblarticle.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (c) 2026 David Purton <[email protected]>
4 %
5 % This work may be distributed and/or modified under the conditions of
6 % the LaTeX Project Public License, either version 1.3c of this license
7 % or (at your option) any later version. The latest version of this
8 % license is in
9 % http://www.latex-project.org/lppl.txt
10 % and version 1.3c or later is part of all distributions of LaTeX
11 % version 2005/12/01 or later.
12 %
13 %<*driver>
14 \RequirePackage{pdfmanagement}
15 \documentclass[a4paper]{l3doc}
16 \usepackage[T1]{fontenc}
17 \usepackage{microtype}
18 \usepackage{mlmodern}
19 \usepackage[font=small, skip=6pt]{caption}
20 \usepackage{xcolor}
21 \usepackage{listings}
22
23 \AddToHook{env/macrocode/before}{%
24 \addvspace{\medskipamount}}
25
26 \AddToHook{env/macro/before}{%
27 \addvspace{\medskipamount}}
28
29 \begin{document}
30 \DocInput{\jobname.dtx}
31 \end{document}
32 %</driver>
33 % \fi
34 %
35 % \title{The \pkg{sblarticle} Class}
36 % \author{David Purton\thanks{Email: \url{[email protected]}}}
37 % \date{2026-04-04 v1.0}
38 %
39 % \maketitle
40 %
41 % \begin{abstract}
42 % \pkg{sblarticle} provides a LaTeX class for producing articles and papers
43 % conforming to the style required by the Society of Biblical Literature. It
44 % depends on \pkg{sblfonts} for language support and \pkg{biblatex-sbl} for
45 % referencing.
46 % \end{abstract}
47 %
48 % \tableofcontents
49 %
50 % \section{Introduction}
51 %
52 % The \pkg{sblarticle} class creates a term paper matching the style specified
53 % in the \emph{Student Supplement for \emph{The SBL Handbook of Style}, Second
54 % Edition}. See
55 % \url{https://www.sbl-site.org/wp-content/uploads/2025/04/SBLHSsupp2015-02.pdf}.
56 %
57 % The class works with both |pdflatex| and the Unicode engines, but in order
58 % to make use of the SBL fonts you need to install them and use a Unicode
59 % engine (|lualatex| is recommended, especially for Hebrew).
60 %
61 % This class is not intended to be a general flexible starting point for the
62 % requirements of all theological colleges and seminaries. In such cases you
63 % are better off beginning with the \pkg{article} class and loading
64 % \pkg{biblatex-sbl} and (possibly) \pkg{sblfonts} directly. You could use
65 % the code in this class as a guide.
66 %
67 % \subsection{Usage}
68 %
69 % Load the class using |\documentclass{sblarticle}|. See
70 % |sbltex-termpaper.pdf| in the documentation directory for an extended usage
71 % example.
72 %
73 % The following standard commands and environments have been customised for
74 % this class:
75 % \begin{itemize}
76 % \item |\author|, |\title|, |\maketitle|
77 % \item |\tableofcontents|, |\listoffigure|, |\listoftables|
78 % \item |\section|, |\subsection|, |\subsubsection|, |\paragraph|,
79 % |\subparagraph|
80 % \item |\appendix|
81 % \item |\footnote|
82 % \item |\caption|
83 % \item |\printbibliography|, |\printbiblist{abbreviations}|
84 % \item |abstract|, |quotation|, |quote|
85 % \end{itemize}
86 %
87 % American, Greek and Hebrew are set up using \pkg{sblfonts} (and
88 % \pkg{babel}). A different main language can be chosen by passing the
89 % \pkg{babel} language name to the class.
90 %
91 % \subsection{Acknowledgements}
92 %
93 % The \pkg{sblarticle} class depends on a number of other packages:
94 % \begin{itemize}
95 % \item \pkg{sblfonts} (with \pkg{fontspec}, \pkg{fontenc} and \pkg{babel}),
96 % \pkg{biblatex-sbl} (with \pkg{biblatex})
97 % \item \pkg{csquotes}, \pkg{geometry}, \pkg{setspace}, \pkg{ragged2e},
98 % \pkg{fancyhdr}
99 % \item When \cs{DocumentMetadata} is not in use: \pkg{caption},
100 % \pkg{footmisc}, \pkg{titlesec}, \pkg{titletoc}
101 % \end{itemize}
102 %
103 % \subsection{Bug Reports and Feature Requests}
104 %
105 % Bug reports and feature requests can be made at the \pkg{sbltex}
106 % GitHub repository. See \url{https://github.com/dcpurton/sbltex}.
107 %
108 % \begin{description}
109 % \item[Note:] This class is only partially compatible with the \LaTeX{}
110 % tagging project at this stage. As the tagging project stabilises and
111 % dependent packages are updated, compatibility will improve.
112 % \end{description}
113 %
114 % \section{Package Commands}
115 %
116 % \begin{function}{\course}
117 % \begin{syntax}
118 % |\course| \marg{Course name}
119 % \end{syntax}
120 % Set the name of the course the paper is for. This is included on the title
121 % page.
122 % \end{function}
123 %
124 % \begin{function}{\institution}
125 % \begin{syntax}
126 % |\institution| \marg{Institution name}
127 % \end{syntax}
128 % Set the name of the institution the paper will be submitted at. This is
129 % included on the title page.
130 % \end{function}
131 %
132 % \begin{function}{\professor}
133 % \begin{syntax}
134 % |\professor| \marg{Professor name}
135 % \end{syntax}
136 % Set the name of the professor the paper will be submitted to. This is
137 % included on the title page.
138 % \end{function}
139 %
140 % \section{Package Options}
141 %
142 % Items passed to the options below are \emph{appended} to the default options
143 % rather than replacing them.
144 %
145 % Any unrecognised options passed to the \pkg{sblarticle} class are passed
146 % through to the \pkg{article} class.
147 %
148 % \begin{function}{biblatex}
149 % \begin{syntax}
150 % biblatex = \marg{arguments}\hfill Default: \{style=sbl, language=auto, autolang=hyphen\}
151 % \end{syntax}
152 % These options are passed to the \pkg{biblatex} package.
153 % \end{function}
154 %
155 % See the \pkg{biblatex-sbl} package documentation for a full description of
156 % supported options and usage.
157 %
158 % \begin{function}{sblfonts}
159 % \begin{syntax}
160 % sblfonts = \marg{arguments}
161 % \end{syntax}
162 % Options to pass to the \pkg{sblfonts} package.
163 % \end{function}
164 %
165 % The defaults depend on whether the engine in use is 8bit or Unicode:
166 % \begin{description}
167 % \item[8bit defaults:] \mbox{}\\
168 % |{|\\
169 % \strut\quad |mainfont=tempora,|\\
170 % \strut\quad |grfont=Alegreya-LF,|\\
171 % \strut\quad |hefont=frank|\\
172 % |}|
173 % \item[Unicode defaults:] \mbox{}\\
174 % |{|\\
175 % \strut\quad |mainfont=TeXGyreTermesX,|\\
176 % \strut\quad |mainfontoptions={Extension=.otf, UprightFont=*-Regular,|\\
177 % \strut\qquad |ItalicFont=*-Italic, BoldFont=*-Bold,|\\
178 % \strut\qquad |BoldItalicFont=*-BoldItalic},|\\
179 % \strut\quad |sblfonts=true|\\
180 % |}|
181 % \end{description}
182 %
183 % Note that you will need to download and install the SBL fonts yourself from
184 % \url{https://www.sbl-site.org/resources/fonts/}.
185 %
186 % See the \pkg{sblfonts} package documentation for a full description of
187 % supported options and usage.
188 %
189 % \section{Implementation}
190 %
191 % \setlength{\parindent}{0em}
192 %
193 % \begin{macrocode}
194 %<*class>
195 %<@@=sblarticle>
196 % \end{macrocode}
197 %
198 % \begin{macrocode}
199 \NeedsTeXFormat{LaTeX2e}
200 \ProvidesExplClass{sblarticle}{2026-04-04}{1.0}
201 {Society of Biblical Literature Article Class (DCP)}
202 % \end{macrocode}
203 %
204 % \begin{macrocode}
205 \clist_new:N \l_@@_options_to_article_class_clist
206 % \end{macrocode}
207 %
208 % \begin{macrocode}
209 \keys_define:nn { sblarticle }
210 {
211 , biblatex .clist_set:N = \l_@@_options_to_biblatex_clist
212 , sblfonts .clist_set:N = \l_@@_options_to_sblfonts_clist
213 , unknown .code:n = {
214 \clist_put_right:No
215 \l_@@_options_to_article_class_clist
216 { \CurrentOption }
217 }
218 }
219 % \end{macrocode}
220 %
221 % \begin{macrocode}
222 \ProcessKeyOptions
223 % \end{macrocode}
224 %
225 % Set default options.
226 %
227 % \begin{macrocode}
228 \clist_put_left:Nn \l_@@_options_to_article_class_clist
229 {
230 , 12pt
231 , titlepage
232 }
233 % \end{macrocode}
234 %
235 % \begin{macrocode}
236 \clist_put_left:Nn \l_@@_options_to_biblatex_clist
237 {
238 , style = sbl
239 , language = auto
240 , autolang = hyphen
241 }
242 % \end{macrocode}
243 %
244 % \begin{macrocode}
245 \sys_if_engine_opentype:TF
246 {
247 \clist_put_left:Nn \l_@@_options_to_sblfonts_clist
248 {
249 , mainfont = TeXGyreTermesX
250 , mainfontoptions = {
251 , Extension = .otf
252 , UprightFont = *-Regular
253 , ItalicFont = *-Italic
254 , BoldFont = *-Bold
255 , BoldItalicFont = *-BoldItalic
256 }
257 , sblfonts = true
258 }
259 }
260 {
261 \clist_put_left:Nn \l_@@_options_to_sblfonts_clist
262 {
263 , mainfont = tempora
264 , grfont = Alegreya-LF
265 , hefont = frank
266 }
267 }
268 % \end{macrocode}
269 %
270 % Load article class.
271 %
272 % \begin{macrocode}
273 \exp_args:No \PassOptionsToClass
274 { \l_@@_options_to_article_class_clist }
275 { article }
276 \LoadClass { article }
277 % \end{macrocode}
278 %
279 % Font and language set up.
280 %
281 % \begin{macrocode}
282 \exp_args:No \PassOptionsToPackage
283 { \l_@@_options_to_sblfonts_clist }
284 { sblfonts }
285 \RequirePackage { sblfonts }
286 % \end{macrocode}
287 %
288 % \pkg{biblatex} set up.
289 %
290 % \begin{macrocode}
291 \exp_args:No \PassOptionsToPackage
292 { \l_@@_options_to_biblatex_clist }
293 { biblatex }
294 \RequirePackage { biblatex }
295 \RequirePackage { csquotes }
296 % \end{macrocode}
297 %
298 % \subsection{Margins}
299 %
300 % \begin{macrocode}
301 \RequirePackage [ margin = 1in, headheight = 14.5pt ] { geometry }
302 % \end{macrocode}
303 %
304 % \subsection{Text layout}
305 %
306 % \begin{macrocode}
307 \RequirePackage { setspace }
308 \RequirePackage { ragged2e }
309 \doublespacing
310 \frenchspacing
311 \dim_set:Nn \RaggedRightParindent { 0.5in }
312 \dim_set:Nn \RaggedLeftParindent { 0.5in }
313 \dim_set:Nn \JustifyingParindent { 0.5in }
314 \RaggedRight
315 \sloppy
316 \raggedbottom
317 \sys_if_engine_luatex:F
318 {
319 \AddBabelHook [ hebrew ] { sblarticle } { afterextras }
320 {
321 \raggedleft
322 \parindent 0.5in
323 }
324 \AddBabelHook { sblarticle } { afterextras } { \RaggedRight }
325 }
326 % \end{macrocode}
327 %
328 % \subsection{Headers and footers}
329 %
330 % \begin{macrocode}
331 \RequirePackage { fancyhdr }
332 \pagestyle { fancy }
333 \fancyhf { }
334 \fancyhead [ R ] { \thepage }
335 \cs_set_nopar:Npn \headrulewidth { 0pt }
336 \cs_set_nopar:Npn \sectionmark #1
337 {
338 \markboth
339 { \int_compare:nNnT
340 { \c@secnumdepth } > { \c_zero_int }
341 { \thesection \skip_horizontal:n { 1em } }
342 #1
343 }
344 { }
345 }
346 % \end{macrocode}
347 %
348 % \subsection{Footnotes}
349 %
350 % Different handling is required for footnotes when tagging code is loaded.
351 %
352 % \begin{macrocode}
353 \IfDocumentMetadataTF
354 {
355 \hook_gput_code:nnn { fntext / para } { sblarticle }
356 { \RaggedRight }
357 \socket_new_plug:nnn { fntext / mark } { sblarticle }
358 {
359 \skip_horizontal:N \footnotemargin
360 \@thefnmark . \enspace
361 }
362 \socket_assign_plug:nn { fntext / mark } { sblarticle }
363 \socket_assign_plug:nn
364 { build / column / outputbox }
365 { floats-space-footnotes }
366 }
367 {
368 \RequirePackage [ bottom, ragged ] { footmisc }
369 \cs_set:Npn \@makefntext #1
370 {
371 \dim_set_eq:NN \parindent \footnotemargin
372 \@thefnmark . \enspace
373 \footnotelayout #1
374 }
375 }
376 % \end{macrocode}
377 %
378 % \begin{macrocode}
379 \dim_set:Nn \footnotemargin { 0.5in }
380 \cs_set:Npn \footnoterule
381 {
382 \kern -3pt
383 \hrule width 2in
384 \kern 2.6pt
385 \vskip -8pt
386 }
387 \dim_set:Nn \footnotesep { 20pt }
388 % \end{macrocode}
389 %
390 % \subsection{Captions}
391 %
392 % \begin{macrocode}
393 \skip_set:Nn \abovecaptionskip { 6pt }
394 \skip_set:Nn \belowcaptionskip { 6pt }
395 \cs_set:Npn \thefigure
396 {
397 \arabic { figure }
398 }
399 \cs_set:Npn \thetable
400 {
401 \arabic { table }
402 }
403 \counterwithout { figure } { part }
404 \counterwithout { table } { part }
405 % \end{macrocode}
406 %
407 % \begin{macrocode}
408 \IfDocumentMetadataTF
409 {
410 \NewSocketPlug { caption / label } { sblarticle }
411 {
412 \small
413 #1:~
414 }
415 \AssignSocketPlug { caption / label } { sblarticle }
416 }
417 {
418 \RequirePackage [ font = small , skip = 6pt ] { caption }
419 }
420 % \end{macrocode}
421 %
422 % \subsection{Block quotes}
423 %
424 % \begin{macrocode}
425 \IfDocumentMetadataTF
426 {
427 \hook_gput_code:nnn { begindocument / before } { sblarticle }
428 {
429 \RenewDocumentEnvironment { quotation } { !O { } }
430 {
431 \UseInstance { blockenv } { quotation }
432 {
433 , begin-extra-vspace = 0pt
434 , begin-vspace = 0pt
435 , left-margin = 0.5in
436 , right-margin = 0pt
437 , para-indent = 0.5in
438 , para-vspace = 0pt
439 , final-code = \singlespacing
440 \vspace* { -5pt }
441 \ignorespaces
442 , #1
443 }
444 }
445 { \endblockenv }
446 \RenewDocumentEnvironment { quote } { !O { } }
447 {
448 \UseInstance { blockenv } { quote }
449 {
450 , begin-extra-vspace = 0pt
451 , begin-vspace = 0pt
452 , left-margin = 0.5in
453 , right-margin = 0pt
454 , para-indent = 0pt
455 , para-vspace = 7pt
456 , final-code = \singlespacing
457 \vspace* { -5pt }
458 \ignorespaces
459 , #1
460 }
461 }
462 { \endblockenv }
463 }
464 }
465 {
466 \renewenvironment { quotation }
467 {
468 \list { }
469 {
470 \dim_set:Nn \leftmargin { 0.5in }
471 \dim_zero:N \rightmargin
472 \dim_zero:N \topsep
473 \dim_zero:N \partopsep
474 \dim_zero:N \itemsep
475 \dim_zero:N \parsep
476 \dim_set:Nn \itemindent { 0.5in }
477 \dim_set:Nn \listparindent { 0.5in }
478 }
479 \item \relax
480 \singlespacing
481 \vspace* { -5pt }
482 }
483 {
484 \endlist
485 }
486 % \end{macrocode}
487 %
488 % \begin{macrocode}
489 \renewenvironment { quote }
490 {
491 \list { }
492 {
493 \dim_set:Nn \leftmargin { 0.5in }
494 \dim_zero:N \rightmargin
495 \dim_zero:N \topsep
496 \dim_zero:N \partopsep
497 \dim_zero:N \itemsep
498 \dim_set:Nn \parsep { 7pt }
499 \dim_zero:N \itemindent
500 \dim_zero:N \listparindent
501 }
502 \item \relax
503 \singlespacing
504 \vspace* { -5pt }
505 }
506 {
507 \endlist
508 }
509 }
510 % \end{macrocode}
511 %
512 % \subsection{Title page}
513 %
514 % \begin{macrocode}
515 \tl_new:N \g_@@_course_tl
516 \tl_new:N \g_@@_institution_tl
517 \tl_new:N \g_@@_professor_tl
518 % \end{macrocode}
519 %
520 % \begin{macrocode}
521 \cs_new_protected:Npn \course #1
522 {
523 \tl_gset:Nn \g_@@_course_tl { #1 }
524 }
525 % \end{macrocode}
526 %
527 % \begin{macrocode}
528 \cs_new_protected:Npn \institution #1
529 {
530 \tl_gset:Nn \g_@@_institution_tl { #1 }
531 }
532 % \end{macrocode}
533 %
534 % \begin{macrocode}
535 \cs_new_protected:Npn \professor #1
536 {
537 \tl_gset:Nn \g_@@_professor_tl { #1 }
538 }
539 % \end{macrocode}
540 %
541 % \begin{macrocode}
542 \author { [Your ~ Name] }
543 \title { Title ~ of ~ Paper }
544 \tl_gset:Nn \g_@@_course_tl { [Course ~ Number ~ and ~ Title] }
545 \tl_gset:Nn \g_@@_institution_tl { [Name ~ of ~ Institution] }
546 \tl_gset:Nn \g_@@_professor_tl { [Name ~ of ~ Professor] }
547 % \end{macrocode}
548 %
549 % \begin{macrocode}
550 \cs_set_protected:Npn \maketitle
551 {
552 \newgeometry { top=2in, bottom=2in }
553 \pagenumbering { roman }
554 \thispagestyle { empty }
555 \group_begin:
556 \singlespacing
557 \centering
558 \text_uppercase:n { \g_@@_institution_tl } \para_end:
559 \vfill
560 \doublespacing
561 \text_uppercase:n { \@title } \para_end:
562 \vfill
563 \singlespacing
564 \text_uppercase:n
565 { Submitted ~ to ~ \g_@@_professor_tl } \para_end:
566 \text_uppercase:n { in ~ Partial ~ Fulfilment ~ of } \para_end:
567 \text_uppercase:n { \g_@@_course_tl } \para_end:
568 \vfill
569 \text_uppercase:n { By } \para_end:
570 \text_uppercase:n { \@author } \para_end:
571 \text_uppercase:n { \@date } \para_end:
572 \group_end:
573 \restoregeometry
574 }
575 % \end{macrocode}
576 %
577 % \subsection{Abstract}
578 %
579 % \begin{macro}{\@@_abstract_protected_end:n} \marg{abstract}
580 %
581 % \medskip
582 %
583 % This function is used to inject |\__sblarticle_fontmatter_peek:|
584 %
585 % \begin{macrocode}
586 \cs_set_eq:Nc \@@_orig_protected_end:n { end~ }
587 % \end{macrocode}
588 %
589 % \begin{macrocode}
590 \cs_new_nopar:Nn \@@_abstract_protected_end:n
591 {
592 \@@_orig_protected_end:n { #1 }
593 \tl_if_eq:nnT { #1 } { abstract }
594 {
595 \cs_gset_eq:cN { end~ } \@@_orig_protected_end:n
596 \peek_remove_spaces:n
597 {
598 \peek_analysis_map_inline:n
599 {
600 \exp_args:No \token_if_eq_meaning:NNF { ##1 } \para_end:
601 {
602 \peek_analysis_map_break:n
603 {
604 \exp_after:wN
605 \@@_frontmatter_peek:
606 ##1
607 }
608 }
609 ##1
610 }
611 }
612 }
613 }
614 % \end{macrocode}
615 % \end{macro}
616 %
617 % \begin{macrocode}
618 \renewenvironment { abstract }
619 {
620 \part* { \abstractname }
621 \addcontentsline { toc } { part } { \abstractname }
622 \cs_gset_eq:cN { end~ } \@@_abstract_protected_end:n
623 }
624 {
625 \par
626 \clearpage
627 \pagestyle { fancy }
628 }
629 % \end{macrocode}
630 %
631 % \subsection{Section titles}
632 %
633 % \begin{macrocode}
634 \int_set:Nn \c@secnumdepth { -1 }
635 \cs_set_nopar:Npn \thepart
636 {
637 \@arabic \c@part
638 }
639 % \end{macrocode}
640 %
641 % These two functions ensure consistent spacing after section headings whether
642 % body paragraph text follows or another section heading follows.
643 %
644 % \begin{macrocode}
645 \cs_new_nopar:Nn \@@_before_head_correction:
646 {
647 \hook_gclear_next_code:n { para / before }
648 }
649 % \end{macrocode}
650 %
651 % \begin{macrocode}
652 \cs_new_nopar:Nn \@@_after_head_correction:
653 {
654 \vspace* { -5.5pt }
655 \hook_gput_next_code:nn { para / before } { \vspace* { 5.5pt } }
656 }
657 % \end{macrocode}
658 %
659 % For documents using \cs{DocumentMetadata} use standard kernel commands to
660 % redefine section headings, otherwise use the \pkg{titlesec} package.
661 %
662 % \begin{macrocode}
663 \IfDocumentMetadataTF
664 {
665 \cs_set:Npn \section
666 {
667 \hook_gput_next_code:nn { para / end }
668 { \dim_zero:N \hangindent }
669 \@@_before_head_correction:
670 \hook_gput_next_code:nn { para / after }
671 { \@@_after_head_correction: }
672 \@startsection { section } { 1 } { 0pt } { -37pt } { 1sp }
673 { \singlespacing \normalfont \normalsize \bfseries \centering }
674 }
675 \cs_set:Npn \subsection
676 {
677 \hook_gput_next_code:nn { para / end }
678 { \dim_zero:N \hangindent }
679 \@@_before_head_correction:
680 \hook_gput_next_code:nn { para / after }
681 { \@@_after_head_correction: }
682 \@startsection { subsection } { 2 } { 0pt } { -37pt } { 1sp }
683 { \singlespacing \normalfont \normalsize \centering }
684 }
685 \cs_set:Npn \subsubsection
686 {
687 \@@_before_head_correction:
688 \hook_gput_next_code:nn { para / after }
689 { \@@_after_head_correction: }
690 \@startsection { subsubsection } { 3 } { 0pt } { -37pt } { 1sp }
691 { \singlespacing \normalfont \normalsize \bfseries \itshape }
692 }
693 \cs_set:Npn \paragraph
694 {
695 \@@_before_head_correction:
696 \@startsection { paragraph } { 4 } { 0pt } { -37pt } { 1sp }
697 { \singlespacing \normalfont \normalsize }
698 }
699 \cs_set:Npn \subparagraph
700 {
701 \@startsection { subparagraph } { 5 } { 0pt } { -37pt } { -1em }
702 { \normalfont \normalsize \bfseries }
703 }
704 % \end{macrocode}
705 %
706 % Redefine \cs{@part} and \cs{@spart} to format major headings.
707 %
708 % \begin{macrocode}
709 \hook_gput_code:nnn { cmd / part / before } { sblarticle }
710 {
711 \clearpage
712 \mode_leave_vertical:
713 \par
714 \thispagestyle { plain }
715 }
716 % \end{macrocode}
717 %
718 % \begin{macrocode}
719 \cs_set_nopar:Npn \@part [#1]#2
720 {
721 \addvspace { 37pt }
722 \int_compare:nNnTF { \c@secnumdepth } > { -1 }
723 {
724 \refstepcounter { part }
725 \addcontentsline { toc } { part }
726 { \chaptername \space \thepart : \enspace #1 }
727 }
728 {
729 \addcontentsline { toc } { part } {#1}
730 }
731 \group_begin:
732 \dim_zero:N \parindent
733 \centering
734 \interlinepenalty 10000
735 \normalfont
736 \int_compare:nNnT { \c@secnumdepth } > { -1 }
737 {
738 \MakeUppercase { \chaptername } \nobreakspace \thepart
739 \par
740 \nobreak
741 }
742 \singlespacing
743 \MakeUppercase {#2}
744 \hook_gput_next_code:nn { para / after }
745 { \@@_after_head_correction: }
746 \markboth { } { }
747 \par
748 \group_end:
749 \nobreak
750 \skip_vertical:n { 39pt }
751 \@afterheading
752 }
753 % \end{macrocode}
754 %
755 % \begin{macrocode}
756 \cs_set_nopar:Npn \@spart #1
757 {
758 \addvspace { 37pt }
759 \group_begin:
760 \dim_zero:N \parindent
761 \centering
762 \interlinepenalty 10000
763 \normalfont
764 \singlespacing
765 \MakeUppercase {#1}
766 \hook_gput_next_code:nn { para / after }
767 { \@@_after_head_correction: }
768 \par
769 \group_end:
770 \nobreak
771 \skip_vertical:n { 39pt }
772 \@afterheading
773 }
774 }
775 {
776 \RequirePackage [ newparttoc ] { titlesec }
777 \providecommand \phantomsection { }
778 \titleclass { \part } [ 0 ] { top }
779 % \end{macrocode}
780 %
781 % \begin{macrocode}
782 \titlespacing* { \part } { 0pt } { 41pt } { 37pt }
783 \titlespacing* { \section } { 0pt } { 37pt } { 0pt }
784 \titlespacing* { \subsection } { 0pt } { 37pt } { 0pt }
785 \titlespacing* { \subsubsection } { 0pt } { 37pt } { 0pt }
786 \titlespacing* { \paragraph } { 0pt } { 37pt } { 0pt }
787 \titlespacing* { \subparagraph } { 0pt } { 37pt } { 1em }
788 % \end{macrocode}
789 %
790 % \begin{macrocode}
791 \titleformat
792 { \part }
793 [ display ]
794 { \normalfont \normalsize \singlespacing \filcenter }
795 {
796 \MakeUppercase { \chaptername } \space \thepart
797 }
798 { 12pt }
799 { \MakeUppercase }
800 [ \@@_after_head_correction: ]
801 \titleformat
802 { \section }
803 [ block ]
804 {
805 \@@_before_head_correction:
806 \normalfont \normalsize \singlespacing \bfseries \filcenter
807 }
808 { \thesection }
809 { 0.5em }
810 { }
811 [ \@@_after_head_correction: ]
812 \titleformat
813 { \subsection }
814 [ block ]
815 {
816 \@@_before_head_correction:
817 \normalfont \normalsize \singlespacing \filcenter
818 }
819 { \thesubsection }
820 { 0.5em }
821 { }
822 [ \@@_after_head_correction: ]
823 \titleformat
824 { \subsubsection }
825 [ block ]
826 {
827 \@@_before_head_correction:
828 \normalfont \normalsize \singlespacing \bfseries \itshape \filright
829 }
830 { \thesubsubsection }
831 { 0.5em }
832 { }
833 [ \@@_after_head_correction: ]
834 \titleformat
835 { \paragraph }
836 [ block ]
837 {
838 \@@_before_head_correction:
839 \normalfont \normalsize \singlespacing \filright
840 }
841 { \theparagraph }
842 { 0.5em }
843 { }
844 \titleformat
845 { \subparagraph }
846 [ runin ]
847 { \normalfont \normalsize \bfseries }
848 { \thesubparagraph }
849 { 1em }
850 { }
851 }
852 % \end{macrocode}
853 %
854 % \subsection{Table of contents and list of figures/tables}
855 %
856 % \begin{macrocode}
857 \int_set:Nn \c@tocdepth { 2 }
858 % \end{macrocode}
859 %
860 % \begin{macrocode}
861 \cs_set:Npn \tableofcontents
862 {
863 \part* { \contentsname }
864 \@mkboth
865 { \contentsname }
866 { \contentsname }
867 \@starttoc { toc }
868 \clearpage
869 \@@_frontmatter_peek:
870 }
871 % \end{macrocode}
872 %
873 % \begin{macrocode}
874 \cs_set:Npn \listoffigures
875 {
876 \part* { \listfigurename }
877 \addcontentsline { toc } { part } { \listfigurename }
878 \@mkboth
879 { \listfigurename }
880 { \listfigurename }
881 \@starttoc { lof }
882 \clearpage
883 \@@_frontmatter_peek:
884 }
885 % \end{macrocode}
886 %
887 % \begin{macrocode}
888 \cs_set:Npn \listoftables
889 {
890 \part* { \listtablename }
891 \addcontentsline { toc } { part } { \listtablename }
892 \@mkboth
893 { \listfigurename }
894 { \listfigurename }
895 \@starttoc { lot }
896 \clearpage
897 \@@_frontmatter_peek:
898 }
899 % \end{macrocode}
900 %
901 % For documents using \cs{DocumentMetadata} use standard kernel commands to
902 % redefine table of contents lines, otherwise use the \pkg{titletoc} package.
903 %
904 % \begin{macrocode}
905 \IfDocumentMetadataTF
906 {
907 \text_declare_expand_equivalent:Nn \numberline
908 {
909 \exp_not:n { \numberline }
910 }
911 \hook_gput_code:nnn { cmd / @dottedtocline / before }
912 { sblarticle }
913 {
914 \addvspace { \baselineskip }
915 }
916 \hook_gput_code_with_args:nnn { contentsline / text / after }
917 { sblarticle }
918 {
919 \int_compare:nNnT {#1} > { -1 }
920 {
921 \cs_set_nopar:Npn \leaders ##1 ##2 { }
922 \hook_gput_next_code:nn { cmd / SuspendTagging / after }
923 {
924 \cs_set_nopar:Npn \leaders ##1 ##2 { }
925 }
926 }
927 }
928 \cs_set_nopar:cpn { contentsline@text@-1@format }
929 { \MakeUppercase }
930 \cs_set_nopar:Npn \numberline #1
931 {
932 \hook_use:nnw { contentsline / number / before } { 1 } {#1}
933 #1 \enspace
934 \hook_use:nnw { contentsline / number / after } { 1 } {#1}
935 }
936 % \end{macrocode}
937 %
938 % \begin{macrocode}
939 \cs_set_nopar:Npn \l@part
940 {
941 \@dottedtocline { -1 } { 0em } { 0em }
942 }
943 \cs_set_nopar:Npn \l@section
944 {
945 \@dottedtocline { 1 } { 1em } { 0em }
946 }
947 \cs_set_nopar:Npn \l@subsection
948 {
949 \@dottedtocline { 2 } { 2em } { 0em }
950 }
951 \cs_set_nopar:Npn \l@subsubsection
952 {
953 \@dottedtocline { 3 } { 3em } { 0em }
954 }
955 \cs_set_nopar:Npn \l@paragraph
956 {
957 \@dottedtocline { 4 } { 4em } { 0em }
958 }
959 \cs_set_nopar:Npn \l@subparagraph
960 {
961 \@dottedtocline { 5 } { 5em } { 0em }
962 }
963 \cs_set_nopar:Npn \l@figure
964 {
965 \@dottedtocline { 1 } { 0em } { 0em }
966 }
967 \cs_set_eq:NN \l@table \@figure
968 }
969 {
970 \RequirePackage { titletoc }
971 % \end{macrocode}
972 %
973 % \begin{macro}{\@@_hyperlink:nn} \marg{link} \marg{text}
974 %
975 % \medskip
976 %
977 % A convenience version of |\hyperlink| that just uses \meta{text} if
978 % \pkg{hyperref} isn't loaded.
979 %
980 % \begin{macrocode}
981 \cs_new_protected:Nn \@@_hyperlink:nn
982 {
983 \cs_if_exist_use:NTF \hyperlink
984 { { #1 } { #2 } }
985 { #2 }
986 }
987 % \end{macrocode}
988 % \end{macro}
989 %
990 % \begin{macrocode}
991 \titlecontents { figure }
992 [ 2em ]
993 { \singlespacing \filright }
994 {
995 \@@_hyperlink:nn
996 { \Hy@tocdestname }
997 { \makebox [ 2em ] [ l ] { \thecontentslabel . \enspace } }
998 }
999 { }
1000 { \hspace { 0.5em } \titlerule* [ 0.5pc ] { . } \contentspage }
1001 \titlecontents { table }
1002 [ 2em ]
1003 { \singlespacing \filright }
1004 {
1005 \@@_hyperlink:nn
1006 { \Hy@tocdestname }
1007 { \makebox [ 2em ] [ l ] { \thecontentslabel . \enspace } }
1008 }
1009 { }
1010 { \hspace { 0.5em } \titlerule* [ 0.5pc ] { . } \contentspage }
1011 \titlecontents { part }
1012 [ 0pt ]
1013 { \singlespacing \filright }
1014 {
1015 \@@_hyperlink:nn
1016 { \Hy@tocdestname }
1017 {
1018 \MakeUppercase { \chaptername } \space
1019 \thecontentslabel : \enspace
1020 }
1021 \MakeUppercase
1022 }
1023 { \MakeUppercase }
1024 { \hspace { 0.5em } \titlerule* [ 0.5pc ] { . } \contentspage }
1025 \titlecontents { section }
1026 [ 1em ]
1027 { \singlespacing \filright }
1028 { }
1029 { }
1030 { \hfill \contentspage }
1031 \titlecontents { subsection }
1032 [ 2em ]
1033 { \singlespacing \filright }
1034 { }
1035 { }
1036 { \hfill \contentspage }
1037 \titlecontents { subsubsection }
1038 [ 3em ]
1039 { \singlespacing \filright }
1040 { }
1041 { }
1042 { \hfill \contentspage }
1043 \titlecontents { paragraph }
1044 [ 4em ]
1045 { \singlespacing \filright }
1046 { }
1047 { }
1048 { \hfill \contentspage }
1049 \titlecontents { subparagraph }
1050 [ 5em ]
1051 { \singlespacing \filright }
1052 { }
1053 { }
1054 { \hfill \contentspage }
1055 }
1056 % \end{macrocode}
1057 %
1058 % \subsection{Appendices}
1059 %
1060 % Set up appendix headings and table of contents.
1061 %
1062 % \begin{macrocode}
1063 \cs_set_eq:NN \sblarticle@hyperlink \@@_hyperlink:nn
1064 \newcounter { sblarticle@appendix@count }
1065 % \end{macrocode}
1066 %
1067 % \begin{macrocode}
1068 \cs_new_protected:Nn \@@_set_up_appendices:
1069 {
1070 \cs_set_eq:NN \section \part
1071 \int_set:Nn \c@secnumdepth { \c_one_int }
1072 \cs_set_nopar:Npn \chaptername { \appendixname }
1073 \addtocontents { toc } { \def \protect \chaptername { \appendixname } }
1074 \int_compare:nNnT { \c@sblarticle@appendix@count } = { \c_one_int }
1075 {
1076 \int_zero:N \c@sblarticle@appendix@count
1077 }
1078 \IfDocumentMetadataTF
1079 {
1080 \cs_set_nopar:Npn \@part [##1]##2
1081 {
1082 \addvspace { 37pt }
1083 \stepcounter { sblarticle@appendix@count }
1084 \int_compare:nNnTF { \c@secnumdepth } > { -1 }
1085 {
1086 \refstepcounter { part }
1087 \protected@write \@auxout
1088 { }
1089 {
1090 \string \setcounter
1091 { sblarticle@appendix@count } { \the \c@part }
1092 }
1093 \addcontentsline { toc } { part }
1094 {
1095 \chaptername
1096 \ifnum \c@sblarticle@appendix@count > 1
1097 \space \thechapter
1098 \fi
1099 : \enspace ##1
1100 }
1101 }
1102 {
1103 \addcontentsline { toc } { part } {##1}
1104 }
1105 \group_begin:
1106 \dim_zero:N \parindent
1107 \centering
1108 \interlinepenalty 10000
1109 \normalfont
1110 \int_compare:nNnT { \c@secnumdepth } > { -1 }
1111 {
1112 \MakeUppercase { \chaptername }
1113 \int_compare:nNnT
1114 { \c@sblarticle@appendix@count } > { \c_one_int }
1115 {
1116 \nobreakspace \thechapter
1117 }
1118 \par
1119 \nobreak
1120 }
1121 \singlespacing
1122 \MakeUppercase {##2}
1123 \hook_gput_next_code:nn { para / after }
1124 { \@@_after_head_correction: }
1125 \markboth { } { }
1126 \par
1127 \group_end:
1128 \nobreak
1129 \skip_vertical:n { 39pt }
1130 \@afterheading
1131 }
1132 }
1133 {
1134 \titleformat
1135 { \part }
1136 [ display ]
1137 {
1138 \stepcounter { sblarticle@appendix@count }
1139 \protected@write \@auxout
1140 { }
1141 {
1142 \string \setcounter
1143 { sblarticle@appendix@count } { \the \c@part }
1144 }
1145 \singlespacing \normalfont \normalsize \filcenter
1146 }
1147 {
1148 \MakeUppercase { \chaptername }
1149 \ifnum \c@sblarticle@appendix@count > 1
1150 \strut \space \thepart
1151 \fi
1152 }
1153 { 12pt }
1154 { \MakeUppercase }
1155 \titlecontents { part }
1156 [ 0pt ]
1157 { \singlespacing \filright }
1158 {
1159 \sblarticle@hyperlink
1160 { \Hy@tocdestname }
1161 {
1162 \MakeUppercase { \chaptername }
1163 \ifnum \c@sblarticle@appendix@count > 1
1164 \strut \space \thecontentslabel
1165 \fi
1166 : \enspace
1167 }
1168 \MakeUppercase
1169 }
1170 { \MakeUppercase }
1171 { \hspace { 0.5em } \titlerule* [ 0.5pc ] { . } \contentspage }
1172 }
1173 }
1174 % \end{macrocode}
1175 %
1176 % \begin{macrocode}
1177 \hook_gput_code:nnn
1178 { cmd / appendix / after }
1179 { sblarticle }
1180 { \@@_set_up_appendices: }
1181 % \end{macrocode}
1182 %
1183 % \subsection{Bibliography and list of abbreviations}
1184 %
1185 % \begin{macrocode}
1186 \DefineBibliographyStrings { english }
1187 {
1188 shorthands = { List~of~Abbreviations }
1189 }
1190 \cs_set_nopar:Npn \bibsetup { \singlespacing }
1191 \dim_set:Nn \bibhang { 0.5in }
1192 \dim_set:Nn \bibitemsep { 12pt }
1193 \dim_set:Nn \biblabelsep { 0.5in }
1194 \defbibheading { bibliography } [ \bibname ]
1195 {
1196 \part* {#1}
1197 }
1198 \defbibheading { bibintoc } [ \bibname ]
1199 {
1200 \part* {#1}
1201 \addcontentsline { toc } { part } {#1}
1202 }
1203 \defbibheading { biblist } [ \biblistname ]
1204 {
1205 \part* {#1}
1206 }
1207 \defbibheading { biblistintoc } [ \biblistname ]
1208 {
1209 \part* {#1}
1210 \addcontentsline { toc } { part } {#1}
1211 }
1212 % \end{macrocode}
1213 %
1214 % Peeking ahead from the end of |\printbiblist| is slightly more complicated
1215 % because we only want to do so when it's in the front matter and it's defined
1216 % with |\newrobuscmd*| with optional arguments.
1217 %
1218 % \begin{macrocode}
1219 \cs_new:Npn \sblarticle@printbiblist@frontmatter@peek
1220 {
1221 \@@_if_page_numbering:nT { roman }
1222 {
1223 \@@_frontmatter_peek:
1224 }
1225 }
1226 % \end{macrocode}
1227 %
1228 % \subsection{Helper functions}
1229 %
1230 % \begin{macrocode}
1231 \ExplSyntaxOff
1232 \expandafter\apptocmd\csname\string\printbiblist\endcsname
1233 {\sblarticle@printbiblist@frontmatter@peek}
1234 {}
1235 {}
1236 \ExplSyntaxOn
1237 % \end{macrocode}
1238 %
1239 % \begin{macro}{\@@_if_page_numbering:nT} \marg{numbering style}
1240 % \marg{code if true}
1241 %
1242 % \medskip
1243 %
1244 % Test if the current page numbering style matches a particular style.
1245 % (e.g., |arabic| or |roman|).
1246 %
1247 % \begin{macrocode}
1248 \prg_new_conditional:Npnn \@@_if_page_numbering:n #1 { T }
1249 {
1250 \cs_set_nopar:Nn \@@_thepage_test:
1251 { \csname @ #1 \endcsname \c@page }
1252 \if_meaning:w \thepage \@@_thepage_test:
1253 \prg_return_true:
1254 \else:
1255 \prg_return_false:
1256 \fi:
1257 }
1258 % \end{macrocode}
1259 % \end{macro}
1260 %
1261 % \begin{macro}{\@@_frontmatter_peek:}
1262 %
1263 % \medskip
1264 %
1265 % Peek ahead and insert the title of the paper at the start of the main
1266 % matter.
1267 %
1268 % \begin{macrocode}
1269 \cs_new_protected:Nn \@@_frontmatter_peek:
1270 {
1271 \peek_analysis_map_inline:n
1272 {
1273 % \end{macrocode}
1274 %
1275 % Test if the next token is a control sequence of not.
1276 %
1277 % \begin{macrocode}
1278 \int_compare:nNnTF {##2} = { -1 }
1279 {
1280 \exp_args:No \token_if_eq_meaning:NNF {##1} \par
1281 {
1282 \bool_case:nTF
1283 {
1284 {
1285 \exp_args:No \token_if_eq_meaning_p:NN
1286 {##1} \begin
1287 }
1288 { }
1289 {
1290 \exp_args:No \token_if_eq_meaning_p:NN
1291 {##1} \tableofcontents
1292 }
1293 { }
1294 {
1295 \exp_args:No \token_if_eq_meaning_p:NN
1296 {##1} \listoffigures
1297 }
1298 { }
1299 {
1300 \exp_args:No \token_if_eq_meaning_p:NN
1301 {##1} \listoftables
1302 }
1303 { }
1304 {
1305 \exp_args:No \token_if_eq_meaning_p:NN
1306 {##1} \printbiblist
1307 }
1308 { }
1309 }
1310 { \peek_analysis_map_break:n {##1} }
1311 {
1312 % \end{macrocode}
1313 %
1314 % Insert the paper title if some control sequence other than the above is
1315 % found.
1316 %
1317 % \begin{macrocode}
1318 \peek_analysis_map_break:n
1319 {
1320 \part { \@title }
1321 \pagenumbering { arabic }
1322 ##1
1323 }
1324 }
1325 }
1326 }
1327 {
1328 % \end{macrocode}
1329 %
1330 % Ignore spaces and insert the paper title if a token other than a control
1331 % sequence is found.
1332 %
1333 % \begin{macrocode}
1334 \exp_args:No \token_if_space:NF {##1}
1335 {
1336 \peek_analysis_map_break:n
1337 {
1338 \part { \@title }
1339 \pagenumbering { arabic }
1340 ##1
1341 }
1342 }
1343 }
1344 }
1345 }
1346 % \end{macrocode}
1347 % \end{macro}
1348 %
1349 % \medskip
1350 %
1351 % Add the code to peek ahead after |maketitle| at the end of preamble because
1352 % \pkg{hyperref} (if loaded) takes over things.
1353 %
1354 % \begin{macrocode}
1355 \hook_gput_code:nnn
1356 { begindocument / before }
1357 { sblarticle }
1358 {
1359 \g@addto@macro \maketitle { \@@_frontmatter_peek: }
1360 }
1361 % \end{macrocode}
1362 %
1363 % \begin{macrocode}
1364 \endinput
1365 % \end{macrocode}
1366 %
1367 % \begin{macrocode}
1368 %</class>
1369 % \end{macrocode}