-
Notifications
You must be signed in to change notification settings - Fork 6
/
chato-notes.sty
175 lines (165 loc) · 7.94 KB
/
chato-notes.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
170
171
172
173
174
175
% Simple package for inserting notes
% ChaTo - http://www.chato.cl/
% Wed Dec 24 13:33:00 CET 2008
%
% Copyright 2015-22 Matteo Riondato (http://matteo.rionda.to)
%
% Licensed under the Apache License, Version 2.0 (the "License");
% you may not use this file except in compliance with the License.
% You may obtain a copy of the License at
%
% http://www.apache.org/licenses/LICENSE-2.0
%
% Unless required by applicable law or agreed to in writing, software
% distributed under the License is distributed on an "AS IS" BASIS,
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
% See the License for the specific language governing permissions and
% limitations under the License.
\ProvidesPackage{chato-notes}[2015/09/22 v0.001a ChaTo notes]
\RequirePackage{color,ifthen,marvosym,tcolorbox,xkeyval,xspace}
\tcbuselibrary{breakable}
% Variable to store the name of the insert currently under definition
\newcommand{\chato@insertname}{}
% Utility macro
\newcommand{\chato@setprop}[2]{\expandafter\newcommand\csname chato@#1\chato@insertname\endcsname{#2}}
% Default insert colors
\definecolor{chato@clrbittersweet}{rgb}{0.55,0.241,0.204}
\definecolor{chato@clrblue}{rgb}{0.0,0.0,0.6}
\definecolor{chato@clrgoldenrod}{rgb}{0.525,0.397,0.077}
\definecolor{chato@clrgreen}{rgb}{0.0,0.6,0.0}
\definecolor{chato@clrprocessblue}{rgb}{0.077,0.414,0.508}
\definecolor{chato@clrpurple}{rgb}{0.340,0.105,0.555}
\definecolor{chato@clrred}{rgb}{0.6,0.0,0.0}
\definecolor{chato@clrtrueblue}{rgb}{0.0,0.45,0.90}
\newcommand{\chato@defclridea}{chato@clrtrueblue}
\newcommand{\chato@defclrnote}{chato@clrpurple}
\newcommand{\chato@defclrmynote}{\chato@defclrnote}
\newcommand{\chato@defclrquestion}{chato@clrbittersweet}
\newcommand{\chato@defclrreply}{chato@clrblue}
\newcommand{\chato@defclrtodo}{chato@clrgreen}
\newcommand{\chato@defclrwarning}{chato@clrred}
% Default insert symbols
\newcommand{\chato@defsymidea}{\Laserbeam}
\newcommand{\chato@defsymnote}{\Pointinghand}
\newcommand{\chato@defsymmynote}{\chato@defsymnote}
\newcommand{\chato@defsymquestion}{?}
\newcommand{\chato@defsymreply}{\Writinghand}
\newcommand{\chato@defsymtodo}{\Checkedbox}
\newcommand{\chato@defsymwarning}{\Biohazard}
% Default framed insert texts
\newcommand{\chato@deftextidea}{Idea}
\newcommand{\chato@deftextmynote}{Note}
\newcommand{\chato@deftextquestion}{Question}
\newcommand{\chato@deftextreply}{Reply}
\newcommand{\chato@deftexttodo}{To-Do}
\newcommand{\chato@deftextwarning}{Warning}
% for/from text for framed inserts
\newcommand{\chato@fortext}{for}
\newcommand{\chato@fromtext}{from}
% Option processing for framed inserts
\newcommand{\chato@processauthor}[1]{\ifx\relax#1\relax
\ifx\chato@author\@undefined \else \let\chato@author\@undefined \fi \else\def\chato@author{#1}\fi}
\newcommand{\chato@processdate}[1]{\ifx\relax#1\relax
\ifx\chato@date\@undefined \else \let\chato@date\@undefined \fi \else
\def\chato@date{#1} \fi}
\newcommand{\chato@processto}[1]{\ifx\relax#1\relax
\ifx\chato@to\@undefined \else \let\chato@to\@undefined \fi \else
\def\chato@to{#1} \fi}
\define@key{chato}{author}{\chato@processauthor{#1}}
\define@key{chato}{by}{\chato@processauthor{#1}}
\define@key{chato}{from}{\chato@processauthor{#1}}
\define@key{chato}{date}{\chato@processdate{#1}}
\define@key{chato}{for}{\chato@processto{#1}}
\define@key{chato}{to}{\chato@processto{#1}}
\presetkeys{chato}{author=,from=,by=,to=,for=,date=}{}
% Framed inserts template
\define@key{chatoframed}{clr}{\chato@setprop{clrf}{#1}}
\define@key{chatoframed}{sym}{\chato@setprop{symf}{#1}}
\define@key{chatoframed}{text}{\chato@setprop{text}{#1}}
\presetkeys{chatoframed}{clr=black,sym=\MineSign,text=Foo}{}
\newcommand{\newframedinsert}[2][]{
\renewcommand{\chato@insertname}{#2}
\setkeys{chatoframed}{#1}
\expandafter\newcommand\csname #2\endcsname[2][]{
\setkeys{chato}{##1}
\begin{center}
\begin{tcolorbox}[breakable,sharp
corners,boxrule=.2mm,left=.25mm,right=.25mm,top=.25mm,bottom=.25mm,colback=white,notitle,colframe=\csname
chato@clrf#2\endcsname,pad at break*=0mm]
\sffamily
{\color{\csname chato@clrf#2\endcsname}
\textbf{\textsc{\csname chato@symf#2\endcsname\ \csname chato@text#2\endcsname
\ifx\chato@to\@undefined \else \mbox{ \chato@fortext\ \chato@to}\fi
\ifx\chato@author\@undefined\else\mbox{ \chato@fromtext\
\chato@author}\fi
\ifx\chato@date\@undefined \else \mbox{ (\chato@date)}\fi:}}}
##2
\end{tcolorbox}
\end{center}}}
\newframedinsert[clr=\chato@defclridea,sym=\chato@defsymidea,text=\chato@deftextidea]{idea}
\newframedinsert[clr=\chato@defclrmynote,sym=\chato@defsymmynote,text=\chato@deftextmynote]{mynote}
\newframedinsert[clr=\chato@defclrquestion,sym=\chato@defsymquestion,text=\chato@deftextquestion]{question}
\newframedinsert[clr=\chato@defclrreply,sym=\chato@defsymreply,text=\chato@deftextreply]{reply}
\newframedinsert[clr=\chato@defclrtodo,sym=\chato@defsymtodo,text=\chato@deftexttodo]{todo}
\newframedinsert[clr=\chato@defclrwarning,sym=\chato@defsymwarning,text=\chato@deftextwarning]{warning}
% Define inline inserts
\define@key{chatoinline}{sym}{\chato@setprop{symi}{#1}}
\define@key{chatoinline}{clr}{\chato@setprop{clri}{#1}}
\define@key{chatoinline}{open}{\chato@setprop{openi}{#1}}
\define@key{chatoinline}{close}{\chato@setprop{closei}{#1}}
\presetkeys{chatoinline}{clr=black,sym=\MineSign,open=\ensuremath\lceil,close=\ensuremath\rfloor}{}
\newcommand{\newinlineinsert}[2][]{
\renewcommand{\chato@insertname}{#2}
\setkeys{chatoinline}{#1}
\expandafter\newcommand\csname i#2\endcsname[1]{%
{\textsf{\color{\csname chato@clri#2\endcsname}\textbf{\textsc{\csname
chato@openi#2\endcsname \csname
chato@symi#2\endcsname}} {\color{black}\ ##1} \textbf{\textsc{\csname
chato@closei#2\endcsname}}}}}}
\newinlineinsert[clr=\chato@defclridea,sym=\chato@defsymidea]{idea}
\newinlineinsert[clr=\chato@defclrnote,sym=\chato@defsymnote]{note}
\newinlineinsert[clr=\chato@defclrmynote,sym=\chato@defsymmynote]{mynote}
\newinlineinsert[clr=\chato@defclrquestion,sym=\chato@defsymquestion]{question}
\newinlineinsert[clr=\chato@defclrreply,sym=\chato@defsymreply]{reply}
\newinlineinsert[clr=\chato@defclrtodo,sym=\chato@defsymtodo]{todo}
\newinlineinsert[clr=\chato@defclrwarning,sym=\chato@defsymwarning]{warning}
\newcommand{\chato@citemissingclr}{chato@clrgoldenrod}
\newcommand{\chato@citemissingnoargtext}{\lbrack%
Citation\rbrack}
\newcommand{\chato@citemissingwithargtextpre}{\lbrack%
Cit:}
\newcommand{\chato@citemissingwithargtextpost}{\rbrack}
\newcommand{\chato@citemissingnoarg}{\textsf{\textbf{\textsc{\color{\chato@citemissingclr}\chato@citemissingnoargtext}}}\xspace}
\newcommand{\chato@citemissingwitharg}[1]{\textsf{\textbf{\textsc{\color{\chato@citemissingclr}\chato@citemissingwithargtextpre#1\chato@citemissingwithargtextpost}}}\xspace}
\newcommand{\citemissing}[1][]{%
\ifthenelse{\equal{#1}{}}{%
\chato@citemissingnoarg{}}{%
\chato@citemissingwitharg{#1}}}
\newcommand{\chato@refmissingclr}{chato@clrprocessblue}
\newcommand{\chato@refmissingnoargtext}{Reference}
\newcommand{\chato@refmissingwithargtext}{Ref:}
\newcommand{\chato@refmissingnoarg}[0]{\textsf{\textbf{\textsc{\color{\chato@refmissingclr}\chato@refmissingnoargtext}}}\xspace}
\newcommand{\chato@refmissingwitharg}[1]{\textsf{\textbf{\textsc{\color{\chato@refmissingclr}\chato@refmissingwithargtext#1}}}\xspace}
\newcommand{\refmissing}[1][]{%
\ifthenelse{\equal{#1}{}}{%
\chato@refmissingnoarg{}}{%
\chato@refmissingwitharg{#1}}}
\DeclareOption{show}{
}
\DeclareOption{hide}{
\renewcommand{\idea}[2][]{}
\renewcommand{\mynote}[2][]{}
\renewcommand{\question}[2][]{}
\renewcommand{\reply}[2][]{}
\renewcommand{\todo}[2][]{}
\renewcommand{\warning}[2][]{}
\renewcommand{\iidea}[2][]{}
\renewcommand{\inote}[1]{}
\renewcommand{\iquestion}[1]{}
\renewcommand{\ireply}[1]{}
\renewcommand{\itodo}[1]{}
\renewcommand{\iwarning}[1]{}
\renewcommand{\citemissing}{}
\renewcommand{\refmissing}{}
}
\ProcessOptions