2

I am trying to create my cover letter with class moderncv but I don't quite know how to move the name, address, phone, email to the top center of the page. I would like to make it look like the one in second picture (it's a screenshot of a word document).

\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{john@doe.com}                             


\begin{document}

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

enter image description here

That is want I want to get:

enter image description here

EDIT:

Thank you again for the suggestion. I have almost everything I need for the cover letter except for the address part. When I add the address below name, it creates space between the address and the phone/email. I tried reducing the space but it didn't work. How can I reduce the space? Thanks!

% personal data
\name{John}{Doe}
\address{111 nowhere street}{nowhere, nw}{11111}
\phone {(111)-111-111}
\email{johndoe@johndoe.com}

enter image description here

  • Welcome to TeX.SX! Probably you are more satisfied with the banking style. For an example output see here: mirror.physik-pool.tu-berlin.de/pub/CTAN/macros/latex/contrib/… – leandriis Jul 29 '19 at 18:09
  • Yeah, banking style sounds good. However, it is a resume and I'm looking to integrate that style on my cover letter. – Akboh Jul 29 '19 at 18:39
  • Page 4 of the above mentioned example document shows the corresponding cover letter. – leandriis Jul 29 '19 at 18:44
  • @leandriis where do I find that template? edit: I found it. – Akboh Jul 30 '19 at 1:24
  • If you like my answer and it was helpful, please consider upvoting (by clicking on the arrows next to the score) and/or marking it as the accepted answer (by clicking on the checkmark ✓). That is the way here to say "Thank you for your help!" – Mensch Aug 19 '19 at 17:54
1

The issue here has two parts:

  1. Choose the right/best layout for the cover letter
  2. Add the title at the proper place

Because you did not tell us if you build your cv and the cover letter in one file I guess you do ...

So you have first to change for the cover letter the used head (it is easier to use an already existing layout than to complete rewrite the code for the header ...) like this:

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

Command \moderncvhead{3} uses the header used in style banking and with the following patchcmd I simply deleted the predefined title. We add the missing title with the code:

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

Please see that \makeatletter and \makeatother are needed to be able to use @ in the code ...

Of course you can use another value instead my used 2em to define the space between the title and the following To: in line

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

So please see the following complete 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{john@doe.com}

\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}

and its result:

resulting cover letter

EDIT (for first comment):

To get a smaller gap between the name and the jobtitle add the following code

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

Change my used [1em] to a value fitting your needs ...

See the complete 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{john@doe.com}

\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}

and its result:

result two

EDIT (for your edit in question):

You need to add another patch to the code:

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

With the complete 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{johndoe@johndoe.com}

\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}

you get:

result three

  • Thanks for the suggestion and the cover letter is a separate document. It is not part of the resume. I was able to add the title/headline below my address. However, there is a big gap between the name and the title of the job. How do I reduce it? – Akboh Jul 30 '19 at 2:46
  • Thanks for the suggestion. I have one more question when I add address below the name, it creates a space between the address and the phone/email. How do I reduce the space between the address and phone/email? As for the resume, I already made a post. You replied to that post with a link to adding a line below the name/address. However, I want to add the "title of the job" below the address just like the cover letter. Here is the link to the post: tex.stackexchange.com/questions/501996/… – Akboh Jul 30 '19 at 15:33
  • @AbhinavKonagala Please do not use this outdated class resume.cls and please note the code you gave there is not compilable!). Why do you not use class moderncv for your cv too, then you can keep cover letter and cv in one file ... – Mensch Jul 30 '19 at 15:41

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .