%% %% This is file `templatetools.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% templatetools.dtx (with options: `templatetools.sty') %% %% IMPORTANT NOTICE: %% %% For the copyright see the source file. %% %% Any modified versions of this file must be renamed %% with new filenames distinct from templatetools.sty. %% %% For distribution of the original source see the terms %% for copying and modification in the file templatetools.dtx. %% %% This generated file may be distributed as long as the %% original source files, as listed above, are part of the %% same distribution. (The sources need not necessarily be %% in the same archive or directory.) \NeedsTeXFormat{LaTeX2e}[1994/12/01] \ProvidesPackage{templatetools} [2023/03/26 v0.2 Collection of conditional commands useful inside templates] %%% --- Necessary Packages %%% ------------------------------------------------------------------ \RequirePackage{iftex} \RequirePackage{etoolbox} \RequirePackage{ltxcmds} \RequirePackage{array} % for column types \RequirePackage{ifdraft} % check draft \RequirePackage{scrlfile} %%% --- Check if command is defined %%% ------------------------------------------------------------------ \newcommand{\IfDefined}[2]{\ifcsdef{#1}{#2}{}}% \newcommand{\IfUndefined}[2]{\ifcsdef{#1}{}{#2}}% \newcommand{\IfElseDefined}[3]{\ifcsdef{#1}{#2}{#3}}% \newcommand{\IfElseUndefined}[3]{\ifcsdef{#1}{#3}{#2}}% \newcommand{\IfMultDefined}[1]{% \@tempswatrue \def\do##1{% %% define \@tempa with trimmed index element. \edef\@tempa{\zap@space##1 \@empty}% %% check if package of current index is loaded \ifcsdef{\@tempa}{}{\@tempswafalse}% }% %% Process csv list with command \do (etoolbox) \docsvlist{#1}% %% makes sure that the conditional works with one or two (if, else) parameters. \if@tempswa\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi% } \newcommand{\IfDraft}[1]{\ifx\@draft\@undefined \else #1 \fi} \newcommand{\IfNotDraft}[1]{\ifx\@draft\@undefined #1 \fi} \newcommand{\IfNotDraftElse}[2]{\ifx\@draft\@undefined #1 \else #2 \fi} \newcommand{\IfPackageLoaded}[2]{\ltx@ifpackageloaded{#1}{#2}{}} \newcommand{\IfPackageNotLoaded}[2]{\ltx@ifpackageloaded{#1}{}{#2}} \let\IfElsePackageLoaded\ltx@ifpackageloaded \newcommand{\IfPackagesLoaded}[1]{% \@tempswatrue \def\do##1{% \edef\@tempa{\zap@space##1 \@empty}% \ltx@ifpackageloaded{\@tempa}{}{\@tempswafalse}% }% \docsvlist{#1}% \if@tempswa\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi% } \newcommand{\IfPackagesNotLoaded}[1]{% \@tempswatrue \def\do##1{% \edef\@tempa{\zap@space##1 \@empty}% \ltx@ifpackageloaded{\@tempa}{\@tempswafalse}{}% }% \docsvlist{#1}% \if@tempswa\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi% } \newcommand{\ExecuteAfterPackage}[2]{% %% #1: after this package %% #2: code to execute \AfterAtEndOfPackage{#1}{ #2% } \AtEndPreamble{% \IfPackageNotLoaded{#1}{% #2% } } } \newcommand{\ExecuteBeforePackage}[2]{% %% #1: before this package %% #2: code to execute \BeforePackage{#1}{ #2% } \AtEndPreamble{% \IfPackageNotLoaded{#1}{% #2% } } } \def\IfTikzLibraryLoaded#1{% \ifcsname tikz@library@#1@loaded\endcsname \expandafter\@firstoftwo \else \expandafter\@secondoftwo \fi } \expandafter\let\csname columntype@l\endcsname\@empty \expandafter\let\csname columntype@c\endcsname\@empty \expandafter\let\csname columntype@r\endcsname\@empty \expandafter\let\csname columntype@p\endcsname\@empty \expandafter\let\csname columntype@m\endcsname\@empty \expandafter\let\csname columntype@b\endcsname\@empty \expandafter\let\csname columntype@@\endcsname\@empty \expandafter\let\csname columntype@!\endcsname\@empty \expandafter\let\csname columntype@|\endcsname\@empty \expandafter\let\csname columntype@<\endcsname\@empty \expandafter\let\csname columntype@>\endcsname\@empty \expandafter\let\csname columntype@=\endcsname\@empty \newcommand\CheckIfColumntypeDefined[1]{% %% create the bool variable for column type \providebool{tpl@coltype@#1} %% check if new column type of this name was created \ifcsdef{NC@find@\string#1}% {\setbool{tpl@coltype@#1}{true}}% %% if not check if it is a predefined column type {\ifcsdef{columntype@\string#1} {\setbool{tpl@coltype@#1}{true}}% {\setbool{tpl@coltype@#1}{false}}% }% } \newcommand\isColumntypeDefined[1]{tpl@coltype@#1} \newcommand\IfColumntypeDefined[3]{% %% Execute check which create bool variable \CheckIfColumntypeDefined{#1} %% use bool variable for if sequence \ifboolexpr{ bool{\isColumntypeDefined{#1}} }{#2}{#3}% } \newcommand{\IfColumntypesDefined}[1]{% \@tempswatrue \def\do##1{% \edef\@tempa{\zap@space##1 \@empty}% %% check if column is defined. %% Here with \expandafter because of the \string definition %% in \CheckIfColumntypeDefined. \expandafter\IfColumntypeDefined \expandafter{\@tempa}{}{\@tempswafalse} }% \docsvlist{#1}% \if@tempswa\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi% } \newcommand{\IfColorDefined}[3]{% \ifcsdef{\string\color @#1} {#2} % color string is defined {#3}} % color string is not defined \newcommand{\IfColorsDefined}[1]{% \@tempswatrue \def\do##1{% \edef\@tempa{\zap@space##1 \@empty}% \expandafter\IfColorDefined \expandafter{\@tempa}{}{\@tempswafalse} }% \docsvlist{#1}% \if@tempswa\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi% } \newcommand{\IfMathVersionDefined}[3]{\ifcsdef{mv@#1}{#2}{#3}} \newcommand{\IfGlossariesStyleDefined}[2]{\ifcsdef{@glsstyle@#1}{#2}{}} \newcommand{\IfBibEnvironmentDefined}[1]{\ifcsdef{blx@env@#1}} \newcommand\SetTemplateDefinition[3]{% 1: group, 2: property, 3: code \csdef{tpl@definition@#1@#2}{#3} } \newcommand\UseDefinition[2]{% \ifcsdef{tpl@definition@#1@#2} {\csuse{tpl@definition@#1@#2}} {\PackageWarning{templatetools}% {Definition #1->#2 is unknown\MessageBreak}{}}% }% \endinput %% %% End of file `templatetools.sty'.