forked from mateuszbaransanok/BubbleCV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bubblecv.sty
434 lines (394 loc) · 18.8 KB
/
bubblecv.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
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
%========================================================================================
% PARAMETERS
%========================================================================================
%----------------------------------------------------------------------------------------
% CV SCALE
%----------------------------------------------------------------------------------------
\newcommand\cvscale{1}
%----------------------------------------------------------------------------------------
% FONT
%----------------------------------------------------------------------------------------
\newcommand\cvfont{ppl}
\newcommand\cvheadertitlefontscale{2.25}
\newcommand\cvheadersubtitlefontscale{1.5}
\newcommand\cvsectionfontscale{1.75}
\newcommand\cvnamefontscale{1.25}
\newcommand\cvdescriptionfontscale{1}
%----------------------------------------------------------------------------------------
% MARGIN
%----------------------------------------------------------------------------------------
\newcommand\cvheadermargin{5}
\newcommand\cvtopmargin{10}
\newcommand\cvbottommargin{10}
\newcommand\cvleftmargin{35}
\newcommand\cvrightmargin{10}
%----------------------------------------------------------------------------------------
% HEADER
%----------------------------------------------------------------------------------------
\newcommand\cvavatarradius{20}
\newcommand\cvavatarborderwidth{1}
\newcommand\cvheaderoffset{5}
%----------------------------------------------------------------------------------------
% TIMELINE
%----------------------------------------------------------------------------------------
\newcommand\cvtimelineoffset{25}
\newcommand\cvtimelinewidth{0.5}
%----------------------------------------------------------------------------------------
% MAIN
%----------------------------------------------------------------------------------------
\newcommand\cvmainspace{3}
\newcommand\cvmainbubbleradius{6}
\newcommand\cvmainbubbleborderwidth{1}
%----------------------------------------------------------------------------------------
% EVENT
%----------------------------------------------------------------------------------------
\newcommand\cveventdatewidth{16}
\newcommand\cveventbubbleradius{3}
\newcommand\cveventbubbleborderwidth{1}
%----------------------------------------------------------------------------------------
% SIDEBAR
%----------------------------------------------------------------------------------------
\newcommand\cvsidebarspace{3}
\newcommand\cvsidebarbubbleradius{6}
\newcommand\cvsidebarbubbleborderwidth{1}
\newcommand\cvsidebaroffset{2}
%----------------------------------------------------------------------------------------
% COLUMN
%----------------------------------------------------------------------------------------
\newcommand\cvcolumnratio{0.6}
\newcommand\cvspacebetweencolumns{12}
%----------------------------------------------------------------------------------------
% SEPARATOR
%----------------------------------------------------------------------------------------
\newcommand\cvseparatorscale{1}
%----------------------------------------------------------------------------------------
% COLORS
%----------------------------------------------------------------------------------------
\usepackage{xcolor}
\definecolor{cvcolor}{RGB}{20, 20, 20} % main color
\definecolor{cviconcolor}{RGB}{255, 255, 255} % icon color
\definecolor{cvbordercolor}{RGB}{255, 255, 255} % border color
\definecolor{cvavatarbordercolor}{RGB}{255, 255, 255} % avatar border color
\definecolor{cvtimelinecolor}{RGB}{0, 0, 0} % timeline color
\definecolor{cvlightcolor}{RGB}{245, 245, 245} % light color
%========================================================================================
% CONFIGURATION
%========================================================================================
%----------------------------------------------------------------------------------------
% RESCALE
%----------------------------------------------------------------------------------------
\usepackage{fp}
\FPeval{\cvavatarradius}{\cvscale*\cvavatarradius}
\FPeval{\cvavatarborderwidth}{\cvscale*\cvavatarborderwidth}
\FPeval{\cvmainspace}{\cvscale*\cvmainspace}
\FPeval{\cvmainbubbleradius}{\cvscale*\cvmainbubbleradius}
\FPeval{\cvmainbubbleborderwidth}{\cvscale*\cvmainbubbleborderwidth}
\FPeval{\cveventdatewidth}{\cvscale*\cveventdatewidth}
\FPeval{\cveventbubbleradius}{\cvscale*\cveventbubbleradius}
\FPeval{\cveventbubbleborderwidth}{\cvscale*\cveventbubbleborderwidth}
\FPeval{\cvsidebarspace}{\cvscale*\cvsidebarspace}
\FPeval{\cvsidebarbubbleradius}{\cvscale*\cvsidebarbubbleradius}
\FPeval{\cvsidebarbubbleborderwidth}{\cvscale*\cvsidebarbubbleborderwidth}
\FPeval{\cvseparatorscale}{\cvscale*\cvseparatorscale}
%----------------------------------------------------------------------------------------
% SETTINGS
%----------------------------------------------------------------------------------------
\newcommand\packagename{bubblecv}
\usepackage[a4paper]{geometry}
\geometry{top=\cvtopmargin mm, bottom=\cvbottommargin mm, left=\cvleftmargin mm, right=\cvrightmargin mm}
\setlength{\topskip}{0mm} % no top margin default
\setlength{\parindent}{0mm} % no indent default
\pagenumbering{gobble} % disable page numbering
\usepackage{enumitem}
\setlist[itemize]{noitemsep, nolistsep, leftmargin=*} % default list style
%----------------------------------------------------------------------------------------
% COMMON PACKAGES
%----------------------------------------------------------------------------------------
\usepackage[utf8]{inputenc} % for utf-8 encoding
\usepackage{xparse} % new document command
\usepackage{ifthen} % if then else
\usepackage{tabularx} % tabular for progress bar
\usepackage{hyperref} % hyper ref
%----------------------------------------------------------------------------------------
% COLUMNS
%----------------------------------------------------------------------------------------
\usepackage{paracol}
\setlength{\columnsep}{\cvspacebetweencolumns mm} % space between columns
\newcommand\iscvsidebar{0} % flag if sidebar is active
%----------------------------------------------------------------------------------------
% FONTS & ICONS
%----------------------------------------------------------------------------------------
\usepackage{relsize} % for font scaling
\usepackage{fontawesome}
% allow icons to scale
\DeclareFontFamily{U}{fontawesomeOne}{}
\DeclareFontShape{U}{fontawesomeOne}{m}{n}{<-> FontAwesome--fontawesomeone}{}
\DeclareRobustCommand\FAone{\fontencoding{U}\fontfamily{fontawesomeOne}\selectfont}
%----------------------------------------------------------------------------------------
% TIMELINE
%----------------------------------------------------------------------------------------
\usepackage{silence}
\WarningsOff[everypage] % disable warning about problems with background package
\usepackage{background}
\SetBgScale{1}
\SetBgAngle{0}
\SetBgColor{cvtimelinecolor}
\SetBgContents{\rule{\cvtimelinewidth mm}{\textheight}}
% start offset from left edge of a4 paper instead of center
\SetBgHshift{\dimexpr(\cvtimelineoffset mm - 105 mm)}
\newcommand{\timelinespace}{\the\numexpr\cvleftmargin - \cvtimelineoffset\relax}
%----------------------------------------------------------------------------------------
% FOOTNOTE
%----------------------------------------------------------------------------------------
\setlength{\skip\footins}{0.25\baselineskip}
%----------------------------------------------------------------------------------------
% RGB TO ARRAY
%----------------------------------------------------------------------------------------
% Convert RGB to decode array.
% Parameter 1: RGB color.
% Parameter 2: Variable to which the array will be assigned.
\newcommand{\rgbtoarray}[2]{%
\extractcolorspecs{#1}\ParseResultModel\ParseResultColor%
\convertcolorspec\ParseResultModel\ParseResultColor{rgb}\ParseRgb%
\let#2\@empty%
\@for\ParseValue:=\ParseRgb\do{%
\edef#2{%
#2%
\ifx#2\@empty%
\else%
\space%
\fi%
\ParseValue\space 1%
}%
}%
}%
%----------------------------------------------------------------------------------------
% DRAW CIRCLE
%----------------------------------------------------------------------------------------
% Draw a circle with the image inside.
% Parameter 1 (optional): Path to image resource.
% Parameter 2 (optional): Image scale.
% Parameter 3 (optional): Image color in RGB.
% Parameter 4: Circle radius in millimeters.
% Parameter 5: Circle border width in millimeters.
% Parameter 6: Circle background color in RGB.
% Parameter 7: Circle border color in RGB.
\NewDocumentCommand{\drawcircle}{O{} O{1} O{} m m m m}{%
\ifthenelse{\equal{#3}{}}{}{%
\rgbtoarray{#3}\customdecodearray%
}{}%
\begin{tikzpicture}%
\draw[%
draw=#7, fill=#6, line width=#5mm,%
path picture={%
\ifthenelse{\equal{#1}{}}{}{%
\node at (path picture bounding box.center){%
\ifthenelse{\equal{#3}{}}{%
\includegraphics[%
width=#2\dimexpr#4mm\relax,%
height=#2\dimexpr#4mm\relax]{#1}%
}{%
\includegraphics[%
width=#2\dimexpr#4mm\relax,%
height=#2\dimexpr#4mm\relax,%
decodearray={\customdecodearray}]{#1}%
}%
};%
}%
}%
] (0,0) circle (\dimexpr#4mm-#5mm/2\relax);%
\end{tikzpicture}%
}%
%========================================================================================
% PUBLIC FUNCTIONS
%========================================================================================
%----------------------------------------------------------------------------------------
% CV
%----------------------------------------------------------------------------------------
% Main CV function that prepares the entire layout.
% Parameter 1 (optional): Path to avatar resource.
% Parameter 2 (optional): Avatar scale.
% Parameter 3 (optional): Avatar color in RGB.
% Parameter 4: Name.
% Parameter 5: Description.
\NewDocumentEnvironment{cv}{O{} O{2} O{} m m}{%
\relscale{\cvscale}%
\fontfamily{\cvfont}%
\vspace*{\cvheadermargin mm}%
\vspace*{-\cvtopmargin mm}%
\hspace{-\timelinespace mm}%
\hspace{-\cvavatarradius mm}%
\begin{minipage}{\dimexpr(\cvavatarradius mm + \cvavatarradius mm)}%
\protect\ifthenelse{\equal{#1}{}}%
{\drawcircle{\cvavatarradius}{\cvavatarborderwidth}{cvcolor}{cvavatarbordercolor}}%
{\drawcircle[resources/#1][#2][#3]{\cvavatarradius}{\cvavatarborderwidth}{cvcolor}{cvavatarbordercolor}}%
\end{minipage}%
\hspace{\cvheaderoffset mm}%
\begin{minipage}{\dimexpr(\linewidth + \timelinespace mm - \cvavatarradius mm - \cvheaderoffset mm)}%
\textscale{\cvheadertitlefontscale}{#4}%
\cvseparator[3]%
\textscale{\cvheadersubtitlefontscale}{#5}%
\end{minipage}%
\columnratio{\cvcolumnratio}%
\begin{paracol}{2}%
}{%
\end{paracol}%
}%
%----------------------------------------------------------------------------------------
% CV SECTION
%----------------------------------------------------------------------------------------
% Groups events, items and skills inside one block.
% Parameter 1 (optional): Path to icon resource.
% Parameter 2 (optional): Icon scale.
% Parameter 3 (optional): Icon color in RGB.
% Parameter 4: Section title.
\NewDocumentCommand{\cvsection}{O{} O{1} O{cviconcolor} m}{%
\ifthenelse{\equal{\iscvsidebar}{0}}{%
\vspace{\cvmainspace mm}%
\hspace{-\timelinespace mm}%
\hspace{-\cvmainbubbleradius mm}%
\begin{minipage}{\dimexpr(\cvmainbubbleradius mm + \cvmainbubbleradius mm)}%
\ifthenelse{\equal{#1}{}}%
{\protect\drawcircle{\cvmainbubbleradius}{\cvmainbubbleborderwidth}{cvcolor}{cvbordercolor}}%
{\protect\drawcircle[resources/#1][#2][#3]{\cvmainbubbleradius}{\cvmainbubbleborderwidth}{cvcolor}{cvbordercolor}}%
\end{minipage}%
\hspace{\dimexpr(\timelinespace mm - \cvmainbubbleradius mm)}%
\begin{minipage}{\linewidth}%
\textscale{\cvsectionfontscale}{\textbf{#4}}%
\end{minipage}%
\cvseparator%
}{%
\vspace{\cvsidebarspace mm}%
\hspace{-\cvsidebarbubbleradius mm}%
\begin{minipage}{\dimexpr(\cvsidebarbubbleradius mm + \cvsidebarbubbleradius mm)}%
\protect\ifthenelse{\equal{#1}{}}%
{\drawcircle{\cvsidebarbubbleradius}{\cvsidebarbubbleborderwidth}{cvcolor}{cvbordercolor}}%
{\drawcircle[resources/#1][#2][#3]{\cvsidebarbubbleradius}{\cvsidebarbubbleborderwidth}{cvcolor}{cvbordercolor}}%
\end{minipage}%
\hspace{\cvsidebaroffset mm}%
\begin{minipage}{\dimexpr(\linewidth - \cvsidebarbubbleradius mm - \cvsidebaroffset mm)}%
\textscale{\cvsectionfontscale}{\textbf{#4}}%
\end{minipage}%
\cvseparator%
}%
}%
%----------------------------------------------------------------------------------------
% CV EVENT
%----------------------------------------------------------------------------------------
% Contains information about the event.
% Parameter 1 (optional): Start date of the event.
% Parameter 2 (optional): End date of the event.
% Parameter 3: Content.
\NewDocumentEnvironment{cvevent}{O{} O{} +b}{%
\ifthenelse{\equal{\iscvsidebar}{0}}{%
\hspace{-\cveventbubbleradius mm}%
\hspace{-\timelinespace mm}%
\hspace{-\cveventdatewidth mm}%
\begin{minipage}[t]{\cveventdatewidth mm}%
\begin{center}%
\ifthenelse{\equal{#2}{}}{%
\ifthenelse{\equal{#1}{}}{}{%
\textbf{#1}\par%
}%
}{%
\textbf{#2}\par%
\textbf{$\uparrow$}\par%
\textbf{#1}%
}%
\end{center}%
\end{minipage}%
\begin{minipage}{\dimexpr(\cveventbubbleradius mm + \cveventbubbleradius mm)}%
\protect\drawcircle{\cveventbubbleradius}{\cveventbubbleborderwidth}{cvcolor}{cvbordercolor}%
\end{minipage}%
\hspace{\dimexpr(\timelinespace mm - \cveventbubbleradius mm)}%
\begin{minipage}[t]{\linewidth}%
#3%
\end{minipage}%
\par%
}{%
\PackageError{\packagename}{The cvevent can be used only in the main column}{}%
}%
}{}%
%----------------------------------------------------------------------------------------
% CV SEPARATOR
%----------------------------------------------------------------------------------------
% Vertical space between paragraphs.
% Parameter 1 (optional): Space size in millimeters.
\NewDocumentCommand{\cvseparator}{O{1}}{\vspace{#1\dimexpr\cvseparatorscale mm\relax}\par}
%----------------------------------------------------------------------------------------
% CV NAME
%----------------------------------------------------------------------------------------
% The title of the event header.
% Parameter 1: Event title.
\newcommand{\cvname}[1]{\textscale{\cvnamefontscale}{\textbf{#1}}\cvseparator}
%----------------------------------------------------------------------------------------
% CV DESCRIPTION
%----------------------------------------------------------------------------------------
% The description of the event header.
% Parameter 1: Event description.
\newcommand{\cvdescription}[1]{\textscale{\cvdescriptionfontscale}{\textit{\textbf{#1}}}\cvseparator[2]}
%----------------------------------------------------------------------------------------
% CV SIDEBAR
%----------------------------------------------------------------------------------------
% Switches the main column to the sidebar.
\newcommand{\cvsidebar}[0]{%
\ifthenelse{\equal{\iscvsidebar}{0}}{%
\switchcolumn%
\renewcommand{\iscvsidebar}{1}%
}{%
\PackageError{\packagename}{The cvsidebar can be used only once}{}%
}%
}%
%----------------------------------------------------------------------------------------
% CV ITEM
%----------------------------------------------------------------------------------------
% List item with a label.
% Parameter 1 (optional): Icon name from fontawesome package.
% Parameter 2 (optional): Icon size in milimeters.
% Parameter 3: Content.
\NewDocumentEnvironment{cvitem}{O{Circle} O{2.5} +b}{%
\ifthenelse{\equal{\iscvsidebar}{1}}{%
\begin{minipage}{\cvscale\dimexpr#2mm\relax}%
\makebox(0, 0){\textcolor{cvcolor}{\fontsize{\cvscale\dimexpr#2mm\relax}{\cvscale\dimexpr#2mm\relax}\csname fa#1\endcsname}}%
\end{minipage}%
\hspace{\cvsidebaroffset mm}%
\begin{minipage}{\dimexpr(\linewidth - \cvsidebaroffset mm - \cvscale\dimexpr#2mm\relax)}%
#3%
\end{minipage}%
\par%
}{%
\PackageError{\packagename}{The cvitem can be used only in the sidebar column}{}%
}%
}{}%
%----------------------------------------------------------------------------------------
% CV SKILL
%----------------------------------------------------------------------------------------
% Renders a progress-bar to indicate a certain skill in percent.
% Parameter 1: Name of skill.
% Parameter 2: Skill level.
% Parameter 3: Percent of the progress-bar in range [0, 1].
\newcommand{\cvskill}[3]{%
\ifthenelse{\equal{\iscvsidebar}{1}}{%
\begin{tabularx}{\linewidth}{>{\raggedright\arraybackslash}X>{\raggedleft\arraybackslash}X}%
\textcolor{black}{\textbf{#1}} & \textcolor{cvcolor}{#2}%
\end{tabularx}%
\begin{tikzpicture}[scale=1,rounded corners=\cvscale*0.5mm,very thin]%
\fill [cvlightcolor] (0,0) rectangle (\linewidth, 0.15*\cvscale);%
\fill [cvcolor] (0,0) rectangle (#3\linewidth, 0.15*\cvscale);%
\end{tikzpicture}%
\cvseparator[2]%
}{%
\PackageError{\packagename}{The cvskill can be used only in the sidebar column}{}%
}%
}%
%----------------------------------------------------------------------------------------
% CV FOOTNOTE
%----------------------------------------------------------------------------------------
% Footnote without order number and hyperlink.
% Parameter 1: Footnote content.
\newcommand\cvfootnote[1]{%
\begingroup%
\renewcommand\thefootnote{}\NoHyper\footnote{#1}%
\addtocounter{footnote}{-1}%
\endgroup%
}%