Debian Codegraph @

texmf-dist/doc/latex/keytheorems/keytheorems-doc.tex

raw
1 % !TeX TXS-program:compile = txs:///arara/[-v]
2 % arara: lualatex: { synctex:yes, interaction:nonstopmode }
3 % arara: makeindex
4 % arara: lualatex: { synctex:yes, interaction:nonstopmode } if found('log', 'Rerun to get')
5 \RequirePackage{pdfmanagement}
6 \SetKeys[document/metadata]{lang=en-US}
7 \PassOptionsToPackage{hyperindex}{hyperref}
8 \PassOptionsToPackage{dvipsnames}{xcolor}
9 \documentclass{ltxdoc}
10 \usepackage{geometry}
11 \geometry{margin=1.5in}
12 \usepackage{tcolorbox}
13 \PassOptionsToPackage{cachedir=keythms-doc-minted}{minted}
14 \tcbuselibrary{documentation,minted,breakable,hooks}
15
16 \usepackage{fontspec}
17 \setmainfont{NewCM10-Book.otf}[
18 IgnoreFontspecFile,
19 % Copied from NewCM-Book.fontspec
20 % Needed to change BoldFont to LM demibold
21 UprightFont={NewCM10-Book.otf},%
22 UprightFeatures={%
23 SizeFeatures={%
24 {%
25 Size={-8},%
26 Font={NewCM08-Book.otf}%
27 },%
28 {%
29 Size={8-},%
30 Font={NewCM10-Book.otf}%
31 }%
32 }%
33 },%
34 ItalicFont={NewCM10-BookItalic.otf},%
35 ItalicFeatures={%
36 SizeFeatures={%
37 {%
38 Size={-8},%
39 Font={NewCM08-BookItalic.otf}%
40 },%
41 {%
42 Size={8-},%
43 Font={NewCM10-BookItalic.otf}%
44 }%
45 }%
46 },%
47 BoldFont={lmromandemi10-regular.otf},%
48 BoldFeatures={%
49 SizeFeatures={%
50 {%
51 Size={0-},%
52 Font={lmromandemi10-regular.otf}%
53 }%
54 }%
55 },%
56 BoldItalicFont={NewCM10-BoldItalic.otf},%
57 BoldItalicFeatures={%
58 SizeFeatures={%
59 {%
60 Size={0-},%
61 Font={NewCM10-BoldItalic.otf}%
62 }%
63 }%
64 },%
65 SlantedFont={NewCM10-Book.otf},%
66 SlantedFeatures={%
67 SizeFeatures={%
68 {%
69 Size={-8},%
70 Font={NewCM08-Book.otf}%
71 },%
72 {%
73 Size={8-},%
74 Font={NewCM10-Book.otf}%
75 }%
76 }%
77 },%
78 BoldSlantedFont={lmromandemi10-oblique.otf},%
79 BoldSlantedFeatures={%
80 SizeFeatures={%
81 {%
82 Size={0-},%
83 Font={lmromandemi10-oblique.otf}%
84 }%
85 }%
86 },%
87 SwashFont={NewCM10-Book.otf},%
88 SwashFeatures={%
89 SizeFeatures={%
90 {%
91 Size={-8},%
92 Font={NewCM08-Book.otf}%
93 },%
94 {%
95 Size={8-},%
96 Font={NewCM10-Book.otf}%
97 }%
98 }%
99 },%
100 BoldSwashFont={NewCM10-Bold.otf},%
101 BoldSwashFeatures={%
102 SizeFeatures={%
103 {%
104 Size={0-},%
105 Font={NewCM10-Bold.otf}%
106 }%
107 }%
108 }%
109 ]
110 \setsansfont{NewCMSans10-Book.otf}
111 \setmonofont{NewCMMono10-Book.otf}
112 \usepackage{lum-newcomputermodern}
113
114 \usetikzlibrary{cd}
115 \usepackage{fontawesome5}
116 \usepackage{longtable}
117 \usepackage{booktabs}
118 \usepackage{keytheorems}
119 \usepackage{zref-clever}
120 \zcsetup{nameinlink=false}
121
122 \makeatletter
123 \newcommand\keythmsversion{\@keythms@version}
124 \makeatother
125
126 \title{%
127 The \pkg{keytheorems} package \\[1ex]
128 \large version \keythmsversion \\[1ex]
129 \href{https://github.com/mbertucci47/keytheorems}
130 {\texttt{github.com/mbertucci47/keytheorems}}
131 }
132 \author{Matthew Bertucci}
133
134 \hypersetup{
135 pdftitle={keytheorems package},
136 pdfauthor={Matthew Bertucci},
137 }
138
139 \counterwithin{equation}{section}
140 \keytheoremset{restate-counters={section}}
141
142 \newkeytheoremstyle{breaksty}{break}
143 \newkeytheorem{theorem}
144 \newkeytheorem{mythm}[name=Some Name]
145 \newkeytheorem{theorem*}[name=Theorem,numbered=false]
146 \newkeytheorem{conjecture}[parent=section]
147 \newkeytheorem{lemma}[sibling=theorem]
148 \newkeytheorem{test}[
149 preheadhook=PREHEAD,
150 postheadhook=POSTHEAD,
151 prefoothook=PREFOOT,
152 postfoothook=POSTFOOT
153 ]
154 \newkeytheorem{prop}[
155 name=Proposition,
156 refname={proposition,propositions},
157 Refname={Proposition,Propositions}
158 ]
159 \newkeytheorem{example}[qed]
160 \newkeytheorem{solution}[qed=$\clubsuit$]
161 \newkeytheorem{remark}[style=remark]
162 \tcbset{
163 defstyle/.style={arc=0mm,colback=blue!5!white,colframe=blue!75!black},
164 thmstyle/.style={colback=green!5,colframe=green!35!black},
165 }
166 \newkeytheoremstyle{tcb-standard}{
167 tcolorbox=thmstyle,
168 headpunct={},
169 notebraces={}{},
170 noteseparator={: },
171 notefont=\bfseries,
172 bodyfont=\normalfont,
173 }
174 \newkeytheorem{mytheo}[name=Theorem,style=tcb-standard]
175 \newkeytheorem{corollary}[tcolorbox]
176 \newkeytheorem{definition}[
177 style=definition,
178 tcolorbox={defstyle}
179 ]
180 \newkeytheorem{boxcor}[
181 tcolorbox-no-titlebar={colback=red!10},
182 name=Corollary,
183 sibling=corollary,
184 ]
185 \newkeytheorem{observation}[style=breaksty]
186 \newkeytheorem{quotethm}[name=Quote Theorem,margin=1cm]
187 \newkeytheorem{indentedthm}[name=Indented Theorem,leftmargin=1cm]
188 \newkeytheorem{mainthm}[
189 name=Theorem,
190 counter-format=\Alph*,
191 ]
192 \newkeytheoremstyle{marginstyle}{headformat=margin}
193 \newkeytheoremstyle{swapnumberstyle}{headformat=swapnumber}
194 \newkeytheorem{marginthm}[name=Margin Theorem,style=marginstyle]
195 \newkeytheorem{swapnumberthm}[name=Swapnumber Theorem,style=swapnumberstyle]
196
197 \MakeShortVerb{\|}
198 \newcommand{\env}{\texttt}
199 \newcommand{\hook}{\texttt}
200 \NewCommandCopy{\braces}{\brackets}
201 \newcommand{\bracks}[1]{\texttt{[#1]}}
202 \newcommand{\ttbraces}[1]{\braces{\texttt{#1}}}
203 %\tcbset{index gather commands=false}
204 \usepackage{xcolor-solarized}
205 \colorlet{ExampleBack}{solarized-base3!50}
206 \colorlet{ExampleBackLower}{solarized-base3}
207 \tcbset{
208 color command=BrickRed,
209 color key=Fuchsia,
210 color value=teal,
211 before doc body={%
212 \setlength{\parindent}{15pt}
213 \noindent
214 },
215 docexample/.append style={boxrule=0pt,arc=0pt,after app={\noindent}}
216 }
217
218 \makeatletter % code from muzimuzhi (https://github.com/T-F-S/tcolorbox/issues/298)
219 \tcbset{
220 before verbatim write app/.code={%
221 \appto\tcb@verbatim@begin@hook{\tcb@iow@write{#1}}},
222 % provided for symmetry, but not used
223 after verbatim write pre/.code={%
224 \preto\tcb@verbatim@end@hook{\tcb@iow@write{#1}}},
225 }
226 \tcbset{
227 mark preamble/.style={
228 before verbatim write app={\@percentchar\space preamble},
229 },
230 mark document/.style={
231 before verbatim write app={\@percentchar\space document},
232 },
233 }
234 \tcbset{
235 listing engine=minted,
236 minted language=latex,
237 withpreamble/.style = {
238 mark document,
239 before upper = {%
240 % affects both the \tcbsettemplisting and the original upper
241 \setminted{listparameters={\topsep=0pt \partopsep=0pt}}%
242 \tcbusetemplisting
243 \vspace{5pt}%
244 }
245 }
246 }
247 \NewDocumentEnvironment{codepreamble}{}{%
248 \tcbset{mark preamble}%
249 \tcbwritetemp
250 }{%
251 \endtcbwritetemp
252 }
253 \makeatother
254
255 \NewTCBListing{keythmscode}{ !O{} }
256 {
257 colback=ExampleBack,
258 arc=0pt,
259 boxrule=0pt,
260 skin=bicolor,
261 colbacklower=ExampleBackLower,
262 breakable,
263 parbox=false, % so examples match document with indent, etc.
264 minted options app={breaksymbolleft={}},
265 #1
266 }
267 \newtcolorbox{notebox}[1][]{enhanced,
268 before skip balanced=2mm,after skip balanced=4mm,
269 boxrule=0.4pt,left=5mm,right=2mm,top=1mm,bottom=1mm,
270 colback=red!20,
271 colframe=red!40!black,
272 sharp corners,rounded corners=southeast,arc is angular,arc=3mm,
273 underlay={%
274 \path[fill=tcbcolback!80!black] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
275 \path[draw=tcbcolframe,shorten <=-0.05mm,shorten >=-0.05mm] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
276 \path[fill=red!40!black,draw=none] (interior.south west) rectangle node[white]{\LARGE\bfseries !} ([xshift=4mm]interior.north west);
277 },
278 drop fuzzy shadow,#1}
279 \makeatletter
280 % allow for optional argument specifying printed text, mostly for starred keys
281 \RenewDocumentCommand\tcb@ref@doc{msom}{%
282 \hyperref[{#1:#4}]{%
283 \IfValueTF{#3}{\texttt{#3}}{\texttt{\ref*{#1:#4}}}%
284 \IfBooleanTF{#2}{}{%
285 \ifnum\getpagerefnumber{#1:#4}=\thepage\relax%
286 \else%
287 \kvtcb@doc@format@page{{\fontfamily{pzd}\fontencoding{U}\fontseries{m}\fontshape{n}\selectfont\char213}%
288 \,\kvtcb@text@pageshort\,\pageref*{#1:#4}}%
289 \fi}}%
290 }
291 \newcommand{\TCBdescnewline}{%
292 \def\tcb@doc@do@description{%
293 \ifx\kvtcb@doc@description\@empty\else\tcblower\raggedleft\strut
294 \\[1ex]% added
295 (\kvtcb@doc@description)\strut\fi%
296 }%
297 }
298 \makeatother
299 \makeindex
300
301 \begin{document}
302
303 \maketitle
304
305 \begin{abstract}
306 An \pkg{expl3}-implementation of a key-value interface to \pkg{amsthm}, implementing most of the functionality provided by \pkg{thmtools}.
307 Several issues encountered with \pkg{thmtools} are avoided (see the README for a list) and a few new features are added.
308 \end{abstract}
309
310 \begingroup
311 \hypersetup{linkcolor=black}
312 \tableofcontents
313 \endgroup
314
315 \section{Dependencies}
316
317 The package depends on the \pkg{aliascnt}, \pkg{amsthm}, \pkg{refcount}, and \pkg{translations} packages.
318 The \refKey{tcolorbox} and \refKey{tcolorbox-no-titlebar} keys require \pkg{tcolorbox}, and the \refKey[numbered=unless-unique]{numbered} key requires the \pkg{unique} package.
319 A \LaTeX{} kernel no older than 2025-06-01 is required.
320
321 \section{Global options}
322
323 \begin{docCommand}{keytheoremset}
324 {\marg{options}}
325 Every key in this section can be given as an option to \cs{usepackage} or in \cs{keytheoremset}, with the exception that \refKey{continues-code} can only be used in the latter.
326 \end{docCommand}
327
328 \subsection{Compatibility options}
329
330 \begin{docKey}{overload}
331 {}
332 {initially unset}
333 Redefines \cs{newtheorem} to internally use the \pkg{keytheorems} machinery.
334 The syntax remains the same.
335 This is automatically set by \refKey{thmtools-compat}.
336 \end{docKey}
337
338 \begin{docKey}{thmtools-compat}
339 {}
340 {initially unset}
341 For compatibility with \pkg{thmtools} syntax.
342 For most documents,
343 \begin{dispListing}
344 \usepackage[thmtools-compat]{keytheorems}
345 \end{dispListing}
346 should be a drop-in replacement for \cs{usepackage}\ttbraces{amsthm,thmtools}.
347 The option defines the commands in the left column below.
348 The right column lists the corresponding \pkg{keytheorems} replacement that should be used in new documents.
349 \begin{longtable}{rcl}
350 \multicolumn{1}{c}{\pkg{thmtools} command} & & \multicolumn{1}{c}{\pkg{keytheorems} replacement} \\
351 \toprule
352 \docAuxCommand*{declaretheorem} & \textrightarrow & \refCom{newkeytheorem} \\
353 \docAuxCommand*{declaretheoremstyle} & \textrightarrow & \refCom{newkeytheoremstyle} \\
354 \docAuxCommand*{listoftheorems} & \textrightarrow & \refCom{listofkeytheorems} \\
355 \docAuxCommand*{listtheoremname} & \textrightarrow & \refKey{title} key \\
356 \begin{tabular}{r@{}}
357 \docAuxCommand*{addtotheorempreheadhook}\\
358 \docAuxCommand*{addtotheorempostheadhook}\\
359 \docAuxCommand*{addtotheoremprefoothook}\\
360 \docAuxCommand*{addtotheorempostfoothook}\\
361 \end{tabular} & \textrightarrow & \refCom{addtotheoremhook} \\
362 \docAuxEnvironment*{restatable} environment & \textrightarrow & \refKey{store} key \\
363 \docAuxEnvironment*{restatable*} environment & \textrightarrow & \refKey[store*]{store} key
364 \end{longtable}
365 Also defined are the \docAuxKey*{shaded} and \docAuxKey*{thmbox} keys, implemented internally with \pkg{tcolorbox} rather than the \pkg{shadethm} and \pkg{thmbox} packages, respectively.
366 \end{docKey}
367
368 \subsection{Other global options}
369
370 \begin{docKey}{auto-translate}
371 {\colOpt{=true\textbar false}}
372 {default |true|, initially |true|}
373 If |false|, \pkg{keytheorems} does not automatically translate the title text used for \refCom{listofkeytheorems} and the note produced by the \refKey{continues} key.
374 These texts can be manually customized with the \refKey{title} and \refKey{continues-code} keys, respectively.
375 \end{docKey}
376
377 \begin{docKey}[][before upper=\TCBdescnewline]{continues-code}
378 {=\meta{code with \textup{\texttt{\#1}}}}
379 {initially \cs{GetTranslation}\ttbraces{keythms\string_continues}\cs{pageref}\ttbraces{\#1}}
380 The code used to typeset the note produced by the \refKey{continues} key.
381 If English or an unknown language is used, defaults to \texttt{continuing from p.}\cs{,}\cs{pageref}\ttbraces{\#1}.
382 Currently (likely inaccurate!) translations exist for several European languages.
383 \end{docKey}
384
385 \begin{docKey}{predefined}
386 {\colOpt{=\marg{options}}}
387 {initially unset}
388 This is a convenience key, similar to \pkg{ntheorem}'s |standard| option, that predefines a set of theorems that, unless \refKey{auto-translate} is set to |false|, are translated into the current language if translations exist.
389 The predefined theorems are
390 \begin{itemize}
391 \item |plain| style: \docAuxEnvironment{conjecture}, \docAuxEnvironment{corollary}, \docAuxEnvironment{lemma}, \docAuxEnvironment{proposition}, \docAuxEnvironment{theorem};
392 \item |definition| style: \docAuxEnvironment{axiom}, \docAuxEnvironment{definition}, \docAuxEnvironment{example};
393 \item |remark| style: \docAuxEnvironment{remark}.
394 \end{itemize}
395 If your language does not have translations, please feel free to open a GitHub pull request.
396
397 These theorems are provided at the end of the preamble (specifically, in the \hook{begindocument} hook) with \refCom{providekeytheorem} so will not overwrite user-defined environments with the same name.
398 By default, the predefined theorems share a counter and do not have a parent counter.
399 These settings can be changed by calling |siblings=false| (alias |sharenumbers=false|) and/or |parent=|\meta{counter}, respectively, in \meta{options}.
400
401 \begin{dispListing}
402 \usepackage[
403 predefined={parent=section}
404 ]{keytheorems}
405
406 % or equivalently
407 \usepackage{keytheorems}
408 \keytheoremset{predefined={parent=section}}
409 \end{dispListing}
410 \end{docKey}
411
412 \begin{docKey}{qed-symbol}
413 {=\meta{symbol}}
414 {initially \cs{openbox}}
415 Redefines \cs{qedsymbol} to be \meta{symbol}.
416 \end{docKey}
417
418 \begin{docKey}{restate-counters}
419 {=\marg{comma-list of counters}}
420 {initially \ttbraces{equation}}
421 Additional counters whose values are preserved when a theorem is restated.
422 This key does not reset the list, so you don't need to include |equation| in \meta{comma-list}.
423 \end{docKey}
424
425 \begin{docKey}{store-all}
426 {}
427 {initially unset}
428 Tells \pkg{keytheorems} to grab the body of each theorem so it can later be printed with the \refKey{print-body} option of \refCom{listofkeytheorems}.
429 Note that this means a theorem body \emph{cannot} contain verbatim material.
430 \end{docKey}
431
432 \begin{docKey}{store-sets-label}
433 {}
434 {initially unset}
435 Defines the \refKey{store} key to also set \refKey{label}, i.e., it makes |store=|\meta{tag} equivalent to |store=|\meta{tag}|,label=|\meta{tag}.
436 Similarly for \refKey[store*]{store}.
437 \end{docKey}
438
439 \section{Defining theorems}
440
441 \begin{docCommand}{newkeytheorem}
442 {\marg{env name}\oarg{options}}
443 Defines a theorem environment \meta{env name} which itself takes a few options (see \autoref{in-doc-keys}).
444 You can also declare multiple theorems at once by replacing \meta{env name} with a comma-list of names, e.g.,
445 \begin{center}
446 \cs{newkeytheorem}\ttbraces{theorem,lemma,proposition}\bracks{\meta{options}}.
447 \end{center}
448
449 By default, the theorem's printed name is a title-cased \meta{env name}.
450 This can be changed with the \refKey{thm/name} key.
451 All \meta{options} are described in subsections \ref{thm-thmtools-keys} and \ref{thm-added-keys}.
452
453 \begin{codepreamble}
454 \newkeytheorem{theorem}
455 \end{codepreamble}
456
457 \begin{keythmscode}[withpreamble]
458 \begin{theorem}
459 There are infinitely many prime numbers.
460 \end{theorem}
461 \end{keythmscode}
462
463 \end{docCommand}
464
465 \begin{docCommands}[
466 doc parameter=\marg{env name}\oarg{options}
467 ]
468 {
469 {doc name = renewkeytheorem},
470 {doc name = providekeytheorem},
471 {doc name = declarekeytheorem},
472 }
473 Sometimes a package or class defines theorems that need to be overwritten by the user.
474 For this case, \pkg{keytheorems} provides \cs{renewkeytheorem} which redefines \meta{env name} or errors if it is not defined.
475 For completeness, also provided are \cs{providekeytheorem} and \cs{declarekeytheorem}.
476 The former only defines \meta{env name} if it is not already defined; the latter always overwrites \meta{env name}.
477 \end{docCommands}
478
479 \subsection{Keys available to theorem environments} \label{in-doc-keys}
480
481 As in \pkg{amsthm}, theorems can take an optional argument that contains a note or heading.
482
483 \begin{keythmscode}
484 \begin{theorem}[Bertrand's postulate]
485 For every $n\geq 1$, there is a prime number $p$ with $n<p\leq 2n$.
486 \end{theorem}
487 \end{keythmscode}
488
489 Alternatively, the optional argument may contain any of the following keys.
490
491 \begin{docKey}{note}
492 {=\meta{text}}
493 {initially unset}
494 Alias \docAuxKey[][doc label=thmuse/name]{name}.
495 This is the key-value equivalent of the optional argument described above.
496 This syntax, however, allows the argument to contain other keys.
497
498 \begin{keythmscode}
499 \begin{theorem}[note=Legendre's formula]
500 The number $n!$ contains the prime factor $p$ exactly
501 \[ \sum_{k\geq 1} \Bigl\lfloor\frac{n}{p^k}\Bigr\rfloor \]
502 times.
503 \end{theorem}
504 \end{keythmscode}
505
506 \end{docKey}
507
508 \begin{docKey}{short-note}
509 {=\meta{text}}
510 {initially unset}
511 Alias \docAuxKey{short-name}.
512 This replaces the value of \refKey{note} when displayed in the list of theorems (\refCom{listofkeytheorems}).
513 \end{docKey}
514
515 \begin{docKey}{label}
516 {=\meta{label name}}
517 {initially unset}
518 This is the key-value equivalent of |\begin{theorem}| \cs{label}\marg{label name}.
519
520 \begin{keythmscode}
521 \begin{theorem}[label=bezout,note=Bézout's identity]
522 Let $a$ and $b$ be integers. Then there exist integers $x$ and $y$ such that $ax+by=\gcd(a,b)$.
523 \end{theorem}
524 See \zcref{bezout}.
525 \end{keythmscode}
526
527 \end{docKey}
528
529 \begin{docKey}{manual-num}
530 {=\meta{text}}
531 {initially unset}
532 Use this to override the printed number of a theorem.
533 It is useful for making ``starred'' versions of other theorems, perhaps to represent a reformulated or more difficult version.
534
535 \begin{keythmscode}
536 \begin{theorem}[manual-num=\ref*{bezout}*]
537 Let $a_1,\dots,a_n$ be integers. Then there exist integers $x_1,\dots,x_n$ such that $a_1x_1+\dots+a_nx_n=\gcd(a_1,\dots,a_n)$.
538 \end{theorem}
539 \begin{theorem}[manual-num=\faRocket] % requires fontawesome5
540 Don't confuse your readers by changing the numbering without good reason.
541 \end{theorem}
542 \end{keythmscode}
543
544 \end{docKey}
545 \begin{docKey}{continues}
546 {\sarg=\meta{label name}}
547 {initially unset}
548 Pick up a theorem where you left off.
549 The theorem number remains the same.
550 The printed text can be customized with the \refKey{continues-code} option.
551 The starred version also copies the theorem \refKey{note} and \refKey{short-note} if they are nonempty.
552
553 \begin{keythmscode}
554 \begin{theorem}[continues=bezout]
555 Moreover, the integers of the form $az+bt$ are exactly the multiples of $\gcd(a,b)$.
556 \end{theorem}
557 \begin{theorem}[continues*=bezout]
558 Moreover, the integers of the form $az+bt$ are exactly the multiples of $\gcd(a,b)$.
559 \end{theorem}
560 \end{keythmscode}
561
562 \end{docKey}
563
564 \begin{docKey}{store}
565 {\sarg=\meta{tag}}
566 {initially unset}
567 Alias \docAuxKey{restate}\sarg.
568 Stores the the theorem to be restated at any point in the document with \refCom{getkeytheorem}.
569 With the starred version, counters and labels are taken from the copy called with \cs{getkeytheorem}, so in this case can only be restated once.
570 This allows you, for example, to write all theorems and proofs in the appendix and call \cs{getkeytheorem} at the appropriate time mid-document.
571 For the numbering to be correct, the unstarred key will need at most two runs and the starred key at most three runs.
572
573 \begin{keythmscode}
574 \begin{theorem}[store=blub]
575 A theorem worth restating.
576 \end{theorem}
577 More brilliant mathematics.
578 \getkeytheorem{blub}
579 \end{keythmscode}
580
581 A theorem given this key \emph{cannot} contain verbatim material or other unexpected catcodes such as a \pkg{tikz-cd} diagram.
582 The latter issue can be averted with the \texttt{ampersand-replacement} key.
583
584 \begin{codepreamble}
585 \usepackage{tikz}
586 \usetikzlibrary{cd}
587 \end{codepreamble}
588
589 \begin{keythmscode}[withpreamble]
590 \begin{lemma}[store=fiberprod]
591 For any $S$-schemes $X$ and $Y$, there exists a scheme $X\times_S Y$ with morphisms to $X$ and $Y$ such that the diagram
592 \[\begin{tikzcd}[ampersand replacement=\&]
593 X\times_S Y \ar[r] \ar[d] \& X \ar[d] \\
594 Y \ar[r] \& S
595 \end{tikzcd}\]
596 commutes and is universal with respect to this property.
597 \end{lemma}
598 \dots
599 \getkeytheorem{fiberprod}
600 \end{keythmscode}
601
602 \end{docKey}
603
604 \begin{docKey}{restate-keys}
605 {=\marg{list of keys}}
606 {initially unset}
607 Allows passing different keys to the restated theorem.
608 At the moment this is only useful with the \refKey{note} key.
609
610 \begin{keythmscode}
611 \begin{theorem}[
612 store=rktest,
613 note=Original,
614 restate-keys={note=Restated},
615 ]
616 Wow, yet another theorem.
617 \end{theorem}
618 \getkeytheorem{rktest}
619 \end{keythmscode}
620
621 \end{docKey}
622
623 \begin{docKey}{listhack}
624 {=\docValue*{true}\textbar\docValue*{false}}
625 {initially |false|}
626 Meant only to be used with the \refKey{break} style key for a theorem starting with a list.
627 Compare:
628
629 \begin{codepreamble}
630 \newkeytheoremstyle{breaksty}{break}
631 \newkeytheorem{observation}[style=breaksty]
632 \end{codepreamble}
633
634 \begin{keythmscode}[withpreamble]
635 \begin{observation}
636 \begin{enumerate}
637 \item First item
638 \item Second item
639 \end{enumerate}
640 \end{observation}
641
642 \begin{observation}[listhack=true]
643 \begin{enumerate}
644 \item First item
645 \item Second item
646 \end{enumerate}
647 \end{observation}
648 \end{keythmscode}
649
650 Note that the value |true| must be explicitly set so that |listhack| is not interpreted as the note text.
651 \end{docKey}
652
653 \begin{docKey}[][doc label=thmuse/seq]{seq}
654 {=\meta{name}}
655 {initially unset}
656 Adds the theorem to a custom sequence \meta{name} that can then be listed with \cs{listofkeytheorems}\bracks{seq=\meta{name}}.
657 See \refKey{listof/seq} for more details.
658 \end{docKey}
659
660 \begin{docKey}{tcb-append}
661 {=\marg{list of \pkg{tcolorbox} keys}}
662 {initially unset}
663 Appends the given \pkg{tcolorbox} keys to the |keythms_tcb_|\meta{env name} style for theorems defined with the \refKey{tcolorbox} or \refKey{tcolorbox-no-titlebar} keys.
664 Note that it is not recommended to frequently change the appearance of theorems throughout a document so use this key sparingly.
665 \end{docKey}
666
667 \begin{docKey}[][doc label=thmuse/ignore]{ignore}
668 {=\docValue*{true}\textbar\docValue*{false}}
669 {initially |false|}
670 If set to |true|, the theorem is completely ignored.
671
672 \begin{keythmscode}
673 Some text.
674 \begin{theorem}[ignore=true]
675 A theorem I want to ignore.
676 \end{theorem}
677 Some more text.
678 \end{keythmscode}
679
680 \end{docKey}
681
682 \subsection{Keys also defined in \pkg{thmtools}} \label{thm-thmtools-keys}
683
684 These are the \oarg{options} available to \cs{newkeytheorem}.
685 Except for \refKey{thm/name} and \refKey{style}, each key below can also be used in \refCom{newkeytheoremstyle}.
686 For more description, see the \href{https://ctan.org/pkg/thmtools}{\pkg{thmtools}} package.
687
688 \begin{docKey}[][doc label=thm/name]{name}
689 {=\meta{display name}}
690 {initially title-cased \meta{env name}}
691 Aliases \docAuxKey{heading} and \docAuxKey{title}.
692 Sets the displayed name of the theorem.
693
694 \begin{codepreamble}
695 \newkeytheorem{mythm}[name=Some Name]
696 \end{codepreamble}
697
698 \begin{keythmscode}[withpreamble]
699 \begin{mythm}
700 Some text
701 \end{mythm}
702 \end{keythmscode}
703
704 \end{docKey}
705
706 \begin{docKey}{numbered}
707 {=\docValue*{true}\textbar\docValue*{false}\textbar \docValue{unless-unique}}
708 {default |true|, initially |true|}
709 Determines if the theorem is numbered.
710 With the value |unless-unique|, there are two cases.
711 If no \refKey{parent} is given, a theorem is not numbered if it is the only theorem of its type and numbered otherwise.
712 If a \refKey{parent} is given, the same is true but considered within a single value of the parent counter.
713
714 For compatibility with \pkg{thmtools}, |numbered| also accepts the values \docValue*{yes}, \docValue*{no}, and \docValue*{unless unique}.
715
716 \begin{codepreamble}
717 \newkeytheorem{theorem*}[name=Theorem,numbered=false]
718 \end{codepreamble}
719
720 \begin{keythmscode}[withpreamble]
721 \begin{theorem*}
722 An unnumbered theorem.
723 \end{theorem*}
724 \end{keythmscode}
725
726 \end{docKey}
727
728 \begin{docKey}{parent}
729 {=\meta{counter}}
730 {initially unset}
731 Aliases \docAuxKey{numberwithin} and \docAuxKey{within}.
732 Sets the parent counter for the theorem counter, i.e., the displayed theorem number is of the form \meta{parent counter}\textbf{.}\meta{theorem counter} and the theorem counter is reset to 1 whenever the parent counter is incremented.
733
734 \begin{codepreamble}
735 \newkeytheorem{conjecture}[parent=section]
736 \end{codepreamble}
737
738 \begin{keythmscode}[withpreamble]
739 \begin{conjecture}
740 The first number is the section.
741 \end{conjecture}
742 \end{keythmscode}
743
744 \end{docKey}
745
746 \begin{docKey}{sibling}{=\meta{counter}}{initially unset}
747 Aliases \docAuxKey{numberlike} and \docAuxKey{sharenumber}.
748 Sets the sibling counter for the theorem counter, i.e., the sibling and theorem counters are incremented and reset simultaneously.
749
750 \begin{codepreamble}
751 \newkeytheorem{lemma}[sibling=theorem]
752 \end{codepreamble}
753
754 \begin{keythmscode}[withpreamble]
755 \begin{lemma}
756 This shares its counter with \texttt{theorem}.
757 \end{lemma}
758 \end{keythmscode}
759
760 \end{docKey}
761
762 \begin{docKey}{style}
763 {=\meta{style name}}
764 {initially unset}
765 Accepts any \meta{style name} defined by \refCom{newkeytheoremstyle}, as well as any of the predefined \pkg{amsthm} styles: \docValue{plain}, \docValue{definition}, and \docValue{remark}.
766 To emulate the appearance of theorems defined with the kernel \cs{newtheorem}, you may also use the predefined \docValue{legacy2e} style.
767 See \zcref{predefsty} for more on the predefined styles.
768
769 \begin{codepreamble}
770 \newkeytheorem{remark}[style=remark]
771 \end{codepreamble}
772
773 \begin{keythmscode}[withpreamble]
774 \begin{remark}
775 It's nice to distinguish remarks from definitions and theorems.
776 \end{remark}
777 \end{keythmscode}
778
779 \end{docKey}
780
781 \begin{docKeys}[
782 doc parameter = {=\meta{code}},
783 doc description = initially unset,
784 ]
785 {
786 { doc name = preheadhook },
787 { doc name = postheadhook },
788 { doc name = prefoothook },
789 { doc name = postfoothook },
790 }
791 Details in \autoref{keythms-hooks}.
792
793 \begin{codepreamble}
794 \newkeytheorem{test}[
795 preheadhook=PREHEAD,
796 postheadhook=POSTHEAD,
797 prefoothook=PREFOOT,
798 postfoothook=POSTFOOT,
799 ]
800 \end{codepreamble}
801
802 \begin{keythmscode}[withpreamble]
803 \begin{test}
804 Some text
805 \end{test}
806 \end{keythmscode}
807
808 \end{docKeys}
809
810 \begin{docKey}{qed}
811 {\colOpt{=\meta{symbol}}}
812 {default \cs{qedsymbol}, initially unset}
813 Adds \colOpt{\meta{symbol}} to the end of the theorem body.
814 If no value is given, the current value of |\qedsymbol| is used (one can redefine this or set it with \refKey{qed-symbol}).
815 By default, this is \qedsymbol.
816
817 \begin{codepreamble}
818 \newkeytheorem{example}[qed]
819 \newkeytheorem{solution}[qed=$\clubsuit$]
820 \end{codepreamble}
821
822 \begin{keythmscode}[withpreamble]
823 \begin{example}
824 Some text.
825 \end{example}
826 \begin{solution}
827 Some more text.
828 \end{solution}
829 \end{keythmscode}
830
831 \end{docKey}
832
833 \begin{docKey}[][before upper=\TCBdescnewline]{refname}
834 {=\meta{ref name} \textrm{or} \brackets{\meta{singular name},\meta{plural name}}}
835 {initially \cs{text\string_lowercase:n} \marg{display name}}
836 If a single string, then the name used by \pkg{hyperref}'s \cs{autoref}, \pkg{cleveref}'s \cs{cref}, and \pkg{zref-clever}'s \cs{zcref}.
837 If two strings separated by a comma, then the second string is the plural form used by \cs{cref} and \cs{zcref}.
838 \end{docKey}
839
840 \begin{docKey}[][before upper=\TCBdescnewline]{Refname}
841 {=\meta{ref name} \textrm{or} \brackets{\meta{singular name},\meta{plural name}}}
842 {initially \cs{text\string_titlecase\string_first:n} \marg{display name}}
843 Same as \refKey{refname} but for \docAuxCommand{Autoref}, \cs{Cref}, and \cs{zcref} with any of its capitalizing options.
844 Note that \cs{Autoref} is defined by \pkg{keytheorems}, but requires \pkg{hyperref} to work.
845 As with \cs{autoref}, there is also a starred version \docAuxCommand{Autoref*} that suppresses the hyperlink.
846
847 \begin{codepreamble}
848 \newkeytheorem{prop}[
849 name=Proposition,
850 refname={proposition,propositions},
851 Refname={Proposition,Propositions},
852 ]
853 \end{codepreamble}
854
855 \begin{keythmscode}[withpreamble]
856 \begin{prop}[label=abc]
857 Some text.
858 \end{prop}
859 \begin{prop}[label=def]
860 Some more text.
861 \end{prop}
862 Consider \zcref{abc,def}. \Autoref{abc} \dots
863 \end{keythmscode}
864
865 \end{docKey}
866
867 Both \pkg{cleveref} and \pkg{zref-clever} define default reference names for some commonly used counters like |theorem|, |lemma|, etc.
868 For technical reasons, unless explicit values for \refKey{refname} and \refKey{Refname} are given, \pkg{keytheorems} does not try to change these defaults at all in the case of \pkg{cleveref} and only the singular name in the case of \pkg{zref-clever}.
869 The easiest way to get exactly the output you want is to just explicitly set \refKey{refname} and \refKey{Refname}.
870
871 \begin{notebox}
872 The \refPkg{cleveref} package has not been updated since 2018 and contains several incompatibilities with the \LaTeX{} kernel.
873 These are often patched by the \LaTeX{} team, but further incompatibilities are likely to arise with each future update.
874 For this reason, I recommend moving to \refPkg{zref-clever}.
875 It offers all the same features as \pkg{cleveref} and is actively maintained.
876 \end{notebox}
877
878 \begin{docKeys}[doc parameter={=\meta{plural name}}]
879 {
880 { doc name=plural-refname, doc description=initially unset },
881 { doc name=plural-Refname, doc description=initially unset },
882 }
883 For convenience, you can also just specify the \meta{plural name} with these keys.
884 Since \pkg{keytheorems} uses the \meta{display name} to form the defaults for the \meta{singular name} but does not try to guess the \meta{plural name}, it's often the case that the user only needs to specify values for these keys and not \refKey{refname} or \refKey{Refname}.
885 \end{docKeys}
886
887 \subsection{Keys added by \pkg{keytheorems}} \label{thm-added-keys}
888
889 \begin{docKey}{counter-format}
890 {=\meta{code}}
891 {initially unset}
892 Syntactic sugar that essentially does \cs{renewcommand}\ttbraces{\cs{the}\meta{counter}}\marg{code}.
893 The \meta{code} should not contain any unexpandable tokens such as formatting commands.
894 Formatting should be taken care of in the style keys \refKey{headfont} and \refKey{numberfont}.
895 If used with an unnumbered theorem, a warning is issued.
896
897 \begin{codepreamble}
898 \newkeytheorem{mainthm}[
899 name=Theorem,
900 counter-format=\Alph*,
901 ]
902 \end{codepreamble}
903
904 \begin{keythmscode}[withpreamble]
905 \begin{mainthm}
906 The first main result, distinguished by using letters.
907 \end{mainthm}
908 \begin{mainthm}
909 And here is the second main result.
910 \end{mainthm}
911 \end{keythmscode}
912
913 The |*| following |\Alph| means ``use the current counter'', a syntax originally introduced in \pkg{enumitem}'s |label| key.
914 This is available with a \LaTeX{} kernel 2025-06-01 or later.
915 For older kernels, the above example could be implemented equivalently with |counter-format=\Alph{mainthm}|.
916 \end{docKey}
917
918 \begin{docKeys}[doc parameter={=\meta{length}}]
919 {
920 { doc name=leftmargin },
921 { doc name=rightmargin },
922 { doc name=margin, doc description=initially |0pt| },
923 }
924 Sets the left (respectively, right) margin of the theorem relative to the text width.
925 The |margin| key sets both simultaneously.
926 This sets the theorem apart from the text, similar to a block quote.
927 The code was adapted from Enrico Gregorio's \TeX{} Stack Exchange answers:
928 \begin{itemize}
929 \item \href{https://tex.stackexchange.com/a/67251/208544}{How to change margins in enunciation (theorem-like environment)?}
930 \item \href{https://tex.stackexchange.com/a/236407/208544}{A theoremstyle with complete indentation using amsthm}
931 \end{itemize}
932 \begin{codepreamble}
933 \newcommand{\marginthmtext}{%
934 We need some text to show off theorems with margins. }
935 \newkeytheorem{quotethm}[name=Quote Theorem,margin=1cm]
936 \newkeytheorem{indentedthm}[name=Indented Theorem,leftmargin=1cm]
937 \end{codepreamble}
938
939 \newcommand{\marginthmtext}{We need some text to show off theorems with margins. }
940 \begin{keythmscode}[withpreamble]
941 \marginthmtext\marginthmtext\marginthmtext
942
943 \begin{quotethm}
944 \marginthmtext\marginthmtext\marginthmtext
945 \end{quotethm}
946
947 \marginthmtext\marginthmtext\marginthmtext
948
949 \begin{indentedthm}
950 \marginthmtext\marginthmtext\marginthmtext
951 \end{indentedthm}
952 \end{keythmscode}
953
954 \end{docKeys}
955
956 \begin{docKey}{tcolorbox}
957 {\colOpt{=\marg{tcolorbox options}}}
958 {initially unset}
959 This key specifies that the theorem be placed inside a |tcolorbox| environment with \colOpt{\meta{options}}.
960 The theorem head is typeset as a |tcolorbox| title; to avoid this see \refKey{tcolorbox-no-titlebar}.
961
962 \begin{codepreamble}
963 \tcbset{
964 defstyle/.style={
965 arc=0mm,
966 colback=blue!5!white,
967 colframe=blue!75!black
968 },
969 }
970 \newkeytheorem{corollary}[tcolorbox]
971 \newkeytheorem{definition}[style=definition,tcolorbox={defstyle}]
972 \end{codepreamble}
973
974 \begin{keythmscode}[withpreamble]
975 \begin{corollary}
976 Products exist in the category of schemes over $S$.
977 \end{corollary}
978 \begin{definition}[Dedekind domains]
979 A \emph{Dedekind domain} is an integrally closed, Noetherian domain of dimension one.
980 \end{definition}
981 \end{keythmscode}
982
983 \end{docKey}
984
985 \begin{docKey}{tcolorbox-no-titlebar}
986 {\colOpt{=\marg{tcolorbox options}}}
987 {initially unset}
988 Same usage as \refKey{tcolorbox} but the theorem head is typeset as usual, not as a |tcolorbox| title.
989
990 \begin{codepreamble}
991 \newkeytheorem{boxcor}[
992 tcolorbox-no-titlebar={colback=red!10},
993 name=Corollary,
994 sibling=corollary,
995 ]
996 \end{codepreamble}
997
998 \begin{keythmscode}[withpreamble]
999 \begin{boxcor}[Cauchy's theorem]
1000 Let $G$ be a finite group and $p$ a prime dividing the order of $G$. Then $G$ contains an element of order $p$.
1001 \end{boxcor}
1002 \end{keythmscode}
1003
1004 \end{docKey}
1005
1006 \sloppy
1007 Both \refKey{tcolorbox} and \refKey{tcolorbox-no-titlebar} set up a \pkg{tcolorbox} style |keythms_tcb_|\meta{env name} that can be accessed by the user if needed.
1008 For convenience, one can also adjust the style for a specific theorem with the \refKey{tcb-append} key.
1009
1010 \fussy
1011 \pkg{tcolorbox} offers its own comprehensive \texttt{theorems} library.
1012 If all of your theorems are to be tcolorboxes, I highly recommend using it instead of this package! However, if only some of your theorems will use a tcolorbox, you may want to replicate the styles of \cs{NewTcbTheorem}.
1013 Here is an example that emulates \pkg{tcolorbox}'s \texttt{standard} theorem style.
1014
1015 \begin{codepreamble}
1016 \tcbset{
1017 thmstyle/.style={
1018 colback=green!5,
1019 colframe=green!35!black},
1020 }
1021 \newkeytheoremstyle{tcb-standard}{
1022 tcolorbox=thmstyle,
1023 headpunct={},
1024 notebraces={}{},
1025 noteseparator={: },
1026 notefont=\bfseries,
1027 bodyfont=\normalfont,
1028 }
1029 \newkeytheorem{mytheo}[
1030 name=Theorem,
1031 style=tcb-standard,
1032 ]
1033 \end{codepreamble}
1034
1035 \begin{keythmscode}[withpreamble]
1036 \begin{mytheo}[Quillen-Suslin]
1037 Every finitely generated projective module over a polynomial ring is free.
1038 \end{mytheo}
1039 \end{keythmscode}
1040
1041 \section{Theorem styles}
1042 \label{thmstyles}
1043
1044 \begin{docCommand}{newkeytheoremstyle}
1045 {\marg{style name}\marg{options}}
1046 This is \pkg{keytheorems}' version of \pkg{thmtools}' \cs{declaretheoremstyle}.
1047 Since it makes little sense to define a style with no keys, we've made the \meta{options} argument mandatory.
1048 The defined style can be used with either the \refKey{style} key or the traditional \cs{theoremstyle}.
1049 Note that unlike \pkg{amsthm}'s \cs{newtheoremstyle}, this command will error if a style has already been defined.
1050 \end{docCommand}
1051
1052 \begin{docCommands}[
1053 doc parameter=\marg{style name}\marg{options}
1054 ]
1055 {
1056 {doc name = renewkeytheoremstyle},
1057 {doc name = providekeytheoremstyle},
1058 {doc name = declarekeytheoremstyle},
1059 }
1060 \sloppy
1061 To overwrite an existing style, there is the analogous \cs{renewkeytheoremstyle}.
1062 For completeness, also provided are \cs{providekeytheoremstyle} and \cs{declarekeytheoremstyle}.
1063 \end{docCommands}
1064
1065 \subsection{Predefined styles}
1066 \label{predefsty}
1067
1068 \pkg{amsthm} defines the styles |plain|, |definition|, and |remark|. These, along with a |legacy2e| style meant to emulate the style of the kernel \cs{newtheorem}, are supported in both the \refKey{style} theorem key and the \refKey{inherit-style} style key.
1069 The initial values changed by each style are described below.
1070 \begin{itemize}
1071 \item \docValue*{plain}: This is the default.
1072 \item \docValue*{definition}: |bodyfont=\normalfont|
1073 \item \docValue*{remark}: |bodyfont=\normalfont|, |headfont=\itshape|, |spaceabove=0.5\topsep|, |spacebelow=0.5\topsep|
1074 \item \docValue*{legacy2e}: |notefont=\bfseries|, |headpunct={}|
1075 \end{itemize}
1076
1077 \subsection{Keys also defined in \pkg{thmtools}}
1078 \label{stylekeys:thmtools}
1079
1080 The following keys have the same meaning and syntax as the corresponding \pkg{thmtools} keys.
1081 In addition to the list below, most of the keys available to \refCom{newkeytheorem} can be used in \cs{newkeytheoremstyle}.
1082
1083 \begin{docKey}{bodyfont}
1084 {=\meta{font declarations}}
1085 {initially \cs{itshape}}
1086 Sets the font declarations for the theorem body.
1087 This does not affect the theorem heading; see \refKey{headfont}.
1088 \end{docKey}
1089
1090 \begin{docKey}{break}
1091 {}
1092 {initially unset}
1093 Causes the theorem body to be typeset on a new line after the heading.
1094 Do not use this with the \refKey{postheadspace} key.
1095 \end{docKey}
1096
1097 \begin{docKey}{headfont}
1098 {=\meta{font declarations}}
1099 {initially \cs{bfseries}}
1100 Sets the font declarations for the theorem heading, which includes the theorem name, number, and note.
1101 The heading is typeset in a \TeX\ group, so these declarations will not affect the body of the theorem.
1102 Note, however, that the declarations in the \refKey{numberfont} and \refKey{notefont} keys may reset some font features set in |headfont|.
1103 By default, the number is typeset in upright shape and the note in both upright shape and medium weight.
1104 \end{docKey}
1105
1106 \begin{docKey}[][before upper=\TCBdescnewline]{headformat}
1107 {=\docValue{margin}\textbar\docValue{swapnumber}\textbar\meta{code using \cs{NAME}, \cs{NUMBER}, and \cs{NOTE}\,}}
1108 {initially \cs{NAME}\cs{\textvisiblespace}\cs{NUMBER}\cs{NOTE}}
1109 Alias \docAuxKey{headstyle}.
1110 Allows the user to completely control the appearance of the theorem heading.
1111 Within \meta{code}, the commands \docAuxCommand{NAME}, \docAuxCommand{NUMBER}, and \docAuxCommand{NOTE} correspond to the formatted parts of the theorem head.
1112 For compatibility with \pkg{thmtools}, the user is in charge of specifying the separator (usually a space) preceding \cs{NUMBER}; the separator preceding \cs{NOTE} is controlled by \refKey{noteseparator}.
1113
1114 The special values |margin| and |swapnumber| are demonstrated below.
1115
1116 \begin{codepreamble}
1117 \newkeytheoremstyle{marginstyle}{headformat=margin}
1118 \newkeytheoremstyle{swapnumberstyle}{headformat=swapnumber}
1119 \newkeytheorem{marginthm}[
1120 name=Margin Theorem,
1121 style=marginstyle,
1122 ]
1123 \newkeytheorem{swapnumberthm}[
1124 name=Swapnumber Theorem,
1125 style=swapnumberstyle,
1126 ]
1127 \end{codepreamble}
1128
1129 \begin{keythmscode}[withpreamble]
1130 \begin{marginthm}
1131 A theorem whose number juts into the margin.
1132 \end{marginthm}
1133 \begin{swapnumberthm}
1134 A theorem whose name and number are swapped.
1135 \end{swapnumberthm}
1136 \end{keythmscode}
1137
1138 \end{docKey}
1139
1140 \begin{notebox}
1141 In \refKey{headformat}, you may also use the traditional \pkg{amsthm} commands \cs{thmname}, \cs{thmnumber}, and \cs{thmnote}, where |#1| is the theorem name, |#2| the number, and |#3| the note.
1142 \pkg{keytheorems} expands the head spec inside |\text_expand:n| so for these commands to work properly, the package adds them to |\l_text_expand_exclude_tl|.
1143 Note also that if you use these lower-level commands, the style keys \refKey{notebraces}, \refKey{notefont}, \refKey{noteseparator}, and \refKey{numberfont} will have no effect (of course, you can manually control these things inside the commands' arguments).
1144 \end{notebox}
1145
1146 \begin{docKey}{headindent}
1147 {=\meta{length}}
1148 {initially |0pt|}
1149 Sets the distance between the left margin and the theorem heading.
1150 \end{docKey}
1151
1152 \begin{docKey}{headpunct}
1153 {=\meta{code}}
1154 {initially \ttbraces{.}}
1155 Sets the punctuation that ends the theorem heading.
1156 \end{docKey}
1157
1158 \begin{docKey}{notebraces}
1159 {=\marg{left brace}\marg{right brace}}
1160 {initially \ttbraces{(}\ttbraces{)}}
1161 Sets the delimiters surrounding the theorem note if present.
1162 \end{docKey}
1163
1164 \begin{docKey}{notefont}
1165 {=\meta{font declarations}}
1166 {initially \cs{fontseries}\cs{mddefault}\cs{upshape}}
1167 Sets the font declarations for the theorem note.
1168 The note is also affected by \refKey{headfont}; the initial value of |notefont| happens to negate the initial value of |headfont| by resetting the font weight to medium, however any other settings in |headfont| will propagate to the note.
1169 \end{docKey}
1170
1171 \begin{docKey}{postheadspace}
1172 {=\meta{skip expr}}
1173 {initially |5pt plus 1pt minus 1pt|}
1174 Sets the distance between the theorem heading and body.
1175 Do not use this with the \refKey{break} key.
1176 \end{docKey}
1177
1178 \begin{docKey}{spaceabove}
1179 {=\meta{skip expr}}
1180 {initially \cs{topsep}}
1181 Sets the vertical space before the theorem.
1182 \end{docKey}
1183
1184 \begin{docKey}{spacebelow}
1185 {=\meta{skip expr}}
1186 {initially \cs{topsep}}
1187 Sets the vertical space after the theorem.
1188 \end{docKey}
1189
1190 \begin{notebox}
1191 With \refKey{tcolorbox} and \refKey{tcolorbox-no-titlebar}, the \refKey{spaceabove} and \refKey{spacebelow} keys are internally passed to \pkg{tcolorbox}'s \texttt{before skip} and \texttt{after skip}.
1192 When no explicit \texttt{spaceabove} or \texttt{spacebelow} values are given, \pkg{tcolorbox} defaults are used instead of \cs{topsep}.
1193 \end{notebox}
1194
1195 \subsection{Keys added by \pkg{keytheorems}}
1196 \label{stylekeys:new}
1197
1198 \begin{docKey}{inherit-style}
1199 {=\meta{style name}}
1200 {initially unset}
1201 Inherit the keys of any style declared with \refCom{newkeytheoremstyle}.
1202 Additionally, \docValue{legacy2e} and the three styles predefined by \pkg{amsthm} are possible values: \docValue{plain}, \docValue{definition}, and \docValue{remark}.
1203 \end{docKey}
1204
1205 \begin{docKey}{noteseparator}
1206 {=\meta{code}}
1207 {initially \textvisiblespace}
1208 The code inserted before the note, and printed only if there is a note.
1209 This is executed \emph{before} the font commands set by \refKey{notefont} take effect.
1210 \end{docKey}
1211
1212 \begin{docKey}{numberfont}
1213 {=\meta{font declarations}}
1214 {initially \cs{upshape}}
1215 Sets the font declarations for the theorem number.
1216 For almost all theorem styles, it is recommended that you \emph{do not} change this setting.
1217 As with \refKey{notefont}, the number font is affect by \refKey{headfont}, though here the initial value only changes the shape to upright.
1218 \end{docKey}
1219
1220 \begin{notebox}
1221 For the AMS classes \cls{amsart}, \cls{amsbook}, and \cls{amsproc}, as well as the \cls{amsart}-based \cls{acmart} and \cls{aomart}, the initial key values are slightly different those listed in \zcref{stylekeys:new,stylekeys:thmtools} in order to match those class's defaults.
1222 See \autoref{class-support} for details.
1223 \end{notebox}
1224
1225 \section{Restating theorems}
1226
1227 When a theorem is given the \refKey{store} key, the contents of the theorem are saved and written to a |.thlist| file.
1228 At the start of the next run, this file is input at the beginning of the document and allows you to retrieve the stored theorems at any point, before or after the original theorem.
1229
1230 \begin{docCommand}{getkeytheorem}
1231 {\oarg{property}\marg{tag}}
1232 Retrieves the theorem given the key |store=|\meta{tag} or |store*=|\meta{tag}.
1233 An optional \meta{property} can be given to retrieve only the corresponding part of the theorem.
1234 Currently only the property |body| is implemented, which retrieves the (unformatted) body of the theorem.
1235
1236 \begin{keythmscode}
1237 \getkeytheorem{mytag}
1238
1239 \begin{example}[store=mytag]
1240 Fascinating example.
1241 \end{example}
1242
1243 \getkeytheorem[body]{mytag}
1244 \end{keythmscode}
1245
1246 \end{docCommand}
1247
1248 \begin{docCommands}
1249 {
1250 {
1251 doc name = IfRestatingTF,
1252 doc parameter=\marg{true code}\marg{false code}
1253 },
1254 {
1255 doc name = IfRestatingT,
1256 doc parameter=\marg{true code}
1257 },
1258 {
1259 doc name = IfRestatingF,
1260 doc parameter=\marg{false code}
1261 }
1262 }
1263 Executes \meta{true code} if being retrieved with \refCom{getkeytheorem} and \meta{false code} if in the original theorem.
1264 This is reversed if \texttt{store*} is used.
1265
1266 \begin{keythmscode}
1267 \begin{example}[store=hmm]
1268 I am the \IfRestatingTF{restated}{original} example!
1269 \end{example}
1270
1271 \getkeytheorem{hmm}
1272 \end{keythmscode}
1273
1274 \end{docCommands}
1275
1276 \subsection{Counters within a restated theorem}
1277
1278 Counters used within a theorem can be stored and set to their original value when restated.
1279 By default, this is done for the |equation| counter, however more counters can be added with \refKey{restate-counters}.
1280 This is necessary if, as is often the case, equations use the |section| or |subsection| counter as part of their numbering.
1281
1282 \begin{codepreamble}
1283 \counterwithin{equation}{section}
1284 \keytheoremset{restate-counters={section}}
1285 \end{codepreamble}
1286
1287 \begin{keythmscode}[withpreamble]
1288 \begin{theorem}[store=Fermat]
1289 For $n\geq 3$, there are no nontrivial integer solutions to the equation
1290 \begin{equation}
1291 x^n+y^n=z^n.
1292 \end{equation}
1293 \end{theorem}
1294
1295 \getkeytheorem{Fermat}
1296 \end{keythmscode}
1297
1298 In this example, removing |\keytheoremset{restate-counters={section}}| would not change the restated equation number because it is being restated in the same section.
1299 If that line were removed, the restated equation number would be different (wrong) if restated in a different section.
1300
1301 \subsection{Restating theorems from an external file}
1302
1303 \begin{docCommand}{externaltheorems}
1304 {\oarg{prefix}\marg{file name}}
1305 This is \pkg{keytheorems}' version of the \pkg{xr} package's \cs{externaldocument}.
1306 It allows the user to restate theorems from another document's |.thlist| file.
1307 Say you have a file |mycoolpaper.tex|,
1308 \begin{dispListing}
1309 % mycoolpaper.tex
1310 \documentclass{article}
1311 \usepackage{keytheorems}
1312 \newkeytheorem{theorem}
1313 \begin{document}
1314 \begin{theorem}[store=cooltheorem]
1315 My cool theorem.
1316 \end{theorem}
1317 \end{document}
1318 \end{dispListing}
1319 and you'd like to restate the theorem with tag |cooltheorem| in another file |myothercoolpaper.tex| with the same numbering as in the original paper.
1320 Since your new paper probably also has cool theorems that you may want to tag as |cooltheorem|, you'd like to give all restatable theorems from |mycoolpaper.tex| a prefix when retrieved with \refCom{getkeytheorem}, say ``|orig:|''.
1321 \sloppy Just call \cs{externaltheorems}|[orig:]{mycoolpaper}| after loading \pkg{keytheorems} in the new document.
1322 Then any stored theorem from |mycoolpaper.tex| can be retrieved with \cs{getkeytheorem}\ttbraces{orig:\meta{tag}}.
1323 \begin{dispListing}
1324 % myothercoolpaper.tex
1325 \documentclass{article}
1326 \usepackage{keytheorems}
1327 \externaltheorems[orig:]{mycoolpaper}
1328 \newkeytheorem{theorem}
1329 \begin{document}
1330 \getkeytheorem{orig:cooltheorem}
1331 \end{document}
1332 \end{dispListing}
1333 It is important that the |theorem| environment is defined in both documents.
1334 \end{docCommand}
1335
1336 \section{Listing theorems}
1337 \label{listingthms}
1338
1339 \begin{docCommand}{listofkeytheorems}
1340 {\oarg{options}}
1341 Similar to \cs{listoffigures} or \cs{listoftables} but for theorems.
1342 For \cls{memoir} and the AMS classes, \pkg{keytheorems} tries to copy the formatting of these commands as defined by the class.
1343 For other classes, manual adjustments to \refKey{numwidth} and \refKey{indent} may be necessary.
1344 \end{docCommand}
1345
1346 \begin{docCommand}{keytheoremlistset}
1347 {\marg{options}}
1348 The \meta{options} of \refCom{listofkeytheorems} may also be set globally with this command.
1349 \end{docCommand}
1350
1351 \begin{keythmscode}
1352 \listofkeytheorems
1353 \end{keythmscode}
1354
1355 \subsection{Keys also defined in \pkg{thmtools}}
1356
1357 \begin{docKey}{ignore}
1358 {=\marg{comma-list of env names}}
1359 {initially unset}
1360 Environments in \meta{comma-list} are filtered out from the list of theorems.
1361 \end{docKey}
1362
1363 \begin{docKey}{ignoreall}
1364 {}
1365 {initially unset}
1366 Applies \refKey{ignore} to all theorems.
1367 This is usually followed by the keys \refKey{show}, \refKey{onlynamed}, and/or \refKey{onlynumbered}.
1368
1369 \begin{keythmscode}
1370 \listofkeytheorems[ignoreall,show=theorem]
1371 \listofkeytheorems[
1372 ignoreall, show=conjecture,
1373 title=List of Conjectures
1374 ]
1375 \end{keythmscode}
1376
1377 \end{docKey}
1378
1379 \begin{docKey}{numwidth}
1380 {=\meta{length}}
1381 {initially |2.3em|}
1382 Sets the width that theorem numbers occupy in the list of theorems.
1383 This is needed when theorems have long parent counter representations, e.g., Theorem 3.7.4.1.
1384 For the AMS classes, this is initially |1.5pc|.
1385 \end{docKey}
1386
1387 \begin{docKey}{onlynamed}
1388 {\colOpt{=\marg{comma-list of env names}}}
1389 {initially unset}
1390 Environments in \meta{comma-list} are only printed if the theorem was given an optional note.
1391 If no value is given, then this applies to all theorems.
1392 \end{docKey}
1393
1394 \begin{docKey}{show}
1395 {=\marg{comma-list of env names}}
1396 {initially all theorems}
1397 The counterpart to \refKey{ignore}.
1398 Environments in \meta{comma-list} are shown in the list of theorems.
1399 Note that this is only needed if a theorem type was previously ignored, usually with \refKey{ignoreall}.
1400 \end{docKey}
1401
1402 \begin{docKey}{showall}
1403 {}
1404 {initially set}
1405 Applies \refKey{show} to all theorems.
1406 \end{docKey}
1407
1408 \begin{docKey}{swapnumber}
1409 {\colOpt{=true\textbar false}}
1410 {initially |false|}
1411 Swaps the position of the theorem name and number in the list of theorems.
1412 This will override \refKey{format-code} if true.
1413
1414 \begin{keythmscode}
1415 \listofkeytheorems[ignoreall,show=lemma]
1416 \listofkeytheorems[ignoreall,show=lemma,swapnumber]
1417 \end{keythmscode}
1418
1419 \end{docKey}
1420
1421 \begin{docKey}{title}
1422 {=\meta{text}}
1423 {initially \cs{GetTranslation}\ttbraces{keythms\string_listof\string_title}}
1424 Defaults to ``List of Theorems'' if English or an unknown language is used.
1425 Currently several European languages have (likely inaccurate!) translations.
1426 A translation can be added with a GitHub pull request or manually with
1427 \begin{center}
1428 \cs{DeclareTranslation}\marg{lang}\ttbraces{keythms\string_listof\string_title}\marg{text}.
1429 \end{center}
1430 \end{docKey}
1431
1432 \subsection{Keys added by \pkg{keytheorems}}
1433
1434 \begin{docKey}{format-code}
1435 {=\meta{code with \textup{\texttt{\#1}}, \textup{\texttt{\#2}}, and \textup{\texttt{\#3}}}}
1436 {initially \cs{numberline}\texttt{\{\#2\}\#1\#3}}
1437 Allows full control over the format for list entries.
1438 The theorem name is |#1|, the number is |#2|, and the (formatted) note is |#3|.
1439 The note formatting is still controlled by \refKey{note-code}.
1440 \end{docKey}
1441
1442 \begin{docKey}{indent}
1443 {=\meta{length}}
1444 {initially |1.5em|}
1445 Sets the left indent of items in the list of theorems.
1446 For \cls{memoir} and the AMS classes, the indent is initially |0pt|.
1447 It is not recommended to change this unless your class has different defaults not already covered.
1448 \end{docKey}
1449
1450 \begin{docKey}{no-chapter-skip}
1451 {\colOpt{=true\textbar false}}
1452 {initially |false|}
1453 By default a small vertical space is inserted between each chapter's chunk of theorems.
1454 Setting this key to |true| removes this space.
1455 \end{docKey}
1456
1457 \begin{docKey}{chapter-skip-length}
1458 {=\meta{length}}
1459 {initially |10pt|}
1460 Controls the amount of space inserted between chunks of theorems belonging to each chapter.
1461 \end{docKey}
1462
1463 \begin{docKey}{no-continues}
1464 {\colOpt{=true\textbar false}}
1465 {initially |false|}
1466 Suppresses the printing of theorems given the \refKey{continues} key in the list of theorems.
1467 \end{docKey}
1468
1469 \begin{docKey}{no-title}
1470 {\colOpt{=true\textbar false}}
1471 {initially |false|}
1472 Suppresses the title of the list of theorems.
1473 This is useful for custom ordering of the list.
1474
1475 \begin{keythmscode}
1476 \keytheoremlistset{ignoreall}
1477 \listofkeytheorems[show=example]
1478 \listofkeytheorems[show=solution,no-title]
1479 \end{keythmscode}
1480
1481 \end{docKey}
1482
1483 \begin{docKey}{no-toc}
1484 {\colOpt{=true\textbar false}}
1485 {initially |false|}
1486 With the standard classes, lists of figures/tables are not added to the table of contents by default.
1487 The same is true for \cs{listofkeytheorems}, and with those classes this key does nothing.
1488 However some classes, notably \cls{memoir} and the AMS classes, do add lists to the table of contents.
1489 With these classes, this key suppresses the addition of the list of theorems to the table of contents.
1490 \end{docKey}
1491
1492 \begin{docKey}{note-code}
1493 {=\meta{code with \textup{\texttt{\#1}}}}
1494 {initially \ttbraces{\textvisiblespace(\#1)}}
1495 Formats the optional note in the list of theorems.
1496 \end{docKey}
1497
1498 \begin{docKey}{one-col}
1499 {\colOpt{=true\textbar false}}
1500 {initially |false|}
1501 In |twocolumn| mode, some classes such as the standard \cls{book} typeset lists of figures, etc., in one column.
1502 \pkg{keytheorems} does not do this by default; this key forces the list into |onecolumn| mode.
1503 Note that this is \emph{not} compatible with the application mentioned under \refKey{no-title} since switching between \cs{onecolumn} and \cs{twocolumn} starts a new page.
1504 You can, however, achieve the same effect manually:
1505 \begin{dispListing}
1506 \keytheoremlistset{ignoreall}
1507 \onecolumn
1508 \listofkeytheorems[show=example]
1509 \listofkeytheorems[show=solution,no-title]
1510 \twocolumn
1511 \end{dispListing}
1512 If \refKey{no-chapter-skip} is false (the default), you may want to add some vertical space between the two lists.
1513 \end{docKey}
1514
1515 \begin{docKey}{onlynumbered}
1516 {\colOpt{=\marg{comma-list of env names}}}
1517 {initially unset}
1518 Similar to \refKey{onlynamed}, but lists only those theorems which are numbered.
1519 This is useful if you'd like to exclude things like unnumbered definitions and remarks from the list of theorems.
1520 \end{docKey}
1521
1522 \begin{docKey}{print-body}
1523 {}
1524 {initially unset}
1525 Instead of listing the theorem headings, the theorems are restated with their body text.
1526 Not very useful without the \refKey{store-all} load-time option.
1527 \end{docKey}
1528
1529 \begin{docKey}[][doc label=listof/seq]{seq}
1530 {=\meta{name}}
1531 {initially unset}
1532 Used to list only the theorems added to the custom sequence \meta{name} with the \refKey{thmuse/seq} theorem key.
1533 This is the only way to fully customize which theorems appear in the list of theorems.
1534 Unlike with \refKey{show}, you do not need to use \refKey{ignoreall} to prevent theorems not in \meta{name} from being printed.
1535 \end{docKey}
1536
1537 \begin{docKey}{title-code}
1538 {=\meta{code with \textup{\texttt{\#1}}}}
1539 {initially \cs{section*}\ttbraces{\#1}}
1540 If \cs{chapter} is defined, then initially this is instead \cs{chapter*}\ttbraces{\#1}.
1541 This key has no effect if used with an AMS class because these classes hard-code the section heading into \cs{@starttoc}.
1542 \end{docKey}
1543
1544 \subsection{Adding code to list of theorems}
1545
1546 \begin{docCommand}{addtheoremcontentsline}
1547 {\marg{level}\marg{text}}
1548 This command is analogous to \cs{addcontentsline} and has the same usage, that is, manually adding entries to the list of theorems.
1549 \end{docCommand}
1550
1551 \begin{docCommand}{addtotheoremcontents}
1552 {\marg{code}}
1553 This command is analogous to \cs{addtocontents} and has the same usage, that is, manually adding arbitrary code to the list of theorems.
1554 \end{docCommand}
1555
1556 \begin{notebox}
1557 You \emph{must} use these commands rather than the analogous ones mentioned because the |.thlist| file is also used to define restated theorems and cannot contain unexpected code.
1558 \end{notebox}
1559
1560 \section{Theorem hooks} \label{keythms-hooks}
1561
1562 \begin{docCommand}{addtotheoremhook}
1563 {\oarg{env name}\marg{hook name}\marg{code}}
1564 The \meta{hook name} can be \hook{prehead}, \hook{posthead}, \hook{prefoot}, \hook{postfoot}, or \hook{restated}.
1565 If no \meta{env name} is given, the \meta{code} is added to the ``generic'' hook, i.e., applied to all theorems.
1566 As in \pkg{thmtools}, the order of hooks is as follows:
1567
1568 \begin{center}
1569 \small
1570 \tcbset{
1571 nobeforeafter,
1572 tikznode,
1573 tcbox width=forced center,
1574 width=1.85cm,
1575 tcbox raise=-0.4cm,
1576 size=fbox,
1577 after=\;\textrightarrow,
1578 }
1579 \tcbox{\meta{env name}\\ \hook{prehead}}
1580 \tcbox{generic\\ \hook{prehead}}
1581 \tcbox[width=3.25cm,tcbox raise=-0.2cm]{\cs{begin}\brackets{\meta{env name}}}
1582 \tcbox{\meta{env name}\\ \hook{posthead}}
1583 \tcbox[after={}]{generic\\ \hook{posthead}}
1584 \\[2ex]
1585 \tcbset{before=\textrightarrow\;}
1586 \tcbox[width=2.25cm,tcbox raise=-0.2cm]{\meta{theorem body}}
1587 \\[2ex]
1588 \tcbset{after={}}
1589 \tcbox[before={}]{generic\\ \hook{prefoot}}
1590 \tcbox{\meta{env name}\\ \hook{prefoot}}
1591 \tcbox[width=3.25cm,tcbox raise=-0.2cm]{\cs{end}\brackets{\meta{env name}}}
1592 \tcbox{generic\\ \hook{postfoot}}
1593 \tcbox{\meta{env name}\\ \hook{postfoot}}
1594 \end{center}
1595 The \hook{restated} hook is applied at the start of theorems retrieved with the command \cs{getkeytheorem}, after the \hook{prehead} hook.
1596 This can be useful for disabling commands such as \cs{footnote} in the restated theorems, e.g.,
1597 \begin{dispListing}
1598 \addtotheoremhook{restated}{\renewcommand\footnote[2][]{}}
1599 \end{dispListing}
1600
1601 By default, the \hook{restated} hook disables the \cs{glossary}, \cs{index}, \cs{label}, and \cs{RecordProperties} commands.
1602
1603 In \pkg{thmtools}, the \hook{prefoot} and \hook{postfoot} hooks always prepend code, i.e., the code
1604 \begin{dispListing}
1605 \addtotheorempostfoothook{A}
1606 \addtotheorempostfoothook{B}
1607 \end{dispListing}
1608 results in |BA| after the theorem.
1609 With \pkg{keytheorems}, code is added in the order declared, meaning
1610 \begin{dispListing}
1611 \addtotheoremhook{postfoot}{A}
1612 \addtotheoremhook{postfoot}{B}
1613 \end{dispListing}
1614 results in |AB| after the theorem.
1615 This is the behavior of the \LaTeX{} kernel hooks that \pkg{keytheorems} uses under the hood.
1616
1617 Code added using the hook keys \refKey{preheadhook}, etc.\@ is outermost, meaning executed first in \hook{prehead} and \hook{posthead} and last in \hook{prefoot} and \hook{postfoot}.
1618 Furthermore, if present, the \refKey{qed} symbol is placed \emph{before} the \hook{prefoot} hook.
1619 \end{docCommand}
1620
1621 \section{Miscellaneous notes}
1622
1623 \subsection{\cls{beamer} support}
1624 \label{subsec:beamer}
1625
1626 The package contains some \emph{highly experimental} code to support theorems with \cls{beamer}, including overlays.
1627 The support differs based on whether or not the \cls{beamer} class option |noamsthm| is used.
1628
1629 User feedback is necessary to make this code fully compatible.
1630 Please report issues on the \href{https://github.com/mbertucci47/keytheorems/issues}{Github page}!
1631
1632 \subsubsection{Without \texttt{noamsthm}}
1633 Most style keys are disabled by the |default| \cls{beamer} theorem template.
1634 More become functional by setting
1635 \begin{dispListing}
1636 \setbeamertemplate{theorems}[ams style]
1637 \end{dispListing}
1638 in the preamble.
1639 For full control of theorems, load the class option |noamsthm| and see \zcref{subsubsec:noamsthm}.
1640
1641 Note that by default \cls{beamer} defines a set of theorems when the class is loaded.
1642 These can be overwritten with \refCom{renewkeytheorem} or disabled entirely with the |notheorems| class option.
1643
1644 Due to complications with overlays, writing contents of theorems to the |thlist| file is disabled.
1645 This means theorems can only be restated \emph{after} their original statement.
1646 Furthermore, \refCom{listofkeytheorems} is disabled and a warning issued if used.
1647
1648 \subsubsection{With \texttt{noamsthm}}
1649 \label{subsubsec:noamsthm}
1650
1651 If |noamsthm| is loaded, you can use keytheorems exactly as you would in any other document except that \refCom{listofkeytheorems} is disabled.
1652 This includes no limitations on storing and restating theorems that exist without |noamsthm|.
1653
1654 With or without |noamsthm|, overlays are supported with syntax
1655 \begin{tcolorbox}[blankest]
1656 \cs{begin}\braces{\meta{theorem name}}\colOpt{\pbarg{overlay spec}}\colOpt{\oarg{options}} \\
1657 \hspace*{2ex}\meta{contents} \\
1658 \cs{end}\braces{\meta{theorem name}}
1659 \end{tcolorbox}
1660
1661 \subsection{Support for other classes}
1662 \label{class-support}
1663
1664 As mentioned in \autoref{thmstyles}, the initial style key values set by \pkg{keytheorems} are adjusted for the AMS classes \cls{amsart}, \cls{amsbook}, and \cls{amsproc}, the \cls{amsart}-based \cls{acmart} and \cls{aomart}, and \cls{jlreq}.
1665 You can find the exact changed values in the support files \texttt{keythms-\meta{class}-support.tex}.
1666
1667 These class support files also contain code to adapt to class' formatting of lists-of as mentioned in \autoref{listingthms}; changes are made for the AMS classes, \cls{memoir}, \cls{IEEEtran}, and \cls{jlreq}.
1668
1669 Lastly, in addition to the \cls{beamer} support outlined in \zcref{subsec:beamer}, support is provided for overlays in the experimental tagging-compatible presentation class \cls{ltx-talk}.
1670 See \zcref{subsec:tagging} for more details.
1671
1672 \subsection{Support for font packages}
1673
1674 Some font packages, all by Michael Sharpe, offer a |theoremfont| option that redefines the |plain| style body font to have italic text with upright figures, punctuation, and delimiters.
1675 \pkg{keytheorems} detects this option and sets its initial style values accordingly.
1676 The supported packages are \pkg{baskervillef}, \pkg{cochineal}, \pkg{libertinust1math}, \pkg{newpxtext}, \pkg{newtxtext}, \pkg{scholax}, \pkg{stickstootext}, and \pkg{XCharter}.
1677
1678 \subsection{Support for tagged PDF}
1679 \label{subsec:tagging}
1680
1681 \sloppy
1682 The \LaTeX{} team has been working hard to support the creation of tagged PDFs (see \url{https://latex3.github.io/tagging-project/}).
1683 In the current format, \pkg{amsthm} is compatible with the kernel tagging code.
1684 Most of \pkg{keytheorems} is supported too, and anything that doesn't work should be reported.
1685 Explicitly not supported are the \refKey{tcolorbox} and \refKey{tcolorbox-no-titlebar} keys.
1686
1687 \fussy
1688 To produce a tagged PDF, add \cs{DocumentMetadata} in the first line of your document (additional instructions are found on the Tagging Project \href{https://latex3.github.io/tagging-project/documentation/usage-instructions}{website}).
1689 An example invocation might look like
1690
1691 \begin{dispListing}
1692 \DocumentMetadata
1693 {
1694 lang=en-US,
1695 pdfversion=2.0,
1696 pdfstandard=ua-2,
1697 tagging=on,
1698 % tagging-setup={math/setup=mathml-SE}, % optional
1699 }
1700 \end{dispListing}
1701
1702 As mentioned above, support is also provided for the tagging-compatible \cls{ltx-talk} presentation class.
1703 You may use \pkg{keytheorems} exactly as you would in a normal tagged document, with the added support of overlays.
1704 The syntax for overlays is the same as for \cls{beamer}, shown in \zcref{subsubsec:noamsthm}.
1705 Also as for \cls{beamer}, the \refCom{listofkeytheorems} command is disabled.
1706
1707 \subsection{\pkg{subfiles} compatibility}
1708
1709 \sloppy
1710 Because of how the \pkg{subfiles} package works, it is not possible to restate theorems from one subfile in another without an extra step.
1711 The issue boils down to the same reason the \pkg{xr} package is needed for labels and references to work between subfiles.
1712 Thankfully, the fix is fairly easy with \refCom{externaltheorems}.
1713 Just add \cs{externaltheorems}\bracks{\meta{prefix}}\marg{main file name} to the preamble of your main file.
1714 Then, after compiling your main file at least once, theorems can be restated in subfiles with \cs{getkeytheorem}\braces{\meta{prefix}\meta{tag}}.
1715
1716 \fussy
1717 Here is a complete example.
1718 \begin{dispListing*}{breakable}
1719 % mainfile.tex
1720 \documentclass{article}
1721 \usepackage{keytheorems}
1722 \usepackage{subfiles}
1723
1724 \externaltheorems[main:]{mainfile}
1725 \newkeytheorem{theorem}
1726
1727 \begin{document}
1728 \subfile{subfile1.tex}
1729 \subfile{subfile2.tex}
1730 \end{document}
1731
1732 % subfile1.tex
1733 \documentclass[mainfile.tex]{subfiles}
1734 \begin{document}
1735 \section{subfile1}
1736 \begin{theorem}
1737 Some theorem from the first subfile.
1738 \end{theorem}
1739 \getkeytheorem{main:secondthm}
1740 \end{document}
1741
1742 % subfile2.tex
1743 \documentclass[mainfile.tex]{subfiles}
1744 \begin{document}
1745 \section{subfile2}
1746 \begin{theorem}[store=secondthm]
1747 Some theorem from the second subfile.
1748 \end{theorem}
1749 \end{document}
1750 \end{dispListing*}
1751
1752 \subsection{Public coding interfaces}
1753
1754 \begin{docCommand}{l_keythms_thmuse_envname_tl}{}
1755 Inside theorem environments and in all theorem hooks, you have access to the theorem's environment and counter name in this token list variable.
1756 \end{docCommand}
1757
1758 \begin{docCommands}
1759 {
1760 {
1761 doc name=keythms_getthm_theorem:nnnnn,
1762 doc parameter={%
1763 \ \marg{name} \marg{number} \marg{restate counters}\\
1764 \hspace*{1cm}%
1765 \marg{keys} \marg{body text}%
1766 },
1767 },
1768 {
1769 doc name=keythms_getthm_body:nnn,
1770 doc parameter=\ \marg{name} \marg{restate counters} \marg{body text},
1771 },
1772 }
1773 These are the commands called by \refCom{getkeytheorem} when restating stored theorems. They can be useful for customizing the behavior of the list of theorems with a printed body; see \refCom{keythms_listof_listcmd:nnnnnnn}.
1774 \end{docCommands}
1775
1776 \begin{docCommand}{keythms_listof_listcmd:nnnnnnn}
1777 {%
1778 \ \marg{name} \marg{number} \marg{Href} \marg{page}\\
1779 \hspace*{1cm}%
1780 \marg{restate counters} \marg{keys} \marg{body text}%
1781 }
1782 This is the command that controls how theorems are printed in the list of theorems. See \url{https://tex.stackexchange.com/a/747257/208544} for a concrete use-case in tandem with \refCom{keythms_getthm_theorem:nnnnn}.
1783 \end{docCommand}
1784
1785 \begin{docKeys}[doc no index,color key=black]
1786 {
1787 {
1788 doc name=keytheorems/allthms/\textmd{\meta{hook name}},
1789 doc label=allthms-hook,
1790 },
1791 {
1792 doc name=keytheorems/\textmd{\meta{envname}}/\textmd{\meta{hook name}},
1793 doc label=envname-hook,
1794 }
1795 }
1796 These are the ``real'' names for the hooks described in \autoref{keythms-hooks}.
1797 They can be useful with \cs{AddToHookNext} or the kernel's label mechanism for hooks.
1798 \end{docKeys}
1799
1800 \section{Further examples}
1801
1802 \sloppy
1803 More examples will be added soon -- rather, eventually\dots{}
1804 For now, you can find a \pkg{keytheorems} adaptation of \pkg{amsthm}'s classic \href{https://mirrors.ctan.org/macros/latex/required/amscls/doc/thmtest.tex}{\texttt{thmtest.tex}} in the Github \texttt{tests} folder: \href{https://github.com/mbertucci47/keytheorems/blob/develop/tests/keytheorems-amsthmtest.tex}{\texttt{keytheorems-amsthmtest.tex}}.
1805 There is also a version for tagged PDF: \href{https://github.com/mbertucci47/keytheorems/blob/develop/tests/tagged-keytheorems-amsthmtest.tex}{\texttt{tagged-keytheorems-amsthmtest.tex}}.
1806
1807 \fussy
1808 %\section{Implementation}
1809 %\inputminted[linenos,style=bw]{latex}{../keytheorems.sty}
1810
1811 \printindex
1812
1813 \end{document}