aboutsummaryrefslogtreecommitdiffstats
path: root/resume.cls
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2024-12-06 09:16:39 +0800
committerAaron LI <aly@aaronly.me>2024-12-06 09:16:39 +0800
commit4c316f5e66dc380bf194a150e43d34395dd1aecb (patch)
tree5b2b0e5041f881b67f00b4f84fd7fd1bd6a074af /resume.cls
parentddc7ca28fa62b933e72075b47c417868ea2289ab (diff)
downloadresume-4c316f5e66dc380bf194a150e43d34395dd1aecb.tar.bz2
class: Refactor "\photo" again to support left/right position
Extend the "\photo" command to support to place the photo on the right side of profile, which can be controlled with the new "position" parameter key. Use the "keyval" package to implement the key=value style optional parameters for the "\photo" command. See also: PR #21
Diffstat (limited to 'resume.cls')
-rw-r--r--resume.cls25
1 files changed, 19 insertions, 6 deletions
diff --git a/resume.cls b/resume.cls
index 6dab43f..2d08b2c 100644
--- a/resume.cls
+++ b/resume.cls
@@ -34,7 +34,6 @@
]{geometry}
\RequirePackage{xparse}
\RequirePackage{etoolbox}
-\RequirePackage{ifthen}
\RequirePackage{fontspec}
\RequirePackage{fontawesome5}
\RequirePackage{parskip} % auto adjust parskip and items skip
@@ -50,6 +49,7 @@
\RequirePackage[skins]{tcolorbox} % required by tikz to make the header
\RequirePackage{csquotes}
\RequirePackage{relsize} % relatively scale the icons
+\RequirePackage{keyval} % key=value style parameters
\ifdef{\@zh}{
\RequirePackage{xeCJK}
}{}
@@ -259,13 +259,22 @@
% File information
\newcommand*{\fileinfo}[1]{\def\@fileinfo{#1}}
-% Photo: \photo[<shape>]{<width>}{<filename>}
-% Two shapes are supported: circular (default), square
-\NewDocumentCommand{\photo}{O{circular}mm}{
+% Photo:
+% \photo[
+% shape=<circular|square>, % default is circular
+% position=<left|right>, % default is left
+% ]{<width>}{<filename>}
+\define@key{photo}{shape}{\def\@photo@shape{#1}}
+\define@key{photo}{position}{\def\@photo@position{#1}}
+\NewDocumentCommand{\photo}{
+ O{shape=circular, position=left}
+ m m
+}{
+ \setkeys{photo}{#1}
\def\@photo@width{#2}
\def\@photo{%
\begin{minipage}{\@photo@width}
- \ifthenelse{\equal{#1}{square}}{%
+ \ifdefstring{\@photo@shape}{square}{%
\tikz\path[fill overzoom image={#3}]
rectangle (\linewidth, \linewidth);%
}{%
@@ -320,7 +329,9 @@
}{
\def\@profile@width{\linewidth}
}%
- \ifdef{\@photo}{\@photo\hspace{1em}}{}%
+ \ifdefstring{\@photo@position}{left}{%
+ \@photo\hspace{1em}%
+ }{}%
\begin{minipage}{\@profile@width}
{\LARGE\bfseries\color{accentcolor} \@name}
\ifdef{\@tagline}{%
@@ -330,6 +341,8 @@
\medskip \\
\@profile
\end{minipage}
+ % photo on the right side
+ \ifdefstring{\@photo@position}{left}{}{\hfill\@photo}
}
%%