summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/mycv/Doc/Chapters/Usage.tex
blob: b79a542827ee821556225b6ccc36cea518ca5eaf (plain)
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
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
% *****************************************************************************
\chapter{Usage}
\quotes{%
   “There are two ways to write error-free programs; only the third one works”%
}{Alan J. Perlis}
% *****************************************************************************

\section{Requirements}

When \textit{decorations} are not enabled and the \textit{default style} is not used, \classname
has, in addiction to \ctLaTeXe{} obviously, the following requirements:\codeskip
{\small{\begin{lstlisting}[firstnumber=1,numbers=none]
\RequirePackage{kvoptions} % for options
\RequirePackage{etextools} % for lists and other useful tools
\RequirePackage{ifthen}    % for \ifthenelse command
\RequirePackage{xstring}   % for string utilities
\RequirePackage{svn-prov}  % for file info extracted from SVN
\RequirePackage{hyperref}  % for hypertext links and other stuff
\end{lstlisting}}}\codeskip

Besides, if the default style is used, by means of the class option
``\textit{style}''~\myref{sec:class-options}, this class requires (in addiction to
\textit{hyperref} and \textit{svn-prov}):\codeskip
{\small{
\begin{lstlisting}[firstnumber=1,numbers=none]
\RequirePackage{xparse}    % for commands with multiple default arguments
\RequirePackage{pifont}    % for ding style (itemize environment)
\RequirePackage{titlesec}  % for title format and spacing
\RequirePackage{fancyhdr}  % for custom footer
\RequirePackage{xcolor}    % for color
\RequirePackage{calligra}  % for calligra font
\RequirePackage{times}     % times font
\RequirePackage{marvosym}  % symbols - phone
\RequirePackage{amssymb}   % symbols - email
\end{lstlisting}}}\codeskip

Finally, if decorations are enabled, by using the class
option ``\textit{withDec}``~\myref{sec:class-options}, this class also requires (in addiction
to \textit{svn-prov} and \textit{xparse}):\codeskip
{\small{
\begin{lstlisting}[firstnumber=1,numbers=none]
\RequirePackage{tikz}      % for graphics
\end{lstlisting}}}\codeskip

\section{Class options}
\label{sec:class-options}

\classname can use any option supported by the \textit{article} class, on which is based. In
addiction, it provides the following options:
\def\tmpcolor{brown}
\squishlist
\item {\color{red}language=<\argname[\tmpcolor]{string}>}
   \begin{myindent}
   string language to pass to the \textit{babel} package for the document (\CV) language;
   \end{myindent}
\item {\color{red}cntdir=<\argname[\tmpcolor]{dirname}>}
   \begin{myindent}
   sets the directory name where \classname will search for files with the \CV contents.\\
   The default one is ``Contents'';
   \end{myindent}
\item {\color{red}style=<\argname[\tmpcolor]{filemane}>}
   \begin{myindent}
   specifies the file name (with or without the extension ``.sty'') containing the style commands.
   By default, the file \textit{mycv\_style.sty}, provided by the class itself, is that used.
   It is also possible to not use any file by specifying the value ``none'' as file name;
   \end{myindent}
\item {\color{red}mdlname=<\argname[\tmpcolor]{name}>}
   \begin{myindent}
   registers a name for the layout (model) intended to be used: in this way is possible, for
   example, to select the appropriate layout configuration file or a layout-specific portion of
   code;
   \end{myindent}
\item {\color{red}withDec}
   \begin{myindent}
   enables support for decorations (provided by the \textit{TikZ} package).
   \end{myindent}
\squishend

\section{Class commands}

Here follows the complete list of the commands provided by \classname. The style commands
%~\myref{sub:style-commands}
are only available if the class option ``\textit{style}'' was used~\myref{sec:class-options}. The
same goes for the decoration commands,
%~\myref{sub:decoration-commands}
which need the class option ``\textit{withDec}'' to be used. In the following text of this section,
when present, the form {\color{blue}\omissis} (or {\color{blue}<...>}) indicates the default choice
for an optional argument of a command.

\subsection{Conditionals}

\squishlist
\item \cmdname{ifoption}
   \marg{option}\arghsep
   \marg{true}\arghsep\marg{false}\argvsep
   \cmdname{ifmodel}
   \marg{mdlname}\arghsep
   \marg{true}\arghsep\marg{false}\cmddsep
   \textit{ifoption} checks whether \argname{option} was used,
   while \textit{ifmodel} checks whether \argname{mdlname} was registered in the class; then both
   commands use the appropriate \argname{true} or \argname{false} block of code.
\squishend

\subsection{Default style}
\label{sub:style-commands}

\squishlist
\item \cmdname{mysectionTitleFormat}
   \begin{myindent}
   \dargone{titlerule-color-above}{myheadingscolor}\argvsep
   \dargone{titlerule-color-below}{myheadingscolor}
   \end{myindent}\cmddsep
   \argname{titlerule-color-above} is the color for the rule above a section name, while
   \argname{titlerule-color-below} is for that below. \textit{myheadingscolor} is the default color.
\item \cmdname{mysectionTitleSpacing}
   \begin{myindent}
   \dargone{left}{$0\text{pt}$}\arghsep
   \dargone{beforesep}{$0\text{pt}$}\arghsep
   \dargone{aftersep}{$5\text{pt}$}
   \end{myindent}\cmddsep
   this command is just an alias for
   \textit{\textbackslash{titlespacing}\{\textbackslash{section}\}\{\argname{left}\}%
   \{\argname{beforesep}\}\{\argname{aftersep}\}}. See the \textit{titlesec} package for further
   information.
\item \cmdname{mycfoot}
   \marg{text}\cmddsep
   adds \argname{text} to the page footer. It may be useful, for example, to show information
   about the last document update.% (\textbackslash{}mycfoot\{Last update \textbackslash{}today\}).
\item \cmdname{myitemize}
   \cmddsep
   a list environment that uses the \textit{ding} style.
\squishend

\subsection{Decorations}
\label{sub:decoration-commands}

\classname provides some commands for using the \textit{TikZ} decorations. The support
provided is not complete at all (on the other hand \textit{TikZ} has a huge amount of
functionality), but is enough for this class purposes. The only \textit{TikZ} path supported is
\textit{rectangle}.
%\\ Here follows the provided commands list:

\squishlist
\item \cmdname{mydecorationsPathmorphing}[*]
   \begin{myindent}
   \dargone{show-decoration}{$1$}\argvsep
   \marg{decoration-type}\argvsep
   \dargone{decoration-color}{gray}\argvsep
   \dargtwo{shading-type}{radial}\argvsep
   \dargtwo{background-color}{white}%
   \end{myindent}\cmddsep
   \argname{show-decoration}, if equals $1$, does show the decoration \argname{decoration-type},
   while if $0$ does not.
   \textit{Starred} version uses the shading technique, unlike the \textit{not starred} one, and the
   last argument is the background shading color.\\
   For \textit{not starred} version, the argument \argname{shading-type} is not considered
   (just for a matter of clarity, a ``none'' value may be used), and the last argument is simply the
   background color.\\
   \argname{decoration-type} was tested with the following values: ``shape'', ``straight'',
   ``zigzag``, ``random steps``, ``saw``, ``bent``, ``bumps``, ``coil``, ``snake'' and
   ``Koch snowflake``.\\
   \argname{shading-type} was tested with ``radial'' and ``ball'' shadings.
\item \cmdname{mydecorationsShape}
   \begin{myindent}
   \dargone{show-decoration}{$1$}\arghsep
   \marg{decoration-type}\arghsep
   \dargone{decoration-color}{gray}
   \end{myindent}\cmddsep
   \argname{show-decoration}, if equals $1$, does show the decoration \argname{decoration-type},
   while if $0$ does not.
   \argname{decoration-type} was tested with the following ones: ``dart'', ``diamond'',
   ``rectangle'' and ``star''.
\item \cmdname{mydecorationsFading}
   \begin{myindent}
   \dargone{path-fading}{north}\argvsep
   \marg{primary-color}\argvsep
   \dargone{color-gradient}{$80$}\argvsep
   \dargone{secondary-color}{black}\argvsep
   \dargtwo{opacity}{$1.0$}%
   \end{myindent}\cmddsep
   the resulting fill color is given by \argname{primary-color}, \argname{color-gradient}
   and \argname{secondary-color}, which are composed as follows:
   \argname{primary-color}!\argname{color-gradient}!\argname{secondary-color}.
\item \cmdname{mydecorationsSetPos[XTL|YTL|XBR|YBR]}
   \begin{myindent}
   \dargone{coordinate-value}{$1\text{cm}\mid-1\text{cm}\mid-1\text{cm}\mid1\text{cm}$}
   \end{myindent}\cmddsep
   sets the position for the decoration in use. Since the decoration path is \textit{rectangle}, it
   is sufficient to have the $(x,y)$ coordinates of two points: the top-left and bottom-right.
   \textit{XTL} stands for ``\texttt{X-Top-Left}'', \textit{XBR} for ``\texttt{X-Bottom-Right}''
   and so on.
\item
   \cmdname{mydecorationsSetLineWidth}[*]
   \dargone{line-width}{tikz value}\cmdvsep
   \cmdname{mydecorationsSetSegmentAmplitude}[*]
   \dargone{segment-amplitude}{tikz value}\cmdvsep
   \cmdname{mydecorationsSetSegmentLength}[*]
   \dargone{segment-length}{tikz value}\cmddsep
   these commands may respectively be used for modifying the properties \argname{line-width},
   \argname{segment-amplitude} and \argname{segment-length} for the decoration in use.
   \textit{Starred} versions do not require any argument and reinitialize the properties to their
   default values.
\squishend

\subsection{Miscellaneous}

\squishlist
\item
   \cmdname{mypdfauthor}
   \marg{author}\cmdvsep
   \cmdname{mypdftitle}
   \marg{title}\cmdvsep
   \cmdname{mypdfsubject}
   \marg{subject}\cmddsep
   these commands do nothing but register \argname{author}, \argname{title} and \argname{subject}
   information in the document properties of the pdf is being produced.

\item \cmdname{mylang}
   \marg{text}\arghsep
   \dargone{language}{english}\cmddsep
   temporarily changes the language in use (\textit{babel} package) to \argname{language} for
   \argname{text}.

\item \cmdname{mychangemargin}
   \marg{left-margin}\arghsep
   \marg{right-margin}\cmddsep
   \textit{mychangemargin} environment changes the left and right margin of a portion of
   text. The environments \textit{mychangemarginLeft} and \textit{mychangemarginRight}, whose
   meaning is straight forward, are also available.

\item \cmdname{myrenderlayout}
   \dargone{component}{a}\cmddsep
   processes and draws the layout component(s). The option value ``h'' is for the header component,
   ``b'' and ``f'', respectively, for the body and footer ones, while ``a'' is for all components.
\squishend

\section{An example}

This section gives a \textit{minimal} example and some considerations about the use of \classname
(the class permits to do much better with a little patience). This is done by creating two
\textit{curriculum vit\ae{}} with the same contents, but different layouts: one \CV will use a
double page layout (abbreviated \DPL from here forward), while the other will use a single page
layout (\SPL).

The sample code presented here can be found in the ``Examples'' directory shipped with the
\textit{mycv} bundle, which this document is part of, and that also contains files with the \CV
contents: these files are not listed in the present document, as they do not contain anything worth
being mentioned for the purpose of these notes.

First and foremost, to keep the code organized, we need a file containing the layout components
for the \DPL (\textit{model-dpl.tex}) and another one for the \SPL (\textit{model-spl.tex}).
We opt for having the header and footer components being shared, so we create a third file named
\textit{model-common.tex}, such as in listing~\ref{lst:model-common}:
\begin{lstlisting}[firstnumber=1,caption=model-common.tex,label=lst:model-common]
\def\headerlayoutlist{%
   &MainHeaderPageBegin&:<postcmd:vspace=10pt>,
      % --------------------------------- left header
      |SubHeaderPageBegin|:<precmd:hfill>,
         $header_title@$,    % header file one
      |SubHeaderPageEnd|:<postcmd:hfill>,
      % --------------------------------- right header
      |SubHeaderPageBegin|,
         $header_contacts@$, % header file two
      |SubHeaderPageEnd|,
   &MainHeaderPageEnd&%
}
\def\footerlayoutlist{footer_sign@} % footer file
\end{lstlisting}
\codeskip

Now we can deal with the layout components specific for the \DPL (\textit{model-dpl.tex}),
as in listing~\ref{lst:dplmodel}.
%\lstinputlisting[firstnumber=1,caption=model-dpl.tex,label=lst:dplmodel]{
%../Examples/Models/model-dpl.tex}
\begin{lstlisting}[firstnumber=1,caption=model-dpl.tex,label=lst:dplmodel]
\input{Models/model-common}
\def\bodylayoutlist{%
   % ---------------------------------------------------------
   % moves the right margin to the left (text and title rules)
   % ---------------------------------------------------------
   &MainBodyPageBegin&:<0.96>,
      % ---------------------------------------------------------
      % the 2 directives below are just used as a trick to do the
      % same thing for the left margin (it is moved to the right)
      % ---------------------------------------------------------
      |SubBodyPageBegin|,
      |SubBodyPageEnd|,
      % -----------------------------------------
      % left page (0.48 of textwidth)
      % -----------------------------------------
      |SubBodyPageBegin|:<0.48>,
         $contents_partA@$:<precmd:vspace=10pt:sectionnumber=1>,
         $contents_partB@$:<precmd:vspace=10pt:sectionnumber=2>,
         $contents_partC@$:<precmd:vspace=10pt:sectionnumber=3>,
      |SubBodyPageEnd|:<postcmd:hfill>,
      % -----------------------------------------
      % right page (0.48 of textwidth)
      % -----------------------------------------
      |SubBodyPageBegin|:<0.48>,
         $contents_partA@$:<precmd:vspace=10pt:sectionnumber=4>,
         $contents_partB@$:<precmd:vspace=10pt:sectionnumber=5>,
      |SubBodyPageEnd|,
      % -----------------------------------------
   &MainBodyPageEnd&%
}
\end{lstlisting}
\codeskip

%The directive colored in red moves the right margin to the left (text and title rules) while the
%directives in orange are just used as a trick to do the same thing for the left margin (that is
%moved to the right):\codeskip
%\begin{lstlisting}[firstnumber=1,numbers=none]
%&MainBodyPageBegin&:<0.96>
%|SubBodyPageBegin|,
%|SubBodyPageEnd|,
%\end{lstlisting}

As far as the \DPL, we have done; we still have to deal with the layout components specific for
the \SPL (\textit{model-spl.tex}). In this case, we do not need to use the \verb|*PageBegin|
components, but it is sufficient to directly include the files with the contents. The resulting code
is showed in listing~\ref{lst:splmodel}.
%\lstinputlisting[firstnumber=1,caption=model-spl.tex,label=lst:splmodel]{
%../Examples/Models/model-spl.tex }\codeskip
\begin{lstlisting}[firstnumber=1,caption=model-spl.tex,label=lst:splmodel]
\input{Models/model-common}
\def\bodylayoutlist{%
   % ---------------------------------------------------
   $contents_partA@$:<precmd:vspace=10pt:sectionnumber=1>,
   $contents_partB@$:<precmd:vspace=10pt:sectionnumber=2>,
   $contents_partC@$:<precmd:vspace=10pt:sectionnumber=3>,
   $contents_partA@$:<precmd:vspace=10pt:sectionnumber=4>,
   $contents_partB@$:<precmd:vspace=10pt:sectionnumber=5>
   % ---------------------------------------------------
}
\end{lstlisting}
\codeskip

At this point, we both have the components for the double and single page layouts and we can
proceed writing the main files (\textit{mycv-example-dpl.tex} and \textit{mycv-example-spl.tex})
that pick and use them.\\
We start by setting up some options for the %\classname
class; we have chosen to store the \CV contents files in the directory ``Contents'' (that is the
default one where the class searches for the contents files), so there is not need to specify the
path with the option ``\textit{cntdir}''~\myref{sec:class-options}.
\\
The options we want to pass to the class are those related to the decorations and language support;
in addiction, we pass the name of the layout (model) we mean to use.
% (see the listings~~\ref{lst:dplmodel} or~\ref{lst:splmodel}).
\\
Here we take the \DPL as an example (listing~\ref{lst:mycv-example-dpl}), but switching to the
\SPL would just be a matter of changing the ``\textit{mdlname}'' option from \keyword{verDPL} to
\keyword{verSPL}.
\begin{lstlisting}[firstnumber=1,label=lst:mycv-example-dpl,caption=mycv-example-dpl.tex]
\documentclass[10pt,mdlname=verDPL,withDec,language=english]{mycv}
\input{mycv-example-common}

\begin{document}
\cvdec\myrenderlayout\mycfoot{Last update: \today}
\end{document}
\end{lstlisting}\codeskip

The input file \textit{mycv-example-common[.tex]}, showed in listing~\ref{lst:example-common},
selects the appropriate layout components (\ref{lst:dplmodel} or \ref{lst:splmodel}) to be included
(\textit{\textbackslash{}ifmodel} conditional command), which will be subsequently processed by
the command \textit{\textbackslash{}myrenderlayout}.\\
%showed in listing~\ref{lst:example-common}. Since this portion of code is shared between
%\textit{mycv-example-dpl.tex} and \textit{mycv-example-spl.tex}, we need to use
%\textit{\textbackslash{}ifmodel} for selecting the right file to be included.
In addiction, that file contains some decoration commands, which need to be picked up only when the
class option ``\textit{withDec}' is being used; this is the reason why the conditional command
\textit{\textbackslash{}ifoption} is also used.
\begin{lstlisting}[firstnumber=1,caption=mcv-example-common.tex,label=lst:example-common]
[...]
\ifoption{withDec}{%
   \newcommand{\cvdec}{
      \mydecorationsSetLineWidth[0.3mm]%
      \mydecorationsPathmorphing*{coil}<radial><lightgray>
   }%
}{\newcommand{\cvdec}{}}

\ifmodel{verSPL}{\input{Models/model-spl}[...]}{\relax}
\ifmodel{verDPL}{\input{Models/model-dpl}[...]}{\relax}
[...]
\end{lstlisting}
%\lstinputlisting[firstnumber=1,caption=mcv-example-common.tex,label=lst:example]{
%../Examples/mycv-example-common.tex}

\section{Split the contents}

When a double layout page is used, it may occur, for example, that a section is too long for a
page: this would not be a problem with a single layout page, since \LaTeX{} would automatically
break the section contents. Unfortunately, with a double page layout the behavior is substantially
different: this is because \classname uses a \textit{minipage-based mechanism} and a minipage is by
itself not breakable. Thus, what happens is that part of the section contents comes out from the
margins, without being displayed.

When a problem such as this occurs, a possible workaround is to manually break the section contents.
This can be done by using a counter that keeps track of the number of times a same file is included:
when the counter is equal $1$, a part of the section contents is included in the left page,
otherwise is the remaining one to be included in the right page.
Listing~\ref{lst:split-contents-example} shows a practical example of what just discussed.
\begin{lstlisting}[firstnumber=1,label=lst:split-contents-example,caption=split-contents-example]
% ---------------------------------------------------------
% file with the section contents: i.e. <section_skills.tex>
% ---------------------------------------------------------

% increases the counter 'acounter'
% (it's defined outside this file)
\stepcounter{acounter}

\newcommand{\conditionalblock}[2]{%
   \ifthenelse{\value{acounter}<2}{#1}{#2}%
}

% selects the appropriate part of the file contents
\conditionalblock%
   {skills section contents part A}%
   {skills section contents part B (the remaining part)}

% --------------------------------------------------
% file with the DPL components: i.e. <model-dpl.tex>
% --------------------------------------------------

\def\bodylayoutlist{%
   |SubBodyPageBegin|:<0.48>, % left page
      % include part A in the left page
      $section_skills@$,
      [...]
   |SubBodyPageEnd|,
   |SubBodyPageBegin|:<0.48>, % right page
      % include part B in the right page
      $section_skills@$,
      [...]
   |SubBodyPageEnd|
}
\end{lstlisting}\codeskip

Of course the proposed workaround is not the best we could wish for, since it requires manual
operations.\\% (any advice about that is greatly appreciated).\\
As an alternative, it is possible to not use the \verb|*PageBegin| and \verb|*PageEnd| mechanism,
delegating the double page layout to an external package (i.e. \textit{multicols}).
This kind of approach is showed in listings~\ref{lst:model-dpl2} and~\ref{lst:mycv-example-dpl2}.
%(respectively files \textit{model-dpl2.tex} and \textit{mycv-example-dpl2.tex}).
\bigskip
%\lstinputlisting[firstnumber=1,caption=model-dpl2.tex,label=lst:model-dpl2]{
%../Examples/Models/model-dpl2.tex }
\begin{lstlisting}[firstnumber=1,caption=model-dpl2.tex,label=lst:model-dpl2]
\input{Models/model-common}

\newcommand{\mcbegin}{\begin{multicols}{2}}
\newcommand{\mcend}{\end{multicols}}

\def\bodylayoutlist{%
    $contents_partA@$:<precmd:vspace=10pt:mcbegin:sectionnumber=1>,%
    $contents_partB@$:<precmd:vspace=10pt:sectionnumber=2>,%
    $contents_partA@$:<precmd:vspace=10pt:sectionnumber=3>,%
    $contents_partC@$:<precmd:vspace=10pt:sectionnumber=4>,%
    $contents_partA@$:<precmd:vspace=10pt:sectionnumber=5>,%
    $contents_partB@$:<precmd:vspace=10pt:sectionnumber=6>:%
      <postcmd:mcend>,%
}
\end{lstlisting}\codeskip

Notice the usage of the commands \textit{\textbackslash{mcbegin}} and
\textit{\textbackslash{mcend}}, which act as a wrapper for the \textit{multicols} environment.

\lstinputlisting[firstnumber=1,label=lst:mycv-example-dpl2,caption=mycv-example-dpl2.tex]{
../Examples/mycv-example-dpl2.tex}
\codeskip

\bigskip\bigskip
That's all, {\color{brown}happy \LaTeX{}ing!}\\[5pt]
\Large\calligra{AndreaGhersi}