-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathatombook.sty
More file actions
148 lines (139 loc) · 5 KB
/
Copy pathatombook.sty
File metadata and controls
148 lines (139 loc) · 5 KB
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
% atombook.sty
\ProvidesPackage{atombook}[2026/03/27 My simple package]
%%%%%%%%%% enumitem setup %%%%%%%%%%%%%
\usepackage{enumitem}
\newcommand*\squarednum[1]{\tikz[baseline=(char.base)]{\node[rectangle, draw, semithick, inner sep=0pt, minimum size = 1em, font=\sffamily] (char) {#1};}}
\setlist[enumerate]{label=\protect\squarednum{\arabic*},nosep}
%%%%%%%%%% plain tcolorbox setup %%%%%%%%%%%%
\usepackage[many]{tcolorbox}
% https://tex.stackexchange.com/a/747203
\tikzset{mybox frame/.style={tcbcolframe, line width=1.5pt}}
\tcbsubskin{mybox}{empty}{
frame engine=path,
attach boxed title to top left={xshift=.25cm,yshift=-.7\baselineskip},
boxed title style={
skin=empty,frame engine=path,
frame empty,
},
% frame code specific for unbroken boxes
frame code={
\draw[mybox frame]
(title.west) -| (frame.south west) -- (frame.south east) |- (title.east);
},
% frame code for broken boxes
skin first is subskin of={emptyfirst}{
frame code={
\draw[mybox frame]
(title.west) -| (frame.south west)
(frame.south east) |- (title.east);
}
},
skin middle is subskin of={emptymiddle}{
frame code={
\draw[mybox frame]
(frame.north east) -- (frame.south east)
(frame.north west) -- (frame.south west);
}
},
skin last is subskin of={emptylast}{
frame code={
\draw[mybox frame]
(frame.north east) -- (frame.south east)
-- (frame.south west) -- (frame.north west);
}
}
}
\NewTColorBox{mybox}{ O{} m }{
breakable, skin=mybox, top=.5cm,
before skip=.1cm,
after skip=.25cm,
before title={【},after title={】},
% before title={[\,},after title={\,]},
% colframe=green!75!black,
colframe=violet!85,
fonttitle=\bfseries\large,
title={#2},#1,
coltitle=tcbcolframe,% delay after #1
}
%%%%%%%%%%% margin chapter layout%%%%%%%%%%%%%%
\RequirePackage{tikz}
\usetikzlibrary{matrix}
% https://tex.stackexchange.com/a/761258
\ExplSyntaxOn
\tl_new:N \l_mwe_matrix_content_tl
\tl_new:N \l_atombook_node_fill_color
\tl_new:N \l_atombook_current_fill_color
\tl_new:N \l_atombook_node_draw_color
\tl_new:N \l_atombook_current_draw_color
\dim_new:N \l_atombook_block_size_dim
\dim_new:N \l_atombook_block_sep_dim
\tl_new:N \l_atombook_font_style_tl
% keys
\keys_define:nn { atombook }
{
node-fill .tl_set:N = \l_atombook_node_fill_color,
node-fill .initial:n = cyan,
current-fill .tl_set:N = \l_atombook_current_fill_color,
current-fill .initial:n = magenta,
node-draw .tl_set:N = \l_atombook_node_draw_color,
node-draw .initial:n = none,
current-draw .tl_set:N = \l_atombook_current_draw_color,
current-draw .initial:n = none,
block-size .dim_set:N = \l_atombook_block_size_dim,
block-size .initial:n = 1.2cm,
block-sep .dim_set:N = \l_atombook_block_sep_dim,
block-sep .initial:n = 0.5cm,
font .tl_set:N = \l_atombook_font_style_tl,
font .initial:n = { \sffamily\bfseries\Huge },
}
%
\NewDocumentCommand \marginblockset { m } {
\keys_set:nn { atombook } { #1 }
}
\property_new:nnnn { last-chapter } { now } { 1 } {
\arabic{chapter}
}
\hook_gput_code:nnn { enddocument } { . } {
\property_record:nn { atombook/matrix } { last-chapter }
}
\hook_gput_code:nnn { shipout/background } { . } {
\int_compare:nNnF{ \property_ref:nn { atombook/matrix } { last-chapter } } = {0} % add test for no chapter
{%
\int_step_inline:nn { \property_ref:nn { atombook/matrix } { last-chapter } } {
\int_compare:nNnT { #1 } = { \value{chapter} } {
\tl_put_right:Nn \l_mwe_matrix_content_tl { |[fill=\l_atombook_current_fill_color, draw=\l_atombook_current_draw_color]| }
}
\tl_put_right:Nn \l_mwe_matrix_content_tl { #1 \\ }
}
\begin{tikzpicture}[%
overlay,remember~picture,
marginpage/.style={%
matrix~of~nodes,
nodes={
align=center,
draw=\l_atombook_node_draw_color,
fill=\l_atombook_node_fill_color,
minimum~size=\l_atombook_block_size_dim,
font=\l_atombook_font_style_tl
},
row~sep=\l_atombook_block_sep_dim,
column~sep=0mm,
inner~sep=0pt,
outer~sep=0pt,
}%
]%
% \matrix[anchor=east,marginpage] at (current~page.east){\l_mwe_matrix_content_tl};
\if@twoside
\ifodd\value{page}\relax
\matrix[anchor=east,marginpage] at (current~page.east){\l_mwe_matrix_content_tl};
\else%
\matrix[anchor=west,marginpage] at (current~page.west){\l_mwe_matrix_content_tl};
\fi%
\else
\matrix[anchor=east,marginpage] at (current~page.east){\l_mwe_matrix_content_tl};
\fi
\end{tikzpicture}%
}%
}
\ExplSyntaxOff
\endinput