summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/moderncv/moderncvheadvii.sty
blob: f0c259ec0503caccd5a8e6e664d8d51de46486ab (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
%% start of file `moderncvheadvii.sty'.
%% Copyright 2006-2015 Xavier Danaux (xdanaux@gmail.com).
%% Copyright 2023 Javier Lopez-Gomez (javier.lopez.gomez@proton.me).
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License version 1.3c,
% available at http://www.latex-project.org/lppl/.


%-------------------------------------------------------------------------------
%                identification
%-------------------------------------------------------------------------------
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{moderncvheadvii}[2023/11/21 v2.0.0 modern curriculum vitae and letter header variant: 7]

% details options: "details" (default) or "nodetails"
\@initializeif{\if@details}\@detailsfalse
\DeclareOption{details}   {\@detailstrue}
\DeclareOption{nodetails} {\@detailsfalse}
% QR options: "qr" (default) or "noqr".  If "qr" is specified, a QR code is generated to point to the
% homepage and placed near the details section
\@initializeif{\if@headqr}\@headqrfalse
\DeclareOption{qr}   {\@headqrtrue}
\DeclareOption{noqr} {\@headqrfalse}

% left/right options: "left" (default) or "right"
\@initializeif{\if@left} \@leftfalse
\DeclareOption{left}    {\@lefttrue\@rightfalse}
\@initializeif{\if@right}\@rightfalse
\DeclareOption{right}   {\@leftfalse\@righttrue}

\DeclareOption*{}% avoid choking on unknown options
\ExecuteOptions{details,qr,left}
\ProcessOptions*\relax% \ProcessOptions* processes the options in the order provided (i.e., with the later ones possibly overriding the former ones), while \ProcessOptions processes them in the order of the package


%-------------------------------------------------------------------------------
%                required packages
%-------------------------------------------------------------------------------
\RequirePackage{qrcode}
\RequirePackage{tikz}
\usetikzlibrary{tikzmark,fit}


%-------------------------------------------------------------------------------
%                overall head definition
%-------------------------------------------------------------------------------
\@ifundefined{\string\color@headTL}{\colorlet{headTL}{color1}}{}
\@ifundefined{\string\color@headBR}{\colorlet{headBR}{color1}}{}
\@ifundefined{\string\color@headtext}{\colorlet{headtext}{color2}}{}
\@ifundefined{\string\color@headhr}{\colorlet{headhr}{color2}}{}

% fonts
\renewcommand*{\namefont}{\fontsize{30}{32}\rmfamily\mdseries\upshape}
\renewcommand*{\titlefont}{\LARGE\mdseries\slshape}
\renewcommand*{\addressfont}{\small\mdseries\slshape}
\renewcommand*{\quotefont}{\large\slshape}

% styles
\renewcommand*{\namestyle}[1]{{\namefont\textcolor{headtext}{#1}}}
\renewcommand*{\titlestyle}[1]{{\titlefont\textcolor{headtext}{#1}}}
\renewcommand*{\addressstyle}[1]{{\addressfont\textcolor{headtext}{#1}}}
\renewcommand*{\quotestyle}[1]{{\quotefont\textcolor{color0}{#1}}}


%-------------------------------------------------------------------------------
%                resume head definition
%-------------------------------------------------------------------------------
% lengths
\@initializelength{\quotewidth}
\@initializelength{\makecvheadnamewidth}% optional makecvheadname width to force a certain width (if set/remains to 0pt, the width is calculated automatically)
\renewcommand*{\recomputecvheadlengths}{%
  \setlength{\quotewidth}{0.65\textwidth}}

% commands
\renewcommand*{\makecvhead}{%
  % recompute lengths (in case we are switching from letter to resume, or vice versa)
  \recomputecvlengths%
  % optional detailed information (pre-rendering)
  \@initializebox{\makecvheaddetailsbox}%
  \if@details%
    \def\phonesdetails{}%
    \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
      \protected@edef\phonesdetails{\phonesdetails\protect\makenewline\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}}%
    \def\socialsdetails{}%
    \collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
      \protected@edef\socialsdetails{\socialsdetails\protect\makenewline\csname\collectionloopkey socialsymbol\endcsname\collectionloopitem}}%
    \savebox{\makecvheaddetailsbox}{%
      \addressfont\color{headtext}%
      \if@left\begin{tabular}[b]{@{}r@{}}\fi%
      \if@right\begin{tabular}[b]{@{}l@{}}\fi%
        \ifthenelse{\isundefined{\@addressstreet}}{}{\makenewline\addresssymbol\@addressstreet%
          \ifthenelse{\equal{\@addresscity}{}}{}{\makenewline\@addresscity}% if \addresstreet is defined, \addresscity and addresscountry will always be defined but could be empty
          \ifthenelse{\equal{\@addresscountry}{}}{}{\makenewline\@addresscountry}}%
        \phonesdetails% needs to be pre-rendered as loops and tabulars seem to conflict
        \ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
        \ifthenelse{\isundefined{\@homepage}}{}{\makenewline\homepagesymbol\httplink{\@homepage}}%
        \socialsdetails% needs to be pre-rendered as loops and tabulars seem to conflict
        \ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}%
      \end{tabular}
    }\fi%
  % optional photo (pre-rendering)
  \@initializebox{\makecvheadpicturebox}%
  \savebox{\makecvheadpicturebox}{%
    \ifthenelse{\isundefined{\@photo}}%
      {}%
      {%
        \if@right%
          \hspace*{\separatorcolumnwidth}\fi%
        \begin{tikzpicture}
          \path[top color=headBR,bottom color=headTL,shading angle=45] (0,0) circle (\dimexpr\@photowidth/2+\@photoframewidth*2);
          \path[fill=white] (0,0) circle (\dimexpr\@photowidth/2+\@photoframewidth);
          \begin{scope}
            \clip (0,0) circle (\dimexpr\@photowidth/2);
            \node[inner sep=0pt] at (0,0) {\includegraphics[width=\@photowidth]{\@photo}};
          \end{scope}
        \end{tikzpicture}%
      }%
      \if@left%
        \hspace*{\separatorcolumnwidth}\fi}%
  % optional QR for homepage (pre-rendering)
  \@initializebox{\makecvheadqrbox}%
  \if@headqr%
    \savebox{\makecvheadqrbox}{%
      \ifthenelse{\isundefined{\@homepage}}{}{\tikz\node[inner sep=1ex,fill=white]{\qrcode[height=1.5cm]{\@homepage}};}%
    }\fi%
  % name and title (pre-rendering)
  \@initializelength{\makecvheaddetailswidth}\settowidth{\makecvheaddetailswidth}{\usebox{\makecvheaddetailsbox}}%
  \@initializelength{\makecvheadpicturewidth}\settowidth{\makecvheadpicturewidth}{\usebox{\makecvheadpicturebox}}%
  \ifthenelse{\lengthtest{\makecvheadnamewidth=0pt}}% check for dummy value (equivalent to \ifdim\makecvheadnamewidth=0pt)
    {\setlength{\makecvheadnamewidth}{\textwidth-\makecvheaddetailswidth-\makecvheadpicturewidth}}%
    {}%
  \@initializebox{\makecvheadnamebox}%
  \savebox{\makecvheadnamebox}{%
    \begin{minipage}[b]{\makecvheadnamewidth}%
      \if@left\raggedright\fi%
      \if@right\raggedleft\fi%
      \namestyle{\@firstname\ {\scshape\@lastname}}%
      \ifthenelse{\equal{\@title}{}}{}{\\[1.25em]\titlestyle{\@title}}%
    \end{minipage}}%
  % rendering
  \begin{tikzpicture}[remember picture,overlay]
    \node(head-bg) [top color=headTL,bottom color=headBR,shading angle=45,inner sep=0pt,
      fit={(current page.north west)(current page.north east)(pic cs:head-end)}] {};
    % Users may define `\@moderncvheadBackground` for additional background decoration
    \ifthenelse{\isundefined{\@moderncvheadBackground}}{}{\@moderncvheadBackground}

    \path[draw,line width=\@photoframewidth]
        (head-bg.south west) edge[color=headhr!85!black] ([xshift=8em]head-bg.south west)
        ([xshift=8em]head-bg.south west) edge[color=headhr] ([xshift=-8em]head-bg.south east)
        ([xshift=-8em]head-bg.south east) edge[color=headhr!85!black] (head-bg.south east);
  \end{tikzpicture}%
  \if@left%
    \usebox{\makecvheadpicturebox}%
    \usebox{\makecvheadnamebox}%
    \hfill%
    \llap{\usebox{\makecvheaddetailsbox}}% \llap is used to suppress the width of the box, allowing overlap if the value of makecvheadnamewidth is forced
    \usebox{\makecvheadqrbox}\fi%
  \if@right%
    \usebox{\makecvheadqrbox}%
    \rlap{\usebox{\makecvheaddetailsbox}}% \llap is used to suppress the width of the box, allowing overlap if the value of makecvheadnamewidth is forced
    \hfill%
    \usebox{\makecvheadnamebox}%
    \usebox{\makecvheadpicturebox}\fi%
  \\[.15em]%
  \tikzmark{head-end}\\[.15em]%
  % optional quote
  \ifthenelse{\isundefined{\@quote}}%
    {}%
    {{\centering\begin{minipage}{\quotewidth}\centering\quotestyle{\@quote}\end{minipage}\\[.15em]}}%
  \par}% to avoid weird spacing bug at the first section if no blank line is left after \makecvhead


%-------------------------------------------------------------------------------
%                letter head definition
%-------------------------------------------------------------------------------
% lengths
%\renewcommand*{\recomputeletterheadlengths}{}

% commands
\renewcommand*{\makeletterhead}{%
  % recompute lengths (in case we are switching from letter to resume, or vice versa)
  \recomputeletterlengths%
  % sender contact info
  \hfill%
  \begin{minipage}{.5\textwidth}%
    % optional detailed information
    \if@details%
      \raggedleft%
      \addressfont\textcolor{color2}{%
        {\bfseries\upshape\@firstname~\@lastname}\@firstdetailselementfalse%
        % optional detailed information
        \ifthenelse{\isundefined{\@addressstreet}}{}{\makenewline\addresssymbol\@addressstreet%
          \ifthenelse{\equal{\@addresscity}{}}{}{\makenewline\@addresscity}% if \addresstreet is defined, \addresscity and addresscountry will always be defined but could be empty
          \ifthenelse{\equal{\@addresscountry}{}}{}{\makenewline\@addresscountry}}%
        \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
          \makenewline\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}%
        \ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
        \ifthenelse{\isundefined{\@homepage}}{}{\makenewline\homepagesymbol\httplink{\@homepage}}%
        \ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}}\fi%
    \end{minipage}\\[1em]
  % recipient block
  \begin{minipage}[t]{.5\textwidth}
    \raggedright%
    \addressfont%
    {\bfseries\upshape\@recipientname}\\%
    \@recipientaddress%
  \end{minipage}
  % date
  \hfill% US style
%  \\[1em]% UK style
  \@date\\[2em]% US informal style: "January 1, 1900"; UK formal style: "01/01/1900"
  % optional subject
  \ifthenelse{\isundefined{\@subject}}{}{{\bfseries\@subject\\[3em]}}
  % opening
  \raggedright%
  \@opening\\[1.5em]%
  % ensure no extra spacing after \makelettertitle due to a possible blank line
%  \ignorespacesafterend% not working
  \hspace{0pt}\par\vspace{-\baselineskip}\vspace{-\parskip}}


\endinput


%% end of file `moderncvheadvii.sty'.