diff options
author | Aaron LI <aly@aaronly.me> | 2024-12-05 13:50:52 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2024-12-05 13:51:48 +0800 |
commit | 2325395582f031fb0d1dd589fcf9e9ff9f0a13bd (patch) | |
tree | 34198e03103479e3a60c272a0cb868b5b5dfdc0a /resume.cls | |
parent | 099903e454002474e7f14ce6ddd0b5ef03bfb543 (diff) | |
download | resume-2325395582f031fb0d1dd589fcf9e9ff9f0a13bd.tar.bz2 |
class: Refactor "\photo" to simplify photo handling in \makeheader
Derived-from: PR #21
Diffstat (limited to 'resume.cls')
-rw-r--r-- | resume.cls | 43 |
1 files changed, 22 insertions, 21 deletions
@@ -12,7 +12,7 @@ %% https://www.latextemplates.com/template/plasmati-graduate-cv %% -\ProvidesClass{resume}[2024/12/05 v2.5.9 Resume Class] +\ProvidesClass{resume}[2024/12/05 v2.5.10 Resume Class] \LoadClass{article} %% @@ -259,12 +259,28 @@ % File information \newcommand*{\fileinfo}[1]{\def\@fileinfo{#1}} +% Width of the profile +\newlength{\profilewidth} +% Delay the \setlength so the \linewidth becomes available. +\AtBeginDocument{% + \setlength{\profilewidth}{\linewidth} +} + % Photo: \photo[<shape>]{<width>}{<filename>} % Two shapes are supported: circular (default), square \NewDocumentCommand{\photo}{O{circular}mm}{ - \def\@photoshape{#1} - \def\@photowidth{#2} - \def\@photofile{#3} + \setlength{\profilewidth}{\dimexpr \linewidth - #2 - 2em} + \def\@photo{% + \begin{minipage}{#2} + \ifthenelse{\equal{#1}{square}}{% + \tikz\path[fill overzoom image={#3}] + rectangle (\linewidth, \linewidth); + }{% + \tikz\path[fill overzoom image={#3}] + circle[radius=0.5\linewidth]; + } + \end{minipage}% + } } % Address @@ -306,23 +322,8 @@ % Render resume header \newcommand*{\makeheader}{ - \ifdef{\@photowidth}{ - \begin{minipage}{\@photowidth} - \ifthenelse{\equal{\@photoshape}{square}}{% - \tikz\path[fill overzoom image={\@photofile}] - rectangle (\linewidth, \linewidth); - }{% - \tikz\path[fill overzoom image={\@photofile}] - circle[radius=0.5\linewidth]; - } - \end{minipage} - \hspace{1em} - }{} - \ifundef{\@photowidth}{% - \begin{minipage}{\linewidth} - }{% - \begin{minipage}{\dimexpr\linewidth-\@photowidth-2em} - } + \ifdef{\@photo}{\@photo\hspace{1em}}{}% + \begin{minipage}{\profilewidth} {\LARGE\bfseries\color{accentcolor} \@name} \ifdef{\@tagline}{% \medskip \\ |