forked from mikespook/Learning-Go-zh-cn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
coderemarks.sty
30 lines (29 loc) · 932 Bytes
/
coderemarks.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
\ProvidesPackage{coderemarks}
\RequirePackage{tikz}
%% Code Remarks -- Miek Gieben
%% define 2 commands
%% \longremark[1] where you can say something about the code
%% \showremarks - displays all remarks in a list after the code
\newcounter{coderemarks}
\setcounter{coderemarks}{0}
\newcounter{codevar}
\setcounter{codevar}{0}
%
\newcommand{\gocircle}[1]{%
\tikz\node[text=white,font=\sffamily\bfseries,minimum size=3mm,inner sep=0mm,draw,circle,fill=black]{\small #1};}
%
\newcommand{\longremark}[1]{%
\gocircle{\arabic{coderemarks}}%
\global \expandafter\def \csname codebox\the\value{coderemarks}\endcsname{#1}%
\stepcounter{coderemarks}}
%
\newcommand{\showremarks}{%
\begin{list}{\gocircle{\arabic{codevar}}} %
{} %
\whiledo{\value{codevar} < \value{coderemarks}}{ %
\item \expandafter\csname codebox\the\value{codevar}\endcsname %
\stepcounter{codevar}} %
\end{list} %
\setcounter{coderemarks}{0}%
\setcounter{codevar}{0}%
}