8

I am using moderncv templates, on cover letter page i wanted to edit the original code so that the Name/mobile/email appears on top right corner,
enter image description here
but the Build process return the error: There's no line here to end. \makelettertitle Here is the location that error is happening, if i put any character in \recipient{}{} line such as \recipient{'}{} the error would be solved,but the character will be shown in the result,which i don't want it, i searched for similar cases but none of the solutions given helped, is there any solution for it if i don't want to use \recipient ? (I have tried removing it from the code but it didn't work) The code:

\documentclass{moderncv}
\moderncvstyle{classic}
\moderncvcolor{blue}
\usepackage[scale=0.75]{geometry}
\firstname{John} % Your first name
\familyname{Smith} % Your last name
\title{Curriculum Vitae}
\mobile{(+1) 123 456 7890}
\email{john.smith@gmail.com}
\begin{document}
\clearpage
\recipient{}{} % Letter recipient
\date{\today} % Letter date
\opening{Dear Sir, Madam,} % Opening greeting
\closing{Sincerely yours,} % Closing phrase
\enclosure[Attached]{curriculum vit\ae{}} % List of enclosed documents
\makelettertitle % Print letter title
I am an engineer

\makeletterclosing

\end{document}

and the content of class file is:

\newcommand{\recipient}[2]{\def\@recipientname{#1}\def\@recipientaddress{#2}}
\renewcommand*{\date}[1]{\def\@date{#1}}\date{\today}
\newcommand{\opening}[1]{\def\@opening{#1}}
\newcommand*{\closing}[1]{\def\@closing{#1}}
\newcommand*{\enclosure}[2][]{%
  % if an optional argument is provided, use it to redefine \enclname
  \ifthenelse{\equal{#1}{}}{}{\renewcommand*{\enclname}{#1}}%
  \def\@enclosure{#2}}

2 Answers2

7

The class loads the auxiliary package moderncvheadi.sty, which has

  \begin{minipage}[t]{.5\textwidth}
    \raggedright%
    \addressfont%
    {\bfseries\upshape\@recipientname}\\%
    \@recipientaddress%
  \end{minipage}

and this means that if \@recipientname is empty, you get the usual error of a lone \\, that is There's no line to end.

Solution:

\recipient{\mbox{}}{}

which will make the line non empty, as far as \\ is concerned.

egreg
  • 1,121,712
  • 1
    My \recipient is not empty yet I still get this message. – user134593 Aug 06 '20 at 08:50
  • @user134593 I tried the original code with \recipient{x}{y} and get no error. – egreg Aug 06 '20 at 08:55
  • It's really strange too because I used it on this exact PC with this exact installation and file before and don't remember an error. Perhaps it's a side effect of intermediary files, but I deleted the .aux file, and still no dice. Well at least it produces a usable PDF output. – user134593 Aug 06 '20 at 08:58
3

Usually, if you write an letter, you need a recipient. If you want to leave the empty you have to mark the recipient empty. The character ~ marks an unbreakable space and you can use it for your purpose.

So \recipient{~}{~} get's you rid of the error message no line to end.

Mensch
  • 65,388