summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/thmtools/thm-ntheorem.dtx
blob: ccd12dc30d866f1549c4c433364e1b00f4e567dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
% \iffalse meta-comment
%
% Copyright (C) 2010 by Ulrich M. Schwarz
% See file COPYING for more details.
%\fi
%
%\iffalse (hide this from DocInput)
%<*ntheorem>
%\fi
%    \begin{macrocode}

\providecommand\thmt@space{ }

% actually, ntheorem's so-called style is nothing like a style at all...
\def\thmt@declaretheoremstyle@setup{}
\def\thmt@declaretheoremstyle#1{%
  \ifcsname th@#1\endcsname\else
    \@xa\let\csname th@#1\endcsname\th@plain
  \fi
}

\def\thmt@notsupported#1#2{%
  \PackageWarning{thmtools}{Key `#2' not supported by #1}{}%
}

\define@key{thmstyle}{spaceabove}{%
  \setlength\theorempreskipamount{#1}%
}
\define@key{thmstyle}{spacebelow}{%
  \setlength\theorempostskipamount{#1}%
}
\define@key{thmstyle}{headfont}{%
  \theoremheaderfont{#1}%
}
\define@key{thmstyle}{bodyfont}{%
  \theorembodyfont{#1}%
}
% not supported in ntheorem.
\define@key{thmstyle}{notefont}{%
  \thmt@notsupported{ntheorem}{notefont}%
}
\define@key{thmstyle}{headpunct}{%
  \theoremseparator{#1}%
}
% not supported in ntheorem.
\define@key{thmstyle}{notebraces}{%
  \thmt@notsupported{ntheorem}{notebraces}%
}
\define@key{thmstyle}{break}{%
  \theoremstyle{break}%
}
% not supported in ntheorem...
\define@key{thmstyle}{postheadspace}{%
  %\def\thmt@style@postheadspace{#1}%
  \@xa\g@addto@macro\csname thmt@style \thmt@style @defaultkeys\endcsname{%
      postheadhook={\hspace{-\labelsep}\hspace*{#1}},%
  }%
}

% not supported in ntheorem
\define@key{thmstyle}{headindent}{%
  \thmt@notsupported{ntheorem}{headindent}%
}
% sorry, only style, not def with ntheorem.
\define@key{thmstyle}{qed}[\qedsymbol]{%
  \@ifpackagewith{ntheorem}{thmmarks}{%
    \theoremsymbol{#1}%
  }{%
    \thmt@notsupported
      {ntheorem without thmmarks option}%
      {headindent}%
  }%
}

\let\@upn=\textup
\define@key{thmstyle}{headformat}[]{%
  \def\thmt@tmp{#1}%
  \@onelevel@sanitize\thmt@tmp
  %\tracingall
  \ifcsname thmt@headstyle@\thmt@tmp\endcsname
    \newtheoremstyle{\thmt@style}{%
      \item[\hskip\labelsep\theorem@headerfont%
        \def\NAME{\theorem@headerfont ####1}%
        \def\NUMBER{\bgroup\@upn{####2}\egroup}%
        \def\NOTE{}%
        \csname thmt@headstyle@#1\endcsname
        \theorem@separator
      ]
    }{%
      \item[\hskip\labelsep\theorem@headerfont%
        \def\NAME{\theorem@headerfont ####1}%
        \def\NUMBER{\bgroup\@upn{####2}\egroup}%
        \def\NOTE{\if=####3=\else\bgroup\thmt@space(####3)\egroup\fi}%
        \csname thmt@headstyle@#1\endcsname
        \theorem@separator
      ]
    }
  \else
    \newtheoremstyle{\thmt@style}{%
      \item[\hskip\labelsep\theorem@headerfont%
        \def\NAME{\the\thm@headfont ####1}%
        \def\NUMBER{\bgroup\@upn{####2}\egroup}%
        \def\NOTE{}%
        #1%
        \theorem@separator
      ]
    }{%
      \item[\hskip\labelsep\theorem@headerfont%
        \def\NAME{\the\thm@headfont ####1}%
        \def\NUMBER{\bgroup\@upn{####2}\egroup}%
        \def\NOTE{\if=####3=\else\bgroup\thmt@space(####3)\egroup\fi}%
        #1%
        \theorem@separator
      ]
    }
  \fi
}

\def\thmt@headstyle@margin{%
  \makebox[0pt][r]{\NUMBER\ }\NAME\NOTE
}
\def\thmt@headstyle@swapnumber{%
  \NUMBER\ \NAME\NOTE
}



%    \end{macrocode}
%\iffalse (hide this from DocInput)
%</ntheorem>
%\fi