From 031a53d1fbb218b34ebb43c6f30ce4e368e5d356 Mon Sep 17 00:00:00 2001 From: "Posquit0.BJ" Date: Sat, 3 Dec 2016 06:29:14 +0900 Subject: [PATCH] Refactor photo command --- awesome-cv.cls | 85 +++++++++++++++++++--------------------- examples/coverletter.tex | 9 +++-- examples/cv.tex | 3 +- examples/resume.tex | 5 ++- 4 files changed, 52 insertions(+), 50 deletions(-) diff --git a/awesome-cv.cls b/awesome-cv.cls index 11e34db..a43cbd7 100644 --- a/awesome-cv.cls +++ b/awesome-cv.cls @@ -21,7 +21,7 @@ %------------------------------------------------------------------------------- % Identification %------------------------------------------------------------------------------- -\ProvidesClass{awesome-cv}[2016/01/30 v1.5 Awesome Curriculum Vitae Class] +\ProvidesClass{awesome-cv}[2016/12/03 v1.6 Awesome Curriculum Vitae Class] \NeedsTeXFormat{LaTeX2e} @@ -236,20 +236,21 @@ % Commands for personal information %------------------------------------------------------------------------------- % Define photo ID -% Usage: \photoid[circle|rectangle,edge|noedge]{} -\newcommand{\photoid}[2][circle,edge]{% -\@for\tmp:=#1\do{% - \ifthenelse{ - \equal{\tmp}{circle} - \or \equal{\tmp}{rectangle} - }{\let\@phishape\tmp}{ - \ifthenelse{ - \equal{\tmp}{edge} - \or \equal{\tmp}{noedge} - }{\let\@phiedge\tmp}{} - } -}% -\def\@phid{#2}} +% Usage: \photo[circle|rectangle,edge|noedge,left|right]{} +\newcommand{\photo}[2][circle,edge,left]{% + \def\@photo{#2} + \@for\tmp:=#1\do{% + \ifthenelse{\equal{\tmp}{circle} \or \equal{\tmp}{rectangle}}% + {\let\@photoshape\tmp}{}% + \ifthenelse{\equal{\tmp}{edge} \or \equal{\tmp}{noedge}}% + {\let\@photoedge\tmp}{}% + \ifthenelse{\equal{\tmp}{left} \or \equal{\tmp}{right}}% + {\let\@photoalign\tmp}{}% + }% +} +\def\@photoshape{circle} +\def\@photoedge{edge} +\def\@photoalign{left} % Define writer's name % Usage: \name{}{} @@ -394,17 +395,32 @@ % Define a header for CV % Usage: \makecvheader \newcommand*{\makecvheader}[1][C]{% + \newcommand*{\drawphoto}{% + \ifthenelse{\isundefined{\@photo}}{}{% + \newlength{\photodim} + \ifthenelse{\equal{\@photoshape}{circle}}% + {\setlength{\photodim}{1.3cm}}% + {\setlength{\photodim}{1.8cm}}% + \ifthenelse{\equal{\@photoedge}{edge}}% + {\def\@photoborder{darkgray}}% + {\def\@photoborder{none}}% + \begin{tikzpicture}% + \node[\@photoshape, draw=\@photoborder, line width=0.3mm, inner sep=\photodim, fill overzoom image=\@photo] () {}; + \end{tikzpicture} + }% + } \newlength{\headertextwidth} - \newlength{\headerphotoidwidth} - \ifthenelse{\isundefined{\@phid}}{ + \newlength{\headerphotowidth} + \ifthenelse{\isundefined{\@photo}}{ \setlength{\headertextwidth}{\textwidth} - \setlength{\headerphotoidwidth}{0cm} + \setlength{\headerphotowidth}{0cm} }{% - \setlength{\headertextwidth}{0.8\textwidth} - \setlength{\headerphotoidwidth}{0.2\textwidth} + \setlength{\headertextwidth}{0.76\textwidth} + \setlength{\headerphotowidth}{0.24\textwidth} }% - \ifthenelse{\isundefined{\@phishape}}{\def\@phishape{circle}}{} - \ifthenelse{\isundefined{\@phiedge}}{\def\@phiedge{edge}}{} + \begin{minipage}[c]{\headerphotowidth}% + \ifthenelse{\equal{\@photoalign}{left}}{\raggedright\drawphoto}{} + \end{minipage} \begin{minipage}[c]{\headertextwidth} \ifthenelse{\equal{#1}{L}}{\raggedright}{\ifthenelse{\equal{#1}{R}}{\raggedleft}{\centering}} \headerfirstnamestyle{\@firstname}\headerlastnamestyle{{}\acvHeaderNameDelim\@lastname}% @@ -485,28 +501,9 @@ {}% {\headerquotestyle{\@quote\\}\vspace{\acvHeaderAfterQuoteSkip}}% \end{minipage}% - \ifthenelse{\isundefined{\@phid}}{}{% - \newlength{\phiddim}% - \ifthenelse{\equal{\@phishape}{circle}}{\setlength{\phiddim}{1cm}}{\setlength{\phiddim}{1.3cm}} - \begin{minipage}[c]{\headerphotoidwidth}% - \raggedleft\begin{tikzpicture}% - \ifthenelse{\equal{\@phiedge}{edge}}{% - \foreach \r/\colora in {0.2/{black!10},0.08/{black!30}}{ - \ifthenelse{\equal{\@phishape}{circle}}{% - \pgfmathsetlengthmacro{\x}{(\r)*1cm + 1.4142*\phiddim} - \fill[\colora] (0,0) circle (\x); - }{% - \pgfmathsetlengthmacro{\x}{(\r)*1cm + \phiddim} - \fill[\colora] (-\x,-\x) rectangle (\x,\x); - }% - }% - \node[\@phishape,draw=awesome,line width=0.5mm,inner sep=\phiddim,fill overzoom image=\@phid] () {}; - }{% No edge - \node[\@phishape,draw=white,line width=0.0mm,inner sep=1.1*\phiddim,fill overzoom image=\@phid] () {}; - } - \end{tikzpicture}% - \end{minipage} - }% + \begin{minipage}[c]{\headerphotowidth}% + \ifthenelse{\equal{\@photoalign}{right}}{\raggedleft\drawphoto}{} + \end{minipage} } % Define a footer for CV diff --git a/examples/coverletter.tex b/examples/coverletter.tex index 6c73e98..bc4519d 100644 --- a/examples/coverletter.tex +++ b/examples/coverletter.tex @@ -21,7 +21,7 @@ \documentclass[11pt, a4paper]{awesome-cv} % Configure page margins with geometry -% \geometry{left=1.4cm, top=.8cm, right=1.4cm, bottom=1.8cm, footskip=.5cm} +\geometry{left=1.4cm, top=.8cm, right=1.4cm, bottom=1.8cm, footskip=.5cm} % Specify the location of the included fonts \fontdir[fonts/] @@ -51,11 +51,13 @@ % PERSONAL INFORMATION % Comment any of the lines below if they are not required %------------------------------------------------------------------------------- +% Available options: circle|rectangle,edge/noedge,left/right +\photo[circle,noedge,left]{./examples/profile} \name{Claud D.}{Park} \position{Software Engineer{\enskip\cdotp\enskip}Security Expert} \address{246-1002, Gwangmyeongmayrouge Apt. 86, Cheongna lime-ro, Seo-gu, Incheon-si, 404-180, Rep. of KOREA} -\mobile{(+82) 10-9030-1843} +\mobile{(+82) 10-9030-1843} \email{posquit0.bj@gmail.com} \homepage{www.posquit0.com} \github{posquit0} @@ -93,7 +95,8 @@ \begin{document} % Print the header with above personal informations -\makecvheader +% Give optional argument to change alignment(C: center, L: left, R: right) +\makecvheader[R] % Print the footer with 3 arguments(,
, ) % Leave any of these blank if they are not needed diff --git a/examples/cv.tex b/examples/cv.tex index b403069..a450503 100644 --- a/examples/cv.tex +++ b/examples/cv.tex @@ -51,7 +51,8 @@ % PERSONAL INFORMATION % Comment any of the lines below if they are not required %------------------------------------------------------------------------------- -\photoid{./examples/profile.png} +% Available options: circle|rectangle,edge/noedge,left/right +% \photo{./examples/profile.png} \name{Claud D.}{Park} \position{Software Engineer{\enskip\cdotp\enskip}Security Expert} \address{246-1002, Gwangmyeongmayrouge Apt. 86, Cheongna lime-ro, Seo-gu, Incheon-si, 404-180, Rep. of KOREA} diff --git a/examples/resume.tex b/examples/resume.tex index 60ebd41..f2dc59a 100644 --- a/examples/resume.tex +++ b/examples/resume.tex @@ -51,7 +51,8 @@ % PERSONAL INFORMATION % Comment any of the lines below if they are not required %------------------------------------------------------------------------------- -\photoid{./examples/profile.png} +% Available options: circle|rectangle,edge/noedge,left/right +\photo[rectangle,edge,right]{./examples/profile} \name{Claud D.}{Park} \position{Software Engineer{\enskip\cdotp\enskip}Security Expert} \address{246-1002, Gwangmyeongmayrouge Apt. 86, Cheongna lime-ro, Seo-gu, Incheon-si, 404-180, Rep. of KOREA} @@ -75,7 +76,7 @@ % Print the header with above personal informations % Give optional argument to change alignment(C: center, L: left, R: right) -\makecvheader +\makecvheader[L] % Print the footer with 3 arguments(,
, ) % Leave any of these blank if they are not needed