编辑:

编辑:

我正在尝试创建带有类的求职信moderncv,但我不知道如何将姓名、地址、电话、电子邮件移到页面顶部中央。我想让它看起来像第二张图片中的那样(这是 Word 文档的屏幕截图)。

\documentclass[11pt,a4paper,roman]{moderncv}      
\usepackage[english]{babel}


\moderncvstyle{classic}                            
\moderncvcolor{green}                            

% character encoding
\usepackage[utf8]{inputenc}                     

% adjust the page margins
\usepackage[scale=0.75]{geometry}

% personal data
\name{John}{Doe}

\phone[mobile]{0123-123456789}               
\email{[email protected]}                             


\begin{document}

\recipient{To}{Employer}
\date{\today}
\opening{Hi!}
\closing{Thanks in advance!}
\enclosure[Attachment]{CV}
\makelettertitle

在此处输入图片描述

这就是我想要得到的:

在此处输入图片描述

编辑:

再次感谢您的建议。除了地址部分,我几乎已经准备好了求职信所需的一切。当我在姓名下方添加地址时,地址和电话/电子邮件之间会产生空格。我尝试减少空格,但没有成功。我该如何减少空格?谢谢!

% personal data
\name{John}{Doe}
\address{111 nowhere street}{nowhere, nw}{11111}
\phone {(111)-111-111}
\email{[email protected]}

在此处输入图片描述

答案1

这里的问题分为两部分:

  1. 选择正确/最佳的求职信布局
  2. 在适当的位置添加标题

因为你没有告诉我们你是否将你的简历和求职信放在一个文件中,所以我猜你会……

因此,您必须首先更改封面信中使用的标题(使用现有的布局比完全重写标题代码更容易......)如下所示:

\title{title of the job} % <============================================
\moderncvhead{3} % <====================================================
\makeatletter
\patchcmd{\makehead}%
  {\ifthenelse{\equal{\@title}{}}{}{\titlestyle{~|~\@title}}\\}%
  {\ifthenelse{\equal{\@title}{}}{}{\\}}% <=============================
  {}%
  {}

命令\moderncvhead{3}使用样式中使用的标题banking,下面patchcmd我简单地删除了预定义的标题。我们使用代码添加缺失的标题:

\patchcmd{\makeletterhead}%
  {\par}%
  {%
    \par%
      \textbf{\@title}\\[2em]% <==========================================
  }%
  {}%
  {}
\makeatother

请查看\makeatletter并且\makeatother需要能够@在代码中使用...

当然,你可以使用另一个值来代替,2em用于定义标题和To:行内以下内容之间的空间

\textbf{\@title}\\[2em]% <==========================================

因此,请参阅以下完整的 mwe

\documentclass[11pt,a4paper,roman]{moderncv}

\usepackage[english]{babel}
\usepackage{blindtext}

\moderncvstyle{classic} % <================================ classic banking head 3, body 3
\moderncvcolor{green}

% character encoding
\usepackage[utf8]{inputenc}

% adjust the page margins
\usepackage[scale=0.75]{geometry}

% personal data
\name{John}{Doe}

\phone[mobile]{0123-123456789}
\email{[email protected]}

\title{title of the job} % <============================================
\moderncvhead{3} % <====================================================
\makeatletter
\patchcmd{\makehead}%
  {\ifthenelse{\equal{\@title}{}}{}{\titlestyle{~|~\@title}}\\}%
  {\ifthenelse{\equal{\@title}{}}{}{\\}}% <=============================
  {}%
  {error}

\patchcmd{\makeletterhead}%
  {\par}%
  {%
    \par%
    \textbf{\@title}\\[2em]% <==========================================
  }%
  {}%
  {}
\makeatother


\begin{document}

\recipient{To}{Employer}
\date{\today}
\opening{Hi!}
\closing{Thanks in advance!}
\enclosure[Attachment]{CV}
\makelettertitle

\blindtext
\end{document}

及其结果:

由此产生的求职信

编辑(针对第一条评论):

为了缩小姓名和职位之间的差距,请添加以下代码

\patchcmd{\makehead}%
  {\\[2.5em]}%
  {\\[1em]}% <=============================
  {}%
  {}

将我的习惯更改[1em]为适合您需要的值......

查看完整的 mwe

\documentclass[11pt,a4paper,roman]{moderncv}

\usepackage[english]{babel}
\usepackage{blindtext}

\moderncvstyle{classic} % <================================ classic banking head 3, body 3
\moderncvcolor{green}

% character encoding
\usepackage[utf8]{inputenc}

% adjust the page margins
\usepackage[scale=0.75]{geometry}

% personal data
\name{John}{Doe}

\phone[mobile]{0123-123456789}
\email{[email protected]}

\title{title of the job} % <============================================
\moderncvhead{3} % <====================================================
\makeatletter
\patchcmd{\makehead}%
  {\ifthenelse{\equal{\@title}{}}{}{\titlestyle{~|~\@title}}\\}%
  {\ifthenelse{\equal{\@title}{}}{}{\\}}% <=============================
  {}%
  {}

\patchcmd{\makehead}% <=================================================
  {\\[2.5em]}%
  {\\[1em]}% <=============================
  {}%
  {}

\patchcmd{\makeletterhead}%
  {\par}%
  {%
    \par%
    \textbf{\@title}\\[2em]% <==========================================
  }%
  {}%
  {}
\makeatother


\begin{document}

\recipient{To}{Employer}
\date{\today}
\opening{Hi!}
\closing{Thanks in advance!}
\enclosure[Attachment]{CV}
\makelettertitle

\blindtext
\end{document}

及其结果:

结果二

编辑(针对您所讨论的编辑):

您需要在代码中添加另一个补丁:

\patchcmd{\makehead}% <=================================================
  {\\\null}%
  {\\}% <=============================
  {}%
  {}

拥有完整的mwe

\documentclass[11pt,a4paper,roman]{moderncv}

\usepackage[english]{babel}
\usepackage{blindtext}

\moderncvstyle{classic} % <================================ classic banking head 3, body 3
\moderncvcolor{green}

% character encoding
\usepackage[utf8]{inputenc}

% adjust the page margins
\usepackage[scale=0.75]{geometry}

% personal data
\name{John}{Doe}
\address{111 nowhere street}{nowhere, nw}{11111}
\phone {(111)-111-111}
\email{[email protected]}

\title{title of the job} % <============================================
\moderncvhead{3} % <====================================================
\makeatletter
\patchcmd{\makehead}%
  {\ifthenelse{\equal{\@title}{}}{}{\titlestyle{~|~\@title}}\\}%
  {\ifthenelse{\equal{\@title}{}}{}{\\}}% <=============================
  {}%
  {}

\patchcmd{\makehead}% <=================================================
  {\\[2.5em]}%
  {\\[1em]}% <=============================
  {}%
  {}

\patchcmd{\makehead}% <=================================================
  {\\\null}%
  {\\}% <=============================
  {}%
  {}

\patchcmd{\makeletterhead}%
  {\par}%
  {%
    \par%
    \textbf{\@title}\\[2em]% <==========================================
  }%
  {}%
  {}
\makeatother


\begin{document}

\recipient{To}{Employer}
\date{\today}
\opening{Hi!}
\closing{Thanks in advance!}
\enclosure[Attachment]{CV}
\makelettertitle

\blindtext
\end{document}

你得到:

结果三

相关内容