forked from rpbarnes/WorkupSoftware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mycomments.sty
417 lines (408 loc) · 15.9 KB
/
mycomments.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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
\ProvidesPackage{mycomments}
\DeclareOption{commentsoff}{
\newcommand{\commentsoff}{}
}
\DeclareOption{margins}{
\oddsidemargin -0.75in % add 1in to get margin
\evensidemargin +0.25in % add 1in to get margin
\voffset -0.5in
\topmargin 0in
\textwidth 6.5in
\textheight 9.25in
\headheight 15pt
%\headheight 0in
\headsep 15pt
}
\ProcessOptions
\RequirePackage{changepage}
\RequirePackage{wrapfig}
\RequirePackage{setspace}
\RequirePackage{soul}
\RequirePackage[maxfloats=100]{morefloats}
%%{{{ these are for solution 2 below, which doesn't work
%\RequirePackage{zref-abspage}
%\RequirePackage{zref-user}
%\RequirePackage{atbegshi}
%%}}}
\RequirePackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{calc}
\usetikzlibrary{arrows,shapes}
\tikzstyle{every picture}+=[remember picture]
\gdef\myarrowdir{-90}
%{{{ highlightling of stackexchange
% http://tex.stackexchange.com/questions/5959/cool-text-highlighting-in-latex
\newcommand{\defhighlighter}[3][]{%
\tikzset{every highlighter/.style={color=#2, fill opacity=#3, #1}}%
}
\defhighlighter{yellow}{0.15}%JF changed to 0.33 to match
\newcommand{\highlight@DoHighlight}{
\fill [ decoration = {random steps, amplitude=1pt, segment length=15pt}
, outer sep = -15pt, inner sep = 0pt, decorate
, every highlighter, this highlighter ]
($(begin highlight)+(0,8pt)$) rectangle ($(end highlight)+(0,-3pt)$) ;
}
\newcommand{\highlight@BeginHighlight}{
\coordinate (begin highlight) at (0,0) ;
}
\newcommand{\highlight@EndHighlight}{
\coordinate (end highlight) at (0,0) ;
}
\newdimen\highlight@previous
\newdimen\highlight@current
\DeclareRobustCommand*\highlight[1][]{%
\tikzset{this highlighter/.style={#1}}%
\SOUL@setup
%
\def\SOUL@preamble{%
\begin{tikzpicture}[overlay, remember picture]
\highlight@BeginHighlight
\highlight@EndHighlight
\end{tikzpicture}%
}%
%
\def\SOUL@postamble{%
\begin{tikzpicture}[overlay, remember picture]
\highlight@EndHighlight
\highlight@DoHighlight
\end{tikzpicture}%
}%
%
\def\SOUL@everyhyphen{%
\discretionary{%
\SOUL@setkern\SOUL@hyphkern
\SOUL@sethyphenchar
\tikz[overlay, remember picture] \highlight@EndHighlight ;%
}{%
}{%
\SOUL@setkern\SOUL@charkern
}%
}%
%
\def\SOUL@everyexhyphen##1{%
\SOUL@setkern\SOUL@hyphkern
\hbox{##1}%
\discretionary{%
\tikz[overlay, remember picture] \highlight@EndHighlight ;%
}{%
}{%
\SOUL@setkern\SOUL@charkern
}%
}%
%
\def\SOUL@everysyllable{%
\begin{tikzpicture}[overlay, remember picture]
\path let \p0 = (begin highlight), \p1 = (0,0) in \pgfextra
\global\highlight@previous=\y0
\global\highlight@current =\y1
\endpgfextra (0,0) ;
\ifdim\highlight@current < \highlight@previous
\highlight@DoHighlight
\highlight@BeginHighlight
\fi
\end{tikzpicture}%
\the\SOUL@syllable
\tikz[overlay, remember picture] \highlight@EndHighlight ;%
}%
\SOUL@
}
%}}} end highlighting
%%{{{ highlightling ver. 2 off stackexchange
%\newcommand{\currentsidemargin}{%
% \ifodd\zref@extract{textarea-\thetextarea}{abspage}%
% \oddsidemargin%
% \else%
% \evensidemargin%
% \fi%
%}
%
%\newcounter{textarea}
%\newcommand{\settextarea}{%
% \stepcounter{textarea}%
% \zlabel{textarea-\thetextarea}%
% \begin{tikzpicture}[overlay,remember picture]
% % Helper nodes
% \path (current page.north west) ++(\hoffset, -\voffset)
% node[anchor=north west, shape=rectangle, inner sep=0, minimum width=\paperwidth, minimum height=\paperheight]
% (pagearea) {};
% \path (pagearea.north west) ++(1in+\currentsidemargin,-1in-\topmargin-\headheight-\headsep)
% node[anchor=north west, shape=rectangle, inner sep=0, minimum width=\textwidth, minimum height=\textheight]
% (textarea) {};
% \end{tikzpicture}%
%}
%
%
%\usepackage{lipsum}
%\newcommand\xlipsum[1][]{{\let\par\relax\lipsum*[#1]}}
%
%\tikzset{tikzul/.style={yshift=-.75\dp\strutbox}}
%
%\newcounter{tikzul}%
%\newcommand\tikzul[1][]{%
% \begingroup
% \global\tikzullinewidth\linewidth
% \def\tikzulsetting{[#1]}%
% \stepcounter{tikzul}%
% \settextarea
% \zlabel{tikzul-begin-\thetikzul}%
% \tikz[overlay,remember picture,tikzul] \coordinate (tikzul-\thetikzul) at (0,0);% Modified \tikzmark macro
% \ifnum\zref@extract{tikzul-begin-\thetikzul}{abspage}=\zref@extract{tikzul-end-\thetikzul}{abspage}
% \else
% \AtBeginShipoutNext{\tikzul@endpage{#1}}%
% \fi
% \bgroup
% \def\par{\ifhmode\unskip\fi\egroup\par\@ifnextchar\noindent{\noindent\tikzul[#1]}{\tikzul[#1]\bgroup}}%
% \aftergroup\endtikzul
% \let\@let@token=%
%}
%
%\newlength\tikzullinewidth
%
%\def\tikzul@endpage#1{%
%\setbox\AtBeginShipoutBox\hbox{%
%\box\AtBeginShipoutBox
%\hbox{%
%\begin{tikzpicture}[overlay,remember picture,tikzul]
%\draw[#1]
% let \p1 = (tikzul-\thetikzul), \p2 = ([xshift=\tikzullinewidth+\@totalleftmargin]textarea.south west) in
% \ifdim\dimexpr\y1-\y2<.5\baselineskip
% (\x1,\y1) -- (\x2,\y1)
% \else
% let \p3 = ([xshift=\@totalleftmargin]textarea.west) in
% (\x1,\y1) -- +(\tikzullinewidth-\x1+\x3,0)
% % (\x3,\y2) -- (\x2,\y2)
% (\x3,\y1)
% \myloop{\y1-\y2+.5\baselineskip}{%
% ++(0,-\baselineskip) -- +(\tikzullinewidth,0)
% }%
% \fi
%;
%\end{tikzpicture}%
%}}%
%}%
%
%\def\endtikzul{%
% \zlabel{tikzul-end-\thetikzul}%
% \ifnum\zref@extract{tikzul-begin-\thetikzul}{abspage}=\zref@extract{tikzul-end-\thetikzul}{abspage}
% \begin{tikzpicture}[overlay,remember picture,tikzul]
% \expandafter\draw\tikzulsetting
% let \p1 = (tikzul-\thetikzul), \p2 = (0,0) in
% \ifdim\y1=\y2
% (\x1,\y1) -- (\x2,\y2)
% \else
% let \p3 = ([xshift=\@totalleftmargin]textarea.west), \p4 = ([xshift=-\rightmargin]textarea.east) in
% (\x1,\y1) -- +(\tikzullinewidth-\x1+\x3,0)
% (\x3,\y2) -- (\x2,\y2)
% (\x3,\y1)
% \myloop{\y1-\y2}{%
% ++(0,-\baselineskip) -- +(\tikzullinewidth,0)
% }%
% \fi
% ;
% \end{tikzpicture}%
% \else
% \settextarea
% \begin{tikzpicture}[overlay,remember picture,tikzul]
% \expandafter\draw\tikzulsetting
% let \p1 = ([xshift=\@totalleftmargin,yshift=-.5\baselineskip]textarea.north west), \p2 = (0,0) in
% \ifdim\dimexpr\y1-\y2<.5\baselineskip
% (\x1,\y2) -- (\x2,\y2)
% \else
% let \p3 = ([xshift=\@totalleftmargin]textarea.west), \p4 = ([xshift=-\rightmargin]textarea.east) in
% (\x3,\y2) -- (\x2,\y2)
% (\x3,\y2)
% \myloop{\y1-\y2}{%
% ++(0,+\baselineskip) -- +(\tikzullinewidth,0)
% }
% \fi
% ;
% \end{tikzpicture}%
% \fi
% \endgroup
%}
%
%\def\myloop#1#2#3{%
% #3%
% \ifdim\dimexpr#1>1.1\baselineskip
% #2%
% \expandafter\myloop\expandafter{\the\dimexpr#1-\baselineskip\relax}{#2}%
% \fi
%}
%%}}} end highlighting
%\renewcommand{\highlight}[1]{#1}%do nothing, use as a marker
%{{{ wrapfigure that fits inside revtex
\def\inlinewrapfigside{r}
\newcommand{\inlinewrapfig}[1]{%
\begin{wrapfigure}{\inlinewrapfigside}[0.3in]{1.5in}%[number of narrow lines] {placement} [overhang] {width of figure}
\vspace{-0.2in}
\hspace{-0.2in}
\begin{minipage}{1.5in}
#1
\end{minipage}
\vspace{-0.2in}
\end{wrapfigure}
}%
%}}}
%{{{ begin arrow comments and my ntd notation
\newcounter{myreferencecounter}%this is incremented every time I add a reference in the text
\newcounter{mycommentstacksizecounter}%this tells me about the excess of reference to references+text bubbles I have
\newcounter{currentreferencecounter}%this tells me what reference I want to point AT
\makeatletter
\newcommand{\note}[2][blue]{% the first argument is the text to highlight and the second is the footnote
\gdef\myarrowdir{-90}%should be able to use if@firstcolumn, but not able to
\stepcounter{myreferencecounter}%whenever I call note, I create a new reference
\stepcounter{mycommentstacksizecounter}%but, I have not yet used that to make a comment, debug follows: %(for note, reference counter is \themyreferencecounter\ and stack is \themycommentstacksizecounter\ deep)
\highlight[#1]{#2}\hspace*{-0.25cm}\tikz[baseline]\node[fill=#1,fill opacity=0.0,text opacity=1.0,anchor=base,text width=0.01cm,draw=none] (reffootnote\themyreferencecounter) {};%the tikz part is just the marker for the arrow.
%\tikzul[line width=1.5\ht\strutbox,semitransparent,yellow]{#2};\hspace*{-0.25cm}\tikz[baseline]\node[fill=#1,fill opacity=0.0,text opacity=1.0,anchor=base,text width=0.01cm,draw=none] (reffootnote\themyreferencecounter) {};%the tikz part is just the marker for the arrow.
%\sethlcolor{#1}\hl{#2}\hspace*{-0.25cm}\tikz[baseline]\node[fill=#1,fill opacity=0.0,text opacity=1.0,anchor=base,text width=0.01cm,draw=none] (reffootnote\themyreferencecounter) {};%the tikz part is just the marker for the arrow.
}%
\def\noteloc{l}
\def\noteang{0}
\newcommand{\wrapnote}[2][-90]{%
WRAP NOTE SHOULD BE UPDATED TO MATCH SHOWNOTESETCOLOR
\begin{wrapfigure}{\noteloc}{1in}%
\setstretch{-1}
%\hspace{-0.75in}
\begin{tikzpicture}%
\node[fill=blue,fill opacity=0.15,draw opacity=1.0,text opacity=1.0,anchor=base,rounded corners] (footnote\themyreferencecounter) {%
\begin{minipage}{1in}%
\begin{tiny}%
#2
\end{tiny}%
\end{minipage}%
};%
\end{tikzpicture}%
\end{wrapfigure}%
\begin{tikzpicture}[overlay]%
\path[->,color=blue,opacity=0.15,line width=2] (footnote\themyreferencecounter) edge [out=\noteang,in=#1] (reffootnote\themyreferencecounter);%
\end{tikzpicture}%
\def\noteloc{l}
\def\noteang{0}
}%
\newcommand{\showfootnote}[2][out=0, in=-90]{%
SHOW FOOTNOTE SHOULD BE UPDATED TO MATCH SHOWINLINESETCOLOR
\footnote{
\begin{minipage}{\linewidth}
\begin{tikzpicture}[baseline]
\node[fill=blue,fill opacity=0.15,text opacity=1.0,anchor=north,rounded corners] (footnote\themyreferencecounter) {\begin{minipage}{\linewidth}{\color{black}#2}\end{minipage}};
\end{tikzpicture}
\end{minipage}
}
\begin{tikzpicture}[overlay]%
\path[->,color=blue,opacity=0.15,line width=2] (footnote\themyreferencecounter) edge [#1] (reffootnote\themyreferencecounter);%
\end{tikzpicture}%
}%
\newcommand{\shownote}[2][-90]{%
SHOULD BE UPDATED TO MATCH SHOWINLINESETCOLOR
\marginpar{%
\setstretch{-1}
%\hspace{-0.75in}
\begin{tikzpicture}%
\node[fill=blue,fill opacity=0.15,draw opacity=1.0,text opacity=1.0,anchor=base,rounded corners] (footnote\themyreferencecounter) {%
\begin{minipage}{1.75in}%
\begin{tiny}%
#2
\end{tiny}%
\end{minipage}%
};%
\end{tikzpicture}%
}%
\myarrowcommand{out=180,in=#1}%
}%
\newcommand{\myarrowcommand}[2][blue]{%\myarrowcommand[color]{angle}
\begin{tikzpicture}[overlay]%
\path[->,color=#1,opacity=0.15,line width=2] (footnote\thecurrentreferencecounter) edge [#2] (reffootnote\thecurrentreferencecounter);%
\end{tikzpicture}%
}%
\newcommand{\shownotesetcolor}[3][-30]{%\shownotesetcolor[angle]{color}{text}
\setcounter{currentreferencecounter}{\themyreferencecounter}%
\addtocounter{currentreferencecounter}{-\themycommentstacksizecounter}%
\addtocounter{currentreferencecounter}{1}%by default there is one thing on the stack, and it will be the last one, but otherwise, it will go further back, debug follows: %(for shownote, comment counter is \themyreferencecounter, stack is \themycommentstacksizecounter\ deep, and I decide to use shape \thecurrentreferencecounter)
\marginpar{%
\setstretch{-1}
%\hspace{-0.75in}
\begin{tikzpicture}%
\node[fill=#2,fill opacity=0.15,draw opacity=1.0,text opacity=1.0,anchor=base,rounded corners] (footnote\thecurrentreferencecounter) {%
\begin{minipage}{2.75in}%
\begin{scriptsize}%
#3
\end{scriptsize}%
\end{minipage}%
};%
\end{tikzpicture}%
}%
\myarrowcommand[#2]{out=\myarrowdir,in=#1}%
\addtocounter{mycommentstacksizecounter}{-1}%``pop'' the stack
}%
\newcommand{\showrespbox}[2]{%\shownotesetcolor[angle]{color}{text}
%\hspace{-0.75in}
\begin{tikzpicture}%
\node[fill=#1,fill opacity=0.15,draw opacity=1.0,text opacity=1.0,anchor=base,rounded corners] {%
\begin{minipage}{2.70in}%
\begin{scriptsize}%
#2
\end{scriptsize}%
\end{minipage}%
};%
\end{tikzpicture}%
}%
\newcommand{\showinlinesetcolor}[3][0]{%\shownotesetcolor[angle]{color}{text}
\setcounter{currentreferencecounter}{\themyreferencecounter}%I need to decide which reference I want to point at
\addtocounter{currentreferencecounter}{-\themycommentstacksizecounter}%
\addtocounter{currentreferencecounter}{1}%by default my stack size is 1, and I use 1, debug follows: %(for inline, comment counter is \themyreferencecounter, stack is \themycommentstacksizecounter\ deep, and I decide to use shape \thecurrentreferencecounter)
\begin{tikzpicture}%
\node[fill=#2,fill opacity=0.15,draw opacity=1.0,text opacity=1.0,anchor=base,rounded corners] (footnote\thecurrentreferencecounter) {%
\begin{minipage}{\linewidth}%
\begin{scriptsize}%
#3
\end{scriptsize}%
\end{minipage}%
};%
\end{tikzpicture}%
\myarrowcommand[#2]{out=#1,in=0}%
\addtocounter{mycommentstacksizecounter}{-1}%``pop'' the stack
}%
\newcommand{\skipping}[1]{\xspace{\color{orange}\sout{#1}}}
%}}} end arrow comments
%{{{ map comment commands to printed comments
\@ifundefined{commentsoff}{
%{{{ need to do
\newcommand{\ntdmark}[1]{\note[blue]{#1}}
\newcommand{\ntdbubble}[1]{\johnbubble{\textbf{I need to:} #1}}
\renewcommand{\ntd}[2][]{\ntdmark{#1}\ntdbubble{#2}}
%}}}
%{{{ john
\renewcommand{\johnmark}[1]{\note[blue]{#1}}
\renewcommand{\johnbox}[2][180]{\showinlinesetcolor[#1]{blue}{{\tiny\textit{John:}}#2}}
\newcommand{\johnresp}[1]{\johnmark{}\showrespbox{blue}{{\tiny\textit{John:}}#1}}
\renewcommand{\johnbubble}[1]{\shownotesetcolor{blue}{{\tiny\textit{John:}}#1}}
\renewcommand{\john}[2][]{\johnmark{#1}\johnbubble{#2}}
\newcommand{\johntwocol}[2][]{\johnmark{#1}\inlinewrapfig{\johnbox[0]{#2}}}
%}}}
%{{{ songi
\renewcommand{\songimark}[1]{\note[red]{#1}}
\renewcommand{\songibox}[2][180]{\showinlinesetcolor[#1]{red}{{\tiny\textit{Songi:}}#2}}
\renewcommand{\songibubble}[1]{\shownotesetcolor{red}{{\tiny\textit{Songi:}}#1}}
\renewcommand{\songi}[2][]{\songimark{#1}\songibubble{#2}}
\newcommand{\songitwocol}[2][]{\songimark{#1}\inlinewrapfig{\songibox[0]{#2}}}
%}}}
%{{{peter
\renewcommand{\petermark}[1]{\note[green]{#1}}
\renewcommand{\peterbox}[1]{\showinlinesetcolor{green}{{\tiny\textit{Peter:}}#1}}
\renewcommand{\peterbubble}[1]{\shownotesetcolor{green}{{\tiny\textit{Peter:}}#1}}
\renewcommand{\peter}[2][]{\petermark{#1}\peterbubble{#2}}
%}}}
%{{{yuan
\renewcommand{\yuanmark}[1]{\note[yellow]{#1}}
\renewcommand{\yuanbox}[1]{\showinlinesetcolor{yellow}{{\tiny\textit{Yuan:}}#1}}
\renewcommand{\yuanbubble}[1]{\shownotesetcolor{yellow}{{\tiny\textit{Yuan:}}#1}}
\renewcommand{\yuan}[2][]{\yuanmark{#1}\yuanbubble{#2}}
%}}} end yuan
}{
\renewcommand{\ntd}[2][]{#1}
\renewcommand{\john}[2][]{#1}
\renewcommand{\songi}[2][]{#1}
\renewcommand{\peter}[2][]{#1}
\renewcommand{\yuan}[2][]{#1}
}
%}}}