ModernCV 修改标题 - 下一行的内容

ModernCV 修改标题 - 下一行的内容

作为这个问题的延续moderncv 银行风格:如何将标题栏一直移动到左侧?,我想引入以下内容,每行一个,例如:
街道和号码
城市邮政编码
国家
电话号码 1
电话号码 2
电子邮件
网页

项目符号将被删除。代码是:

\documentclass[12pt,letterpaper]{moderncv}
\moderncvstyle{banking}
\moderncvcolor{blue}
\usepackage{libertine}
\usepackage[scale=0.75]{geometry}

\makeatletter
\renewcommand*{\flushmaketitle}{%
  \strut\usebox{\maketitlebox}%
  \savebox{\maketitlebox}{}%
  \savebox{\maketitletempbox}{}%
  \setlength{\maketitleboxwidth}{0pt}}
\renewcommand*{\maketitle}{%
%  \setlength{\maketitlewidth}{0.8\textwidth}% ORIGINAL
  \setlength{\maketitlewidth}{\textwidth}% NEW
  %\hfil% ORIGINAL
  \parbox{\maketitlewidth}{%
%    \centering% ORIGINAL
    \raggedright% NEW
    % name and title
    \namestyle{\@firstname~\@lastname}%
    \\% \isundefined doesn't work on \@title, as LaTeX itself defines \@title (before it possibly gets redefined by \title)
    % detailed information
    \addressfont\color{color2}%
    \ifthenelse{\isundefined{\@addressstreet}}{}{\addtomaketitle{\addresssymbol\@addressstreet}%
      \ifthenelse{\equal{\@addresscity}{}}{}{\addtomaketitle{\@addresscity}}% if \addresstreet is defined, \addresscity and \addresscountry will always be defined but could be empty
      \ifthenelse{\equal{\@addresscountry}{}}{}{\addtomaketitle{\@addresscountry}}%
      \flushmaketitle\@firstmaketitleelementtrue\\}%
    \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
      \addtomaketitle{\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}}%
    \ifthenelse{\isundefined{\@email}}{}{\addtomaketitle{\emailsymbol\emaillink{\@email}}}%
    \ifthenelse{\isundefined{\@homepage}}{}{\addtomaketitle{\homepagesymbol\httplink{\@homepage}}}%
    \collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
      \addtomaketitle{\csname\collectionloopkey socialsymbol\endcsname\collectionloopitem}}%
    \ifthenelse{\isundefined{\@extrainfo}}{}{\addtomaketitle{\@extrainfo}}%
    \flushmaketitle}\\[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 \maketitle
\makeatother


\name{John}{Doe}
\address{street and number}{postcode city}{country}
\phone[mobile]{+1~(234)~567~890}
\phone[fixed]{+2~(345)~678~901}
\phone[fax]{+3~(456)~789~012}
\email{[email protected]}
\homepage{www.johndoe.com}
\quote{Some quote}

\begin{document}
\makecvtitle

\section{A test section}
Some test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text
\end{document} 

在此处输入图片描述

答案1

只需使用一些额外的

\flushmaketitle\@firstmaketitleelementtrue\\        %%% <--- HK here

在适当的地方:

\documentclass[11pt,a4paper,sans]{moderncv}
\moderncvstyle{banking}
\moderncvcolor{blue}
\usepackage[scale=0.75]{geometry}

\makeatletter
%\renewcommand*{\maketitlesymbol}{}%
%
\renewcommand*{\flushmaketitle}{%
  \strut\usebox{\maketitlebox}%
  \savebox{\maketitlebox}{}%
  \savebox{\maketitletempbox}{}%
  \setlength{\maketitleboxwidth}{0pt}}
\renewcommand*{\maketitle}{%
%  \setlength{\maketitlewidth}{0.8\textwidth}% ORIGINAL
  \setlength{\maketitlewidth}{\textwidth}% NEW
  %\hfil% ORIGINAL
  \parbox{\maketitlewidth}{%
%    \centering% ORIGINAL
    \raggedright% NEW
    % 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)
    % detailed information
    \addressfont\color{color2}%
    \ifthenelse{\isundefined{\@addressstreet}}{}{\addtomaketitle{\addresssymbol\@addressstreet}%
    \flushmaketitle\@firstmaketitleelementtrue\\       %%% <--- HK here
      \ifthenelse{\equal{\@addresscity}{}}{}{\addtomaketitle[~--~]{\@addresscity}}% if \addresstreet is defined, \addresscity and \addresscountry will always be defined but could be empty
      \flushmaketitle\@firstmaketitleelementtrue\\     %%% <--- HK here
      \ifthenelse{\equal{\@addresscountry}{}}{}{\addtomaketitle[~--~]{\@addresscountry}}%
      \flushmaketitle\@firstmaketitleelementtrue\\}%
    \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
      \addtomaketitle{\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}
      \flushmaketitle\@firstmaketitleelementtrue\\}%           %% <--- HK here
    \ifthenelse{\isundefined{\@email}}{}{\addtomaketitle{\emailsymbol\emaillink{\@email}}}%
    \flushmaketitle\@firstmaketitleelementtrue\\           %% <--- HK here    
    \ifthenelse{\isundefined{\@homepage}}{}{\addtomaketitle{\homepagesymbol\httplink{\@homepage}}}%
    \flushmaketitle\@firstmaketitleelementtrue\\           %% <--- HK here
    \collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
      \addtomaketitle{\csname\collectionloopkey socialsymbol\endcsname\collectionloopitem}
      \flushmaketitle\@firstmaketitleelementtrue\\}           %% <--- HK here}% 
    \ifthenelse{\isundefined{\@extrainfo}}{}{\addtomaketitle{\@extrainfo}}%
    \flushmaketitle}\\[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 \maketitle
\makeatother


\name{John}{Doe}
\title{Resume title}
\address{street and number}{city postcode}{country}
\phone[mobile]{+1~(234)~567~890}
\phone[fixed]{+2~(345)~678~901}
\phone[fax]{+3~(456)~789~012}
\email{[email protected]}
\homepage{www.johndoe.com}
\social[linkedin]{john.doe} 
\social[twitter]{jdoe}            
\social[github]{jdoe}          
\extrainfo{additional information} 
\quote{Some quote}

\begin{document}
\makecvtitle

\section{A test section}
Some test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text
\end{document}

在此处输入图片描述

回答评论:

您可以使用额外的parboxes:

\makeatletter
%\renewcommand*{\maketitlesymbol}{}%
%
\renewcommand*{\flushmaketitle}{%
  \strut\usebox{\maketitlebox}%
  \savebox{\maketitlebox}{}%
  \savebox{\maketitletempbox}{}%
  \setlength{\maketitleboxwidth}{0pt}}
\renewcommand*{\maketitle}{%
%  \setlength{\maketitlewidth}{0.8\textwidth}% ORIGINAL
  \setlength{\maketitlewidth}{\textwidth}% NEW
  %\hfil% ORIGINAL
  \parbox{\maketitlewidth}{%
%    \centering% ORIGINAL
    \raggedright% NEW
    % 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)
    % detailed information
    \addressfont\color{color2}%
    \parbox[t]{0.45\maketitlewidth}{%
    \ifthenelse{\isundefined{\@addressstreet}}{}{\addtomaketitle{\addresssymbol\@addressstreet}%
    \flushmaketitle\@firstmaketitleelementtrue\\       %%% <--- HK here
      \ifthenelse{\equal{\@addresscity}{}}{}{\addtomaketitle[~--~]{\@addresscity}}% if \addresstreet is defined, \addresscity and \addresscountry will always be defined but could be empty
      \flushmaketitle\@firstmaketitleelementtrue\\     %%% <--- HK here
      \ifthenelse{\equal{\@addresscountry}{}}{}{\addtomaketitle[~--~]{\@addresscountry}}%
  \flushmaketitle\@firstmaketitleelementtrue\\     %%% <--- HK here
      }}%
      \hfill
    \parbox[t]{0.45\maketitlewidth}{%
    \raggedleft%    %% optional  
    \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
      \addtomaketitle{\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}
      \flushmaketitle\@firstmaketitleelementtrue\\}%           %% <--- HK here
    \ifthenelse{\isundefined{\@email}}{}{\addtomaketitle{\emailsymbol\emaillink{\@email}}}%
    \flushmaketitle\@firstmaketitleelementtrue\\           %% <--- HK here    
    \ifthenelse{\isundefined{\@homepage}}{}{\addtomaketitle{\homepagesymbol\httplink{\@homepage}}}%
    \flushmaketitle\@firstmaketitleelementtrue\\           %% <--- HK here
    \collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
      \addtomaketitle{\csname\collectionloopkey socialsymbol\endcsname\collectionloopitem}
      \flushmaketitle\@firstmaketitleelementtrue\\}           %% <--- HK here 
    \ifthenelse{\isundefined{\@extrainfo}}{}{\addtomaketitle{\@extrainfo}}%
    \flushmaketitle}}\\[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 \maketitle
\makeatother

在此处输入图片描述

答案2

以下是简化版本\maketitle,避免将内容添加到框中并仅在最后设置它。相反,内容在检查时按顺序设置。我认为它使代码更短,更容易理解/修改:

在此处输入图片描述

\documentclass[12pt,letterpaper]{moderncv}
\moderncvstyle{banking}
\moderncvcolor{blue}
\usepackage{libertine}
\usepackage[scale=0.75]{geometry}

\makeatletter
\renewcommand*{\maketitle}{%
  \setlength{\maketitlewidth}{\textwidth}%
  \parbox{\maketitlewidth}{%
    \raggedright% NEW
    \namestyle{\@firstname~\@lastname}% name and title
    \\% \isundefined doesn't work on \@title, as LaTeX itself defines \@title (before it possibly gets redefined by \title)
    % detailed information
    \addressfont\color{color2}%
    \begin{tabular}{@{}p{\linewidth}@{}}
      \ifthenelse{\isundefined{\@addressstreet}}{}{\addresssymbol\@addressstreet \par}%
      \ifthenelse{\equal{\@addresscity}{}}{}{\@addresscity \par}% if \addresstreet is defined, \addresscity and \addresscountry will always be defined but could be empty
      \ifthenelse{\equal{\@addresscountry}{}}{}{\@addresscountry \par}%
      \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
        \csname\collectionloopkey phonesymbol\endcsname\collectionloopitem \endgraf}%
      \ifthenelse{\isundefined{\@email}}{}{\emailsymbol\emaillink{\@email} \par}%
      \ifthenelse{\isundefined{\@homepage}}{}{\homepagesymbol\httplink{\@homepage}}%
    \end{tabular}}\\[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 \maketitle
\makeatother

\name{John}{Doe}
\address{street and number}{postcode city}{country}
\phone[mobile]{+1~(234)~567~890}
\phone[fixed]{+2~(345)~678~901}
\phone[fax]{+3~(456)~789~012}
\email{[email protected]}
\homepage{www.johndoe.com}
\quote{Some quote}

\begin{document}
\makecvtitle

\section{A test section}
Some test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text
\end{document}

以下版本\maketitle提供了左右对齐的详细信息:

在此处输入图片描述

\makeatletter
\renewcommand*{\maketitle}{%
  \setlength{\maketitlewidth}{\textwidth}%
  \parbox{\maketitlewidth}{%
    \raggedright% NEW
    \namestyle{\@firstname~\@lastname}% name and title
    \\% \isundefined doesn't work on \@title, as LaTeX itself defines \@title (before it possibly gets redefined by \title)
    % detailed information
    \addressfont\color{color2}%
    \begin{tabular}{@{}p{.5\linewidth}@{}p{.5\linewidth}@{}}
      \ifthenelse{\isundefined{\@addressstreet}}{}{\addresssymbol\@addressstreet \par}%
      \ifthenelse{\equal{\@addresscity}{}}{}{\@addresscity \par}% if \addresstreet is defined, \addresscity and \addresscountry will always be defined but could be empty
      \ifthenelse{\equal{\@addresscountry}{}}{}{\@addresscountry} &%
      \raggedleft% For right-aligned content
      \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
        \csname\collectionloopkey phonesymbol\endcsname\collectionloopitem \endgraf}%
      \ifthenelse{\isundefined{\@email}}{}{\emailsymbol\emaillink{\@email} \par}%
      \ifthenelse{\isundefined{\@homepage}}{}{\homepagesymbol\httplink{\@homepage}}%
    \end{tabular}}\\[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 \maketitle
\makeatother

相关内容