-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmytheorem.sty
169 lines (154 loc) · 5.72 KB
/
mytheorem.sty
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
%
% This package allows for flexibly positioning theorem proofs
% either in the text or in a separate proof section in the appendix.
%
% Written by Christoph Redl (TU Vienna), February 20 2015
%
% Dependencies
\RequirePackage{ifthen}
\RequirePackage{amsthm}
% Parameters
\newif\ifdefaultproofinline\defaultproofinlinetrue
\DeclareOption{outsourcebydefault}{\defaultproofinlinefalse}
\ProcessOptions\relax
% Proof section
\newcommand{\proofs}{} % outsourced proofs
\newcommand{\ifHaveProofs}[1]{}
\newcommand{\appendToProofs}[1]{
\renewcommand{\ifHaveProofs}[1]{##1}
\expandafter\def\expandafter\proofs\expandafter{\proofs { }
#1
\medskip
}
}
% Theorem styles
\newcommand{\newMyTheoremStyle}[9]{
\newtheoremstyle{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}{#9}
\expandafter\newcommand\csname mytheorem@abovespace@#1\endcsname{#2}
\expandafter\newcommand\csname mytheorem@belowspace@#1\endcsname{#3}
\expandafter\newcommand\csname mytheorem@bodyfont@#1\endcsname{#4}
\expandafter\newcommand\csname mytheorem@indent@#1\endcsname{#5}
\expandafter\newcommand\csname mytheorem@headfont@#1\endcsname{#6}
\expandafter\newcommand\csname mytheorem@headpunct@#1\endcsname{#7}
\expandafter\newcommand\csname mytheorem@headspace@#1\endcsname{#8}
\expandafter\newcommand\csname mytheorem@customheadspec@#1\endcsname{#9}
}
\newcommand{\mytheorem@abovespace}{\topsep}
\newcommand{\mytheorem@belowspace}{\topsep}
\newcommand{\mytheorem@bodyfont}{\itshape}
\newcommand{\mytheorem@indent}{0pt}
\newcommand{\mytheorem@headfont}{\bfseries}
\newcommand{\mytheorem@headpunct}{.}
\newcommand{\mytheorem@headspace}{}
\newcommand{\mytheorem@customheadspec}{}
\newcommand{\myTheoremStyle}[1]{
\theoremstyle{#1}
\renewcommand{\mytheorem@abovespace}{\expandafter\csname mytheorem@abovespace@#1\endcsname}
\renewcommand{\mytheorem@belowspace}{\expandafter\csname mytheorem@belowspace@#1\endcsname}
\renewcommand{\mytheorem@bodyfont}{\expandafter\csname mytheorem@bodyfont@#1\endcsname}
\renewcommand{\mytheorem@indent}{\expandafter\csname mytheorem@indent@#1\endcsname}
\renewcommand{\mytheorem@headfont}{\expandafter\csname mytheorem@headfont@#1\endcsname}
\renewcommand{\mytheorem@headpunct}{\expandafter\csname mytheorem@headpunct@#1\endcsname}
\renewcommand{\mytheorem@headspace}{\expandafter\csname mytheorem@headspace@#1\endcsname}
\renewcommand{\mytheorem@customheadspec}{\expandafter\csname mytheorem@customheadspec@#1\endcsname}
}
% References to the proof section
\newcommand{\proofsecref}{Appendix~\ref{sec:proofs}}
% Meta newcommands for defining theorem commands for arbitrary types of theorems
\newcommand{\newMyTheoremOutsourced}[3]{
\newcommand{#1}[3][\empty]{
% state theorem
\ifthenelse{\equal{##1}{\empty}}
{\begin{#2} \label{##2} ##3 \end{#2}}
{\begin{#2}[##1] \label{##2} ##3 \end{#2}}
% restate theorem in the proof section
\expandafter\def\expandafter\proofs\expandafter{\proofs { }
\ifthenelse{\equal{##1}{\empty}}
{\noindent\hspace{\mytheorem@indent}{\mytheorem@headfont{}#3~\ref{##2}.}\mytheorem@headspace{}{\mytheorem@bodyfont{} ##3}}
{\noindent\hspace{\mytheorem@indent}{\mytheorem@headfont{}#3~\ref{##2}} (##1){\mytheorem@headfont{}\mytheorem@headpunct{}}\mytheorem@headspace{}{\mytheorem@bodyfont{} ##3}}
}
}
}
\newcommand{\newMyTheoremOutsourcedOnly}[3]{
\newcommand{#1}[3][\empty]{
% restate the theorem only in the proof section
\expandafter\def\expandafter\proofs\expandafter{\proofs { }
\ifthenelse{\equal{##1}{\empty}}
{\begin{#2} \label{##2} ##3 \end{#2}}
{\begin{#2}[##1] \label{##2} ##3 \end{#2}}
}
}
}
\newcommand{\newMyTheoremInline}[3]{
\newcommand{#1}[3][\empty]{
% state theorem
\ifthenelse{\equal{##1}{\empty}}
{\begin{#2} \label{##2} ##3 \end{#2}}
{\begin{#2}[##1] \label{##2} ##3 \end{#2}}
}
}
% redirection of \newMyTheorem depending on the default position of theorems
\ifdefaultproofinline
\newcommand{\newMyTheorem}{\newMyTheoremInline}
\else
\newcommand{\newMyTheorem}{\newMyTheoremOutsourced}
\fi
% Meta newcommands for defining proof commands for arbitrary types of theorems
\newcommand{\addProofOutsourced}[2]{
\renewcommand{\ifHaveProofs}[1]{##1}
\expandafter\def\expandafter\proofs\expandafter{\proofs { }
\begin{proof}
\label{prf:#1}
#2
\end{proof}
}
\ifdefaultproofinline
\begin{proof}
\renewcommand{\qedsymbol}{}
See \proofsecref, page~\pageref{prf:#1}.
\end{proof}
\fi
}
\newcommand{\addProofOutsourcedOnly}[2]{
\renewcommand{\ifHaveProofs}[1]{##1}
\expandafter\def\expandafter\proofs\expandafter{\proofs { }
\begin{proof}
\label{prf:#1}
#2
\end{proof}
}
}
\newcommand{\addProofInline}[2]{
\begin{proof}
\label{prf:#1}
#2
\end{proof}
}
% redirection of \addProof depending on the default position of theorems
\ifdefaultproofinline
\newcommand{\addProof}[2]{
\begin{proof}
\label{prf:#1}
#2
\end{proof}
}
\else
\newcommand{\addProof}[2]{
\renewcommand{\ifHaveProofs}[1]{##1}
\expandafter\def\expandafter\proofs\expandafter{\proofs { }
\begin{proof}
\label{prf:#1}
#2
\end{proof}
}
}
\fi
% Facade command, which allow for defining several other commands for each theorem type using the above commands.
% \newMyTheoremType{lemma}{Lemma} is used to declare a new theorem environment of amsthm type "lemma" and caption "Lemma"
\newcommand{\newMyTheoremType}[2]{
\newtheorem{#1}{#2}
\expandafter\newMyTheoremOutsourced\csname add#2Outsourced\endcsname{#1}{#2}
\expandafter\newMyTheoremOutsourcedOnly\csname add#2OutsourcedOnly\endcsname{#1}{#2}
\expandafter\newMyTheoremInline\csname add#2Inline\endcsname{#1}{#2}
\expandafter\newMyTheorem\csname add#2\endcsname{#1}{#2}
}