-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Style inheritance in thmtools #15
Labels
enhancement
New feature or request
Comments
Yes I've noticed the question on TeX-SX days before. Not sure if I can add this utility soon. |
@muzimuzhi I think I had linked the wrong post. I've updated it now. |
A very simple attempt with almost no testing: \documentclass{article}
\usepackage{amsthm,thmtools,xcolor}
\makeatletter
\define@key{thmstyle}{style}{%
\thmt@inheritstyle{#1}%
}
\def\thmt@inheritstyle#1{
\ifcsname thmt@style@#1@setdefaultkeys\endcsname%
\csname thmt@style@#1@setdefaultkeys\endcsname%
\else
\PackageError{thmtools}{No style `#1' defined}{}%
\fi
}
\renewcommand\declaretheoremstyle[2][]{%
\def\thmt@style{#2}%
\@xa\def\csname thmt@style \thmt@style @defaultkeys\endcsname{}%
\thmt@declaretheoremstyle@setup
\kvsetkeys{thmstyle}{#1}%
\thmt@declaretheoremstyle{#2}%
\@xa\def\csname thmt@style@\thmt@style @setdefaultkeys\endcsname{% ADDED
\kvsetkeys{thmstyle}{#1}% ADDED
}% ADDED
}
\def\thmt@style@plain@setdefaultkeys{}
\def\thmt@style@definition@setdefaultkeys{%
\kvsetkeys{thmstyle}{%
bodyfont=\normalfont
}%
}
\def\thmt@style@remark@setdefaultkeys{%
\kvsetkeys{thmstyle}{%
spaceabove=0.5\topsep,
spacebelow=0.5\topsep,
headfont=\itshape,
bodyfont=\normalfont
}%
}
\makeatother
\declaretheoremstyle[
headfont=\bfseries\color{blue},
bodyfont=\itshape\color{red},
headformat = \NUMBER\ \NOTE\ \NAME
]{thmsty}
\declaretheoremstyle[
style=thmsty,
notebraces={[}{]},
bodyfont=\upshape\color{purple}
]{lemsty}
\declaretheorem[style=thmsty]{theorem}
\declaretheorem[style=lemsty]{lemma}
\begin{document}
\begin{theorem}[heading]
Text
\end{theorem}
\begin{lemma}[heading]
Text
\end{lemma}
\end{document} Might be better to give it a name like |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Relevant tex.stackexchange post: https://tex.stackexchange.com/q/565165/172923.
The text was updated successfully, but these errors were encountered: