Skip to content
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

Open
noib3 opened this issue Oct 4, 2020 · 3 comments
Open

Style inheritance in thmtools #15

noib3 opened this issue Oct 4, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@noib3
Copy link

noib3 commented Oct 4, 2020

Relevant tex.stackexchange post: https://tex.stackexchange.com/q/565165/172923.

@muzimuzhi
Copy link
Owner

Yes I've noticed the question on TeX-SX days before. Not sure if I can add this utility soon.

@muzimuzhi muzimuzhi added the enhancement New feature or request label Oct 5, 2020
@noib3
Copy link
Author

noib3 commented Oct 5, 2020

@muzimuzhi I think I had linked the wrong post. I've updated it now.

@mbertucci47
Copy link
Collaborator

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}

splitargs-1

Might be better to give it a name like inherit-style.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants