-
Notifications
You must be signed in to change notification settings - Fork 0
/
restatelinks.sty
132 lines (123 loc) · 4.17 KB
/
restatelinks.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
\ProvidesPackage{restatelinks}
\newif\ifmarginprooflinks
\marginprooflinkstrue
\newif\ifproofbox
\proofboxtrue
\DeclareOption{strip}{\marginprooflinksfalse}
\DeclareOption{nobox}{\proofboxfalse}
\ProcessOptions\relax
\RequirePackage{scalerel}
\RequirePackage{hyperref}
\RequirePackage{amsthm}
\RequirePackage{thmtools}
\RequirePackage{tcolorbox}
% \RequirePackage{xstring} % for expandarg
\RequirePackage{xpatch}
\xpatchcmd{\thmt@restatable}% Edit \thmt@restatable
{\csname #2\@xa\endcsname\ifx\@nx#1\@nx\else[{#1}]\fi}% Replace this code
% {\ifthmt@thisistheone\csname #2\@xa\endcsname\typeout{oiii[#1;#2\@xa;#3;\csname thmt@stored@#3\endcsname]}\ifx\@nx#1\@nx\else[#1]\fi\else\csname #2\@xa\endcsname\fi}% with this code
{\ifthmt@thisistheone\csname #2\@xa\endcsname\ifx\@nx#1\@nx\else[{#1}]\fi
\else\fi}
{}{\typeout{FIRST PATCH TO THM RESTATE FAILED}} % execute on success/failure
\xpatchcmd{\thmt@restatable}% A second edit to \thmt@restatable
{\csname end#2\endcsname}
{\ifthmt@thisistheone\csname end#2\endcsname\else\fi}
{}{\typeout{FAILED SECOND THMT RESTATE PATCH}}
% use this to switch between versions for main text and restatement
\newcommand\onlyfirsttime[2][]{\ifthmt@thisistheone#2\else#1\fi}
% \def\onlyaftercolon#1:#2{#2}
\newcommand{\recall}[1]{\medskip\par\noindent{\bf \Cref{thmt@@#1}.} \begingroup\em \noindent
\expandafter\csname#1\endcsname* \endgroup\par\smallskip}
\setlength\marginparwidth{1.55cm}
\newenvironment{linked}[3][]{%
\def\linkedproof{#3}%
\def\linkedtype{#2}%
% \reversemarginpar
% \marginpar{%
% \vspace{1.1em}
% % \hspace{2em}
% % \raggedleft
% \raggedright
% \hyperref[proof:\linkedproof]{%
% \color{blue!50!white}
% \scaleleftright{$\Big[$}{\,{\small\raggedleft\tt\begin{tabular}{@{}c@{}} proof of \\\linkedtype~\ref*{\linkedtype:\linkedproof}\end{tabular}}\,}{$\Big]$}}
% }%
% \restatable[#1]{#2}{#2:#3}\label{#2:#3}%
\ifmarginprooflinks
\marginpar{%
% \vspace{-3em}% %% for bottom
% \vspace{1.5em}
\vspace{3em} %% for double space
\centering%
\@ifundefined{r@proof:\linkedproof}{% no proof available
\color{red!50!gray!60!white}%
\scaleleftright{$\Big($}{\,\mbox{\footnotesize\centering\tt\begin{tabular}{@{}c@{}}
\tiny
% proof of \\\,\linkedtype~\ref*{\linkedtype:\linkedproof}
% no\\[-0.15em]
% proof
unproven!
\end{tabular}}\,}{$\Big)$}~
}{% there is a link; insert link to proof
\hyperref[proof:\linkedproof]{%
% \hyperref[proof:#3]{
\color{blue!30!white}%
\scaleleftright{$\Big[$}{\,\mbox{%
\footnotesize\centering\tt%
% \renewcommand{\baselinestretch}{1.0}%
\singlespacing%
\begin{tabular}{@{}c@{}}
\tiny
% proof of \\\,\linkedtype~\ref*{\linkedtype:\linkedproof}
link to\\[-0.15em]
\tiny
proof
\end{tabular}}\,}{$\Big]$}}~
}}%
\fi
\restatable[#1]{#2}{#2:#3}\label{#2:#3}%
}%
{\endrestatable%
}
\newcounter{proofcntr}
% \newenvironment{lproof}{\begin{proof}\refstepcounter{proofcntr}}{\end{proof}}
\newenvironment{lproof}[1][Proof]{%
\renewcommand*{\proofname}{#1}
\begin{proof}\refstepcounter{proofcntr}}{\end{proof}}
\tcbuselibrary{most}
\ifproofbox
\tcolorboxenvironment{lproof}{
% fonttitle=\bfseries,
% top=0.5em,
enhanced,
parbox=false,
boxrule=0pt,
frame hidden,
borderline west={4pt}{0pt}{blue!20!black!40!white},
% coltext={blue!20!black!60!white},
% colback={blue!20!black!05!white},
colback={blue!20!black!02!white},
% colback={white},
sharp corners,
breakable,
% bottomsep at break=4cm,
% enlarge bottom at break by=-4cm,
% topsep at break=3cm,
% enlarge top at break by=-3cm
}
\fi
\usepackage[framemethod=TikZ]{mdframed}
% \surroundwithmdframed[ % lproof
% topline=false,
% linewidth=3pt,
% linecolor=gray!20!white,
% rightline=false,
% bottomline=false,
% leftmargin=0pt,
% % innerleftmargin=5pt,
% skipabove=\medskipamount,
% skipbelow=\medskipamount
% ]{lproof}
%oli16: The extra space was because there was extra space in the paragraph, not
%because this length was too big. By breaking arrays, everything will be better.
\newcommand{\begthm}[3][]{\begin{#2}[{name=#1},restate=#3,label=#3]}