From 9b38bc35b590bfbccffc10de0b910165984e6537 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Sat, 18 Nov 2023 20:16:52 +0800 Subject: class: Enhance '\photo' command to support circle and square shapse Implement a new optional argument [shape] to the '\photo' command, with the default shape being the original 'circle' shape, and thus allow the user to easily switch to 'square' shape. Close: #18 --- resume.cls | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'resume.cls') diff --git a/resume.cls b/resume.cls index 4d9bede..3bed5d6 100644 --- a/resume.cls +++ b/resume.cls @@ -12,7 +12,7 @@ %% https://www.latextemplates.com/template/plasmati-graduate-cv %% -\ProvidesClass{resume}[2023/02/03 v2.5.1 Resume Class] +\ProvidesClass{resume}[2023/11/18 v2.5.2 Resume Class] \LoadClass{article} %% @@ -34,6 +34,7 @@ ]{geometry} \RequirePackage{xparse} \RequirePackage{etoolbox} +\RequirePackage{ifthen} \RequirePackage{fontspec} \RequirePackage{fontawesome5} \RequirePackage{parskip} % auto adjust parskip and items skip @@ -257,8 +258,13 @@ % File information \newcommand*{\fileinfo}[1]{\def\@fileinfo{#1}} -% Photo: \photo{}{} -\newcommand{\photo}[2]{\def\@photo{#2}\def\@photodiameter{#1}} +% Photo: \photo[]{}{} +% Two shapes are supported: circle (default), square +\NewDocumentCommand{\photo}{O{circle}mm}{ + \def\@photoshape{#1} + \def\@photowidth{#2} + \def\@photofile{#3} +} % Address \newcommand*{\address}[1]{\icontext{\locationSymbol}{#1}} @@ -311,17 +317,22 @@ % Render resume header \newcommand*{\makeheader}{ - \ifdef{\@photodiameter}{ - \begin{minipage}{\@photodiameter} - \tikz\path[fill overzoom image={\@photo}] - circle[radius=0.5\linewidth]; + \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{\@photodiameter}{% + \ifundef{\@photowidth}{% \begin{minipage}{\linewidth} }{% - \begin{minipage}{\dimexpr\linewidth-\@photodiameter-2em} + \begin{minipage}{\dimexpr\linewidth-\@photowidth-2em} } \user{\@firstname}{\@lastname} \ifdef{\@tagline}{% -- cgit v1.2.2