% !TeX program = txs:///lualatex | txs:///makeindex | txs:///lualatex | txs:///view-pdf \PassOptionsToPackage{hyperindex}{hyperref} \PassOptionsToPackage{dvipsnames}{xcolor} \documentclass{ltxdoc} \usepackage{geometry} \geometry{margin=1.5in} \usepackage{tcolorbox} \PassOptionsToPackage{cachedir=keythms-doc-minted}{minted} \tcbuselibrary{documentation,minted,breakable,hooks} \ifTUTeX \usepackage{newcomputermodern} \else \usepackage{lmodern} \usepackage[T1]{fontenc} \usepackage{amssymb} \fi \usetikzlibrary{cd} \usepackage{fontawesome5} \usepackage{booktabs} \usepackage{keytheorems} \usepackage{zref-clever} \zcsetup{nameinlink=false} \makeatletter \newcommand\keythmsversion{\@keythms@version} \makeatother \title{% \pkg{keytheorems} package \\[1ex] \large version \keythmsversion \\[1ex] \href{https://github.com/mbertucci47/keytheorems} {\texttt{github.com/mbertucci47/keytheorems}} } \author{Matthew Bertucci} \newkeytheoremstyle{breaksty}{break} \newkeytheorem{theorem} \newkeytheorem{mythm}[name=Some Name] \newkeytheorem{theorem*}[name=Theorem,numbered=false] \newkeytheorem{conjecture}[parent=section] \newkeytheorem{lemma}[sibling=theorem] \newkeytheorem{test}[ preheadhook=PREHEAD, postheadhook=POSTHEAD, prefoothook=PREFOOT, postfoothook=POSTFOOT ] \newkeytheorem{prop}[ name=Proposition, refname={proposition,propositions}, Refname={Proposition,Propositions} ] \newkeytheorem{example}[qed] \newkeytheorem{solution}[qed=$\clubsuit$] \newkeytheorem{remark}[style=remark] \tcbset{ defstyle/.style={arc=0mm,colback=blue!5!white,colframe=blue!75!black}, thmstyle/.style={colback=green!5,colframe=green!35!black}, } \newkeytheoremstyle{tcb-standard}{ tcolorbox=thmstyle, headpunct={}, notebraces={}{}, noteseparator={: }, notefont=\bfseries, bodyfont=\normalfont, } \newkeytheorem{mytheo}[name=My Theorem,style=tcb-standard] \newkeytheorem{corollary}[tcolorbox] \newkeytheorem{definition}[ style=definition, tcolorbox={defstyle} ] \newkeytheorem{boxcor}[ tcolorbox-no-titlebar={colback=red!10}, name=Corollary, sibling=corollary, ] \newkeytheorem{observation}[style=breaksty] \newkeytheorem{quotethm}[name=Quote Theorem,leftmargin=1cm,rightmargin=1cm] \newkeytheorem{indentedthm}[name=Indented Theorem,leftmargin=1cm] \MakeShortVerb{\|} \newcommand{\env}{\texttt} \newcommand{\hook}{\texttt} \NewCommandCopy{\braces}{\brackets} \newcommand{\bracks}[1]{\texttt{[#1]}} \newcommand{\ttbraces}[1]{\braces{\texttt{#1}}} %\tcbset{index gather commands=false} \usepackage{xcolor-solarized} \colorlet{ExampleBack}{solarized-base3!50} \colorlet{ExampleBackLower}{solarized-base3} \tcbset{ color command=BrickRed, color key=Fuchsia, color value=teal, before doc body={% \setlength{\parindent}{15pt} \noindent }, docexample/.append style={boxrule=0pt,arc=0pt,after app={\noindent}} } \makeatletter % code from muzimuzhi (https://github.com/T-F-S/tcolorbox/issues/298) \tcbset{ before verbatim write app/.code={% \appto\tcb@verbatim@begin@hook{\tcb@iow@write{#1}}}, % provided for symmetry, but not used after verbatim write pre/.code={% \preto\tcb@verbatim@end@hook{\tcb@iow@write{#1}}}, } \tcbset{ mark preamble/.style={ before verbatim write app={\@percentchar\space preamble}, }, mark document/.style={ before verbatim write app={\@percentchar\space document}, }, } \tcbset{ listing engine=minted, minted language=latex, withpreamble/.style = { mark document, before upper = {% % affects both the \tcbsettemplisting and the original upper \setminted{listparameters={\topsep=0pt \partopsep=0pt}}% \tcbusetemplisting \vspace{5pt}% } } } \NewDocumentEnvironment{codepreamble}{}{% \tcbset{mark preamble}% \tcbwritetemp }{% \endtcbwritetemp } \makeatother \NewTCBListing{keythmscode}{ O{} } { colback=ExampleBack, arc=0pt, boxrule=0pt, skin=bicolor, colbacklower=ExampleBackLower, breakable, parbox=false, % so examples match document with indent, etc. minted options app={breaksymbolleft={}}, #1 } \newtcolorbox{notebox}[1][]{enhanced, before skip balanced=2mm,after skip balanced=4mm, boxrule=0.4pt,left=5mm,right=2mm,top=1mm,bottom=1mm, colback=red!20, colframe=red!40!black, sharp corners,rounded corners=southeast,arc is angular,arc=3mm, underlay={% \path[fill=tcbcolback!80!black] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2); \path[draw=tcbcolframe,shorten <=-0.05mm,shorten >=-0.05mm] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2); \path[fill=red!40!black,draw=none] (interior.south west) rectangle node[white]{\LARGE\bfseries !} ([xshift=4mm]interior.north west); }, drop fuzzy shadow,#1} \makeatletter % allow for optional argument specifying printed text, mostly for starred keys \RenewDocumentCommand\tcb@ref@doc{msom}{% \hyperref[{#1:#4}]{% \IfValueTF{#3}{\texttt{#3}}{\texttt{\ref*{#1:#4}}}% \IfBooleanTF{#2}{}{% \ifnum\getpagerefnumber{#1:#4}=\thepage\relax% \else% \kvtcb@doc@format@page{{\fontfamily{pzd}\fontencoding{U}\fontseries{m}\fontshape{n}\selectfont\char213}% \,\kvtcb@text@pageshort\,\pageref*{#1:#4}}% \fi}}% } \makeatother \makeindex \begin{document} \maketitle \begin{abstract} An \pkg{expl3}-implementation of a key-value interface to \pkg{amsthm}, implementing most of the functionality provided by \pkg{thmtools}. Several issues encountered with \pkg{thmtools} are avoided (see the README for a list) and a few new features are added. \end{abstract} \tableofcontents \section{Dependencies} The package depends on the \pkg{aliascnt}, \pkg{amsthm}, \pkg{refcount}, and \pkg{translations} packages. 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. A \LaTeX{} kernel no older than 2023-06-01 is required; if older than 2024-06-01, \pkg{nameref} is required. \section{Global options} \begin{docCommand}{keytheoremset} {\marg{options}} 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. \end{docCommand} \subsection{Compatibility options} \begin{docKey}{overload} {} {initially unset} Redefines \cs{newtheorem} to internally use the \pkg{keytheorems} machinery. The syntax remains the same. This is automatically set by \refKey{thmtools-compat}. \end{docKey} \begin{docKey}{thmtools-compat} {} {initially unset} For compatibility with \pkg{thmtools} syntax. For most documents, \begin{dispListing} \usepackage[thmtools-compat]{keytheorems} \end{dispListing} should be a drop-in replacement for \cs{usepackage}\ttbraces{amsthm,thmtools}. The option defines the commands in the left column below. The right column lists the corresponding \pkg{keytheorems} replacement that should be used in new documents. \begin{center} \begin{tabular}{rcl} \multicolumn{1}{c}{\pkg{thmtools} command} & & \multicolumn{1}{c}{\pkg{keytheorems} replacement} \\ \toprule \docAuxCommand*{declaretheorem} & $\rightarrow$ & \refCom{newkeytheorem} \\ \docAuxCommand*{declaretheoremstyle} & $\rightarrow$ & \refCom{newkeytheoremstyle} \\ \docAuxCommand*{listoftheorems} & $\rightarrow$ & \refCom{listofkeytheorems} \\ \docAuxCommand*{listtheoremname} & $\rightarrow$ & \refKey{title} key \\ \begin{tabular}{r@{}} \docAuxCommand*{addtotheorempreheadhook}\\ \docAuxCommand*{addtotheorempostheadhook}\\ \docAuxCommand*{addtotheoremprefoothook}\\ \docAuxCommand*{addtotheorempostfoothook}\\ \end{tabular} & $\rightarrow$ & \refCom{addtotheoremhook} \\ \docAuxEnvironment*{restatable} environment & $\rightarrow$ & \refKey{store} key \\ \docAuxEnvironment*{restatable*} environment & $\rightarrow$ & \refKey[store*]{store} key \end{tabular} \end{center} 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. \end{docKey} \subsection{Other global options} \begin{docKey}{auto-translate} {\colOpt{=true\textbar false}} {default |true|, initially |true|} If |false|, \pkg{keytheorems} does not automatically translate the title text used for \refCom{listofkeytheorems} and the note produced by the \refKey{continues} key. These texts can be manually customized with the \refKey{title} and \refKey{continues-code} keys, respectively. \end{docKey} \begin{docKey}{continues-code} {=\meta{code with \textup{\texttt{\#1}}}} {initially\\ \cs{GetTranslation}\ttbraces{keythms\string_continues}\cs{pageref}\ttbraces{\#1}} The code used to typeset the note produced by the \refKey{continues} key. If English or an unknown language is used, defaults to \texttt{continuing from p.}\cs{,}\cs{pageref}\ttbraces{\#1}. Currently (likely inaccurate!) translations exist for several European languages. \end{docKey} \begin{docKey}{qed-symbol} {=\meta{symbol}} {initially \cs{openbox}} Redefines \cs{qedsymbol} to be \meta{symbol}. \end{docKey} \begin{docKey}{restate-counters} {=\marg{comma-list of counters}} {initially \ttbraces{equation}} Additional counters whose values are preserved when a theorem is restated. This key does not reset the list, so you don't need to include |equation| in \meta{comma-list}. \end{docKey} \begin{docKey}{store-all} {} {initially unset} 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}. Note that this means a theorem body \emph{cannot} contain verbatim material. \end{docKey} \begin{docKey}{store-sets-label} {} {initially unset} 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}. Similarly for \refKey[store*]{store}. \end{docKey} \section{Defining theorems} \begin{docCommand}{newkeytheorem} {\marg{env name}\oarg{options}} Defines a theorem environment \meta{env name} which itself takes a few options (see \autoref{in-doc-keys}). You can also declare multiple theorems at once by replacing \meta{env name} with a comma-list of names, e.g. \begin{center} \cs{newkeytheorem}\ttbraces{theorem,lemma,proposition}\bracks{\meta{options}}. \end{center} By default, the theorem's printed name is a title-cased \meta{env name}. This can be changed with the \refKey{thm/name} key. All \meta{options} are described in subsections \ref{thm-thmtools-keys} and \ref{thm-added-keys}. \begin{codepreamble} \newkeytheorem{theorem} \end{codepreamble} \begin{keythmscode}[withpreamble] \begin{theorem} There are infinitely many prime numbers. \end{theorem} \end{keythmscode} \end{docCommand} \begin{docCommands}[ doc parameter=\marg{env name}\oarg{options} ] { {doc name = renewkeytheorem}, {doc name = providekeytheorem}, {doc name = declarekeytheorem}, } Sometimes a package or class defines theorems that need to be overwritten by the user. For this case, \pkg{keytheorems} provides \cs{renewkeytheorem} which redefines \meta{env name} or errors if it is not defined. For completeness, also provided are \cs{providekeytheorem} and \cs{declarekeytheorem}. The former only defines \meta{env name} if it is not already defined; the latter always overwrites \meta{env name}. \end{docCommands} \subsection{Keys available to theorem environments} \label{in-doc-keys} As in \pkg{amsthm}, theorems can take an optional argument that contains a note or heading. \begin{keythmscode}[] \begin{theorem}[Bertrand's postulate] For every $n\geq 1$, there is a prime number $p$ with $n