在 Moderncv 中自动将地址与电话号码对齐

在 Moderncv 中自动将地址与电话号码对齐

我正在使用银行风格的软件包中的求职信模板moderncv。目前,我对求职信的修改如下 在此处输入图片描述

可以看出地址行与电话号码不对齐。我的目标是将地址符号和电话符号对齐,这样看起来更清晰。

答案1

好的,我终于找到了一个解决方案,虽然不是最漂亮的解决方案,但它有效。

我将 github 文件中的以下代码块复制moderncvheadiii.sty到我正在使用的文件中。也就是说,如果你将 .sty 文件保存在你的文件夹中,那么就在那里调整它。如果你没有像我一样将文件保存在你的文件夹中,只需插入此代码块\begin{document}并在那里调整它。所以,我所做的更改用%CHANGED:

\makeatletter
%   internal command to flush the makehead
\@initializecommand{\flushmakeheaddetails}{%
  \ifnum\makeheaddetailsboxwidth>0%
    \strut\usebox{\makeheaddetailsbox}%
    \savebox{\makeheaddetailsbox}{}%
    \savebox{\makeheaddetailstempbox}{}%
    \setlength{\makeheaddetailsboxwidth}{0pt}\fi}
\@initializecommand{\makehead}{%
  \setlength{\makeheaddetailswidth}{0.8\textwidth}%
  \hfil%
  \parbox{\makeheaddetailswidth}{%
    \centering%
    % name and title
    \namestyle{\@firstname~\@lastname}%
    \ifthenelse{\equal{\@title}{}}{}{\titlestyle{~|~\@title}}% \isundefined doesn't work on \@title, as LaTeX itself defines \@title (before it possibly gets redefined by \title) 
    % optional detailed information
    \vspace{0.2cm} % CHANGED: introduce some vertical space between title and address block
    \if@details{%
      \\%
      \raggedright % CHANGED: left-align address block
      \hspace{1.6cm} % CHANGED: adjust the horizontal space manually such that the address and phone symbol are aligned
      \addressfont\color{color2}%
      \ifthenelse{\isundefined{\@addressstreet}}{}{\addtomakeheaddetails{\addresssymbol\@addressstreet}%
        \ifthenelse{\equal{\@addresscity}{}}{}{\addtomakeheaddetails[~--~]{\@addresscity}}% if \addresstreet is defined, \addresscity and \addresscountry will always be defined but could be empty
        \ifthenelse{\equal{\@addresscountry}{}}{}{\addtomakeheaddetails[~--~]{\@addresscountry}}%
        \flushmakeheaddetails\@firstmakeheaddetailselementtrue\\}%
      \ifthenelse{\isundefined{\@born}}{}{\addtomakeheaddetails{\bornsymbol\@born}}%
      \vspace{0.2cm} %CHANGED: introduce some vertical space between address and rest of additional information
      \centering % CHANGED: center the rest of the additional information
      \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
        \addtomakeheaddetails{\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}}%
      \ifthenelse{\isundefined{\@email}}{}{\addtomakeheaddetails{\emailsymbol\emaillink{\@email}}}%
      \ifthenelse{\isundefined{\@homepage}}{}{\addtomakeheaddetails{\homepagesymbol\httpslink{\@homepage}}}%
      \collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
        \addtomakeheaddetails{\csname\collectionloopkey socialsymbol\endcsname\collectionloopitem}}%
      \ifthenelse{\isundefined{\@extrainfo}}{}{\addtomakeheaddetails{\@extrainfo}}%
      \flushmakeheaddetails}\fi}\\[2.5em]}% need to force a \par after this to avoid weird spacing bug at the first section if no blank line is left after \makehead
\makeatother

我希望这对其他人也有帮助。也许有人知道更漂亮的解决方案,不需要手动调整。如果是这样,请在此处发布答案!

相关内容