-
Notifications
You must be signed in to change notification settings - Fork 0
/
lithie-task-boxes.sty
189 lines (170 loc) · 8.1 KB
/
lithie-task-boxes.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
%% lithie-task-boxes.sty
%% Florian Sihler, 30.09.2020
%% Dependent brother
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{lithie-task-boxes}[2020/10/06 EagleoutIce - lilly box-port of task boxes]
\newif\iflibx@tb@boxes@style@plain@
\DeclareOption{plainstyle}{\libx@tb@boxes@style@plain@true}
\DeclareOption{normalstyle}{\libx@tb@boxes@style@plain@false}
\newif\iflibx@tb@boxes@showub@
\DeclareOption{showub}{\libx@tb@boxes@showub@true}
\DeclareOption{hideub}{\libx@tb@boxes@showub@false}
\newif\iflibx@tb@boxes@isbm@
\DeclareOption{isbm}{\libx@tb@boxes@isbm@true}
\DeclareOption{noisbm}{\libx@tb@boxes@isbm@false}
\newif\iflibx@tb@boxes@cpalette@
\DeclareOption{cpalette}{\libx@tb@boxes@cpalette@true}
\DeclareOption{nocpalette}{\libx@tb@boxes@cpalette@false}
\ProcessOptions*
\iflibx@tb@boxes@cpalette@
\let\libx@tsk@old@cpl@hooks\cpl@hooks
\def\cpl@hooks{% Add to the hook
\libx@tsk@old@cpl@hooks\libx@task@cpalette@hook}
\def\libx@task@cpalette@hook{%
\colorlet{tskcolor}{paletteA!20!black!50!white}%
\colorlet{tskcolorA}{paletteA}%
\colorlet{tskcolorB}{paletteB}}
\AtBeginDocument{\libx@task@cpalette@hook}
\fi
\def\libx@taskbox@border@width{2.71pt}
\def\libx@taskbox@border@width@large{6.71pt}
\newcounter{libx@tsk@ubnum@}
\colorlet{tskcolor}{black!40!white}
\colorlet{tskcolorA}{black}\colorlet{tskcolorB}{white}
\def\tsksub{\@ifstar\@tsksub@star\@tsksub}
\newcommand*\@tsksub@star[2][]{%
\ifx!#1!\stepcounter{libx@tsk@ubnum@}%
\else\setcounter{libx@tsk@ubnum@}{#1}\fi
\def\libx@currentub{#2}%
\pdfbookmark[0]{\thelibx@tsk@ubnum@\ #2}{libx@tb@boxes@@id@\thelibx@tsk@ubnum@}%
}
\newcommand*\@tsksub[2][]{%
\ifx!#1!\stepcounter{libx@tsk@ubnum@}%
\else\setcounter{libx@tsk@ubnum@}{#1}\fi
\def\libx@currentub{#2}%
\section*{#2}}
\iflibx@tb@boxes@style@plain@\else\RequirePackage{varwidth}\fi
\RequirePackage{bookmark}
\iflibx@tb@boxes@showub@
\def\libx@tb@boxes@boxnumber{\thelibx@tsk@ubnum@.\thetcbcounter}
\else\def\libx@tb@boxes@boxnumber{\thetcbcounter}\fi
\translatelet{\@libx@tskstyle}{Task}
\tcbset{
lithie@box@style@taskbox@plain/.style={%
lithie@box@style@default@plain,fonttitle=\normalsize\normalcolor\sffamily\small,%
% as guides:
lithie@box@style@taskbox@extra@arrows=tskcolor,%
% padding to give them space to breathe:
pad before break*=3mm,pad after break=3mm,lines before break=4,%
after upper={\nobreak\null\nobreak\hfill\nobreak\rlap{\hyperref[@libx@tsk:\thelibx@tsk@ubnum@ @\thetcbcounter]{\textcolor{gray}{\raisebox{.65pt}{$\diamondsuit$}\textcolor{gray}{~$\mathsf{\libx@tb@boxes@boxnumber}$}}}}}%
},%
lithie@box@style@taskbox@extra@arrows/.style={%
extras first and middle={overlay={% .33pt offset to buffer
\begin{scope}[shift={(frame.south west)}]
\path[fill=#1] (0,0) -- ++(\libx@taskbox@border@width/2,-\libx@taskbox@border@width) --
++(\libx@taskbox@border@width/2,\libx@taskbox@border@width) |- (0,.33pt) -- cycle;
\end{scope}
}},%
extras middle and last={overlay={%
\begin{scope}[shift={(frame.north west)}]
\path[fill=#1] (0,0) -- ++(\libx@taskbox@border@width/2,\libx@taskbox@border@width) --
++(\libx@taskbox@border@width/2,-\libx@taskbox@border@width) |- (0,-.33pt) -- cycle;
\end{scope}
}}}%
}
\iflibx@tb@boxes@style@plain@
\def\@libx@tskstyle@suffix{plain}
\else\def\@libx@tskstyle@suffix{normal}\fi
\newtcolorbox[lithie@box@style@default@init]{libx@box@addon@\@libx@tskstyle @plain}[4][]{lithie@box@style@taskbox@plain,%
before title pre={%
\label{@libx@tsk:\thelibx@tsk@ubnum@ @\thetcbcounter}%
\iflibx@tb@boxes@isbm@\pdfbookmark[1]{\libx@tb@boxes@boxnumber\ - #4}{libx@tb@boxes@@id@\thelibx@tsk@ubnum@ @\thetcbcounter}\fi},
title={\textbf{#2 \libx@tb@boxes@boxnumber{}} \ifthenelse{\equal{#4}{}}{}{--~}#4},tikz={#1},%
}
\newlength\libx@tb@ulnumwidth
\iflibx@tb@boxes@showub@\libx@tb@ulnumwidth=22mm
\else\libx@tb@ulnumwidth=13.25mm\fi
\def\libx@tsk@numfieldbox{%
\path[fill=tskcolorA] ([xshift=6mm]frame.north west)
arc[start angle=0,end angle=180,radius=.75mm];
\path[fill=tskcolorB!65!tskcolorA] ([xshift=\libx@tb@ulnumwidth+4.1mm]frame.north west)
arc[start angle=180,end angle=0,radius=.75mm];
\path[left color=tskcolorA,right color=tskcolorB!65!tskcolorA,
middle color=tskcolorB!20!tskcolorA]
([xshift=5mm,yshift=.75mm]frame.north west) -- ++(\libx@tb@ulnumwidth,0)
[rounded corners=.75mm] -- ++(-.75mm,-.75mm)
-- ++(0,-7.5mm) -- ++(-\libx@tb@ulnumwidth+1.5mm,0)
-- ++(0,7.5mm)
[sharp corners]-- cycle;
\path (frame.north west)++(\libx@tb@ulnumwidth/2+5mm,-7.5mm/2) node[white] {\bfseries\libx@tb@boxes@boxnumber};%
}
\colorlet{lithie@box@taskbox@back}{white}
\colorlet{lithie@box@taskbox@text}{black}
\newtcolorbox[lithie@box@style@default@init]{libx@box@addon@\@libx@tskstyle @normal}[4][]{%
enforce breakable, %enforce breakable für: Mehr Seiten
enhanced jigsaw, before skip=2mm plus 3mm minus 1mm,after skip=4mm plus 2mm minus 2mm,coltext=lithie@box@taskbox@text,
colback=lithie@box@taskbox@back,colframe=tskcolor,boxrule=.4mm,%
enlargepage flexible=\baselineskip,%
attach boxed title to top left={xshift=\linewidth-\tcboxedtitlewidth-.75cm,yshift*=1mm-\tcboxedtitleheight},top=2.55mm,bottom=2.55mm,
varwidth boxed title*=-4.5cm,lines before break=4,arc=.75mm,%
boxed title style={
frame code={
\fill[tskcolor]
([yshift=-1mm,xshift=-1.25mm]frame.north west)
arc[start angle=0,end angle=180,radius=1mm];
\fill[white!24!tskcolor] ([yshift=-1mm,xshift=1.25mm]frame.north east)
arc[start angle=180,end angle=0,radius=1mm];
\path[left color=tskcolor,right color=white!24!tskcolor,
middle color=tskcolor]
([xshift=-2.5mm]frame.north west) -- ([xshift=2.5mm]frame.north east)
[rounded corners=1mm]-- ([xshift=2mm,yshift=-1mm]frame.north east)
-- ([xshift=.75mm]frame.south east) -- ([xshift=-.75mm]frame.south west)
-- ([xshift=-2mm,yshift=-1mm]frame.north west)
[sharp corners]-- cycle;
},interior engine=empty,
},
extras first={overlay={% .33pt offset to buffer
\begin{scope}[shift={(frame.south)},yshift=-.125cm]
\path[fill=tskcolor] (0,\z@) -- ++(\libx@taskbox@border@width@large/2,-\libx@taskbox@border@width@large) --
++(\libx@taskbox@border@width@large/2,\libx@taskbox@border@width@large) |- (0,.33pt) -- cycle;
\end{scope}
\libx@tsk@numfieldbox%
}},
extras middle={overlay={% .33pt offset to buffer
\begin{scope}[shift={(frame.south)},yshift=-.125cm]
\path[fill=tskcolor] (0,0) -- ++(\libx@taskbox@border@width@large/2,-\libx@taskbox@border@width@large) --
++(\libx@taskbox@border@width@large/2,\libx@taskbox@border@width@large) |- (0,.33pt) -- cycle;
\end{scope}
\begin{scope}[shift={(frame.north)},yshift=.125cm]
\path[fill=tskcolor] (0,0) -- ++(\libx@taskbox@border@width@large/1.65,\libx@taskbox@border@width@large) --
++(\libx@taskbox@border@width@large/1.65,-\libx@taskbox@border@width@large) -- cycle;
\end{scope}
}},%
extras last={overlay={%
\begin{scope}[shift={(frame.north)},yshift=.125cm]
\path[fill=tskcolor] (0,0) -- ++(\libx@taskbox@border@width@large/1.65,\libx@taskbox@border@width@large) --
++(\libx@taskbox@border@width@large/1.65,-\libx@taskbox@border@width@large) -- cycle;
\end{scope}
}},%
extras unbroken={overlay={\libx@tsk@numfieldbox}},
before title pre={%
\label{@libx@tsk:\thelibx@tsk@ubnum@ @\thetcbcounter}%
\iflibx@tb@boxes@isbm@\pdfbookmark[1]{\libx@tb@boxes@boxnumber\ - #4}{libx@tb@boxes@@id@\thelibx@tsk@ubnum@ @\thetcbcounter}\fi},
fonttitle=\bfseries, #3,%
title={\small\strut#4}%
}
\providetranslation[to=German]{task}{aufgabe}
\providetranslation[to=German]{tasks}{aufgaben}
\providetranslation[to=German]{Task}{Aufgabe}
\providetranslation[to=German]{Tasks}{Aufgaben}
\libx@translateenv{tsk}{task}
% note if this order is wrong redef of '\tasksslistname' is needed
\libx@provide@translation{tasksslistname}{List of}{Tasks}
\libx@RegisterBoxPair%
% List tasks and emblem:
{tasks}{ltasks}{\tasksslistname}{\faStar}%
% color, style, id:
{tskcolor}{addon@\@libx@tskstyle @\@libx@tskstyle@suffix}{tsk}%
% environment name and Prefix:
{\@libx@tsk@envname}{\translate{Task}}
\endinput