4

Is it possible to automatically add a place to the date and print it in the upper right corner of my cover letter generated from moderncv. Here is a minimum working example

\documentclass[11pt,a4paper,sans]{moderncv} 
\moderncvstyle{classic} 
\moderncvcolor{blue} 
\usepackage{lipsum} 

\usepackage[scale=0.75]{geometry} 
\usepackage[english]{babel}
\usepackage{blindtext}
%%%%%%%%%%%%%%%%%%%
\usepackage{etoolbox}
\patchcmd{\makelettertitle}{\hfill}{}{}{}
\patchcmd{\makelettertitle}{\raggedleft}{\raggedright}{}{}

\firstname{XXXXXX} % Your first name
\familyname{XXXXXX} 
\title{CV}
\address{XXXXXX,12}{12345,XXXXXX}
\email{[email protected]}

\begin{document}
\recipient{XXXX}{XXXX\\XXXXXXXXXXXX\\1234 XXXXXX\\XXXXXX} 
\date{\today} % Letter date
\opening{blablabla,} % Opening greeting
\closing{blablabla} % Closing phrase
\enclosure[Im Anhang]{CV} % List of enclosed documents
\makelettertitle % Print letter title
\blindtext[3]
\makeletterclosing % Print letter signature
\clearpage
\end{document}

and the outcome:

enter image description here

1 Answer 1

4

The content of \date doesn't have to be a date per se. As such, specify your \date using something like

\date{Place name, January 01, 1984}

enter image description here

or

\date{%
  \begin{tabular}[t]{l@{}}
    Place name \\
    January 01, 1984
  \end{tabular}}

This will ensure a [t]op-aligned, multi-row placement of a date "object":

enter image description here

The above outputs stems from using the moderncv template with the above \date usages.


For a more complicated setup, you can insert the \@date as part of the recipient address. A complete copy-and-paste of the \makelettertitle would be okay if you wish to make a lot of changes, rather than patching using etoolbox:

enter image description here

\documentclass[11pt,a4paper,sans]{moderncv} 
\moderncvstyle{classic} 
\moderncvcolor{blue} 
\usepackage{lipsum} 

\usepackage[scale=0.75]{geometry} 
\usepackage[english]{babel}
\usepackage{blindtext}
%%%%%%%%%%%%%%%%%%%

\makeatletter

\renewcommand*{\makelettertitle}{%
  % recompute lengths (in case we are switching from letter to resume, or vice versa)
  \recomputeletterlengths%
  % sender contact info
  %\hfill%
  \begin{minipage}{.5\textwidth}%
    \raggedright% \raggedleft
    \addressfont\textcolor{color2}{%
      \makebox[\textwidth][l]{\makebox[2\textwidth]{\bfseries\upshape\@firstname~\@lastname\hfill\normalfont\textcolor{black}{\@date}}}\@firstdetailselementfalse%
      \ifthenelse{\isundefined{\@addressstreet}}{}{\makenewline\addresssymbol\@addressstreet%
        \ifthenelse{\equal{\@addresscity}{}}{}{\makenewline\@addresscity}% if \addresstreet is defined, \addresscity and addresscountry will always be defined but could be empty
        \ifthenelse{\equal{\@addresscountry}{}}{}{\makenewline\@addresscountry}}%
      \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
        \makenewline\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}%
      \ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
      \ifthenelse{\isundefined{\@homepage}}{}{\makenewline\homepagesymbol\httplink{\@homepage}}%
      \ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}}%
    \end{minipage}\\[1em]
  % recipient block
  \begin{minipage}[t]{.5\textwidth}
    \raggedright%
    \addressfont%
    {\bfseries\upshape\@recipientname}\\%
    \@recipientaddress%
  \end{minipage} \\[2em]
  % date
  %\hfill% US style
%  \\[1em]% UK style
  %\@date\\[2em]% US informal style: "January 1, 1900"; UK formal style: "01/01/1900"
  % opening
  \raggedright%
  \@opening\\[1.5em]%
  % ensure no extra spacing after \makelettertitle due to a possible blank line
%  \ignorespacesafterend% not working
  \hspace{0pt}\par\vspace{-\baselineskip}\vspace{-\parskip}}

\makeatother


\firstname{XXXXXX} % Your first name
\familyname{XXXXXX} 
\title{CV}
\address{XXXXXX,12}{12345,XXXXXX}
\email{[email protected]}

\begin{document}
\recipient{XXXX}{XXXX\\XXXXXXXXXXXX\\1234 XXXXXX\\XXXXXX} 
\date{\today} % Letter date
\opening{blablabla,} % Opening greeting
\closing{blablabla} % Closing phrase
\enclosure[Im Anhang]{CV} % List of enclosed documents

\makelettertitle % Print letter title
\blindtext[3]
\makeletterclosing % Print letter signature
\clearpage
\end{document}
4
  • this is almost what I want. But the date and place are placed in front of the recipient. I want them to be placed ín front of my personal data. Commented Jun 4, 2015 at 20:58
  • @user2536125: Great. Can you please provide a minimal working example (MWE) so I know what you're referring to? Please click on the aforementioned link and read through it so you can supply a proper MWE. We want to copy-and-paste-and-compile what you supply and see exactly what you see. It should start with \documentclass and end with \end{document}.
    – Werner
    Commented Jun 4, 2015 at 20:59
  • The MWE is added. Commented Jun 5, 2015 at 5:40
  • @user2536125: I've added an update to the solution which addresses your current date-placement request.
    – Werner
    Commented Jun 6, 2015 at 17:34

You must log in to answer this question.

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