2

enter image description hereI am trying to write a cover letter, however

1) I am not able to remove the additional symbols of fax and mobile. 2) How can I align the receiver's information to the right of the page ?

can you please help, I would be very very thankful. Below is my code:

\documentclass[10pt,a4paper,roman]{moderncv}        % possible options 
include font size ('10pt', '11pt' and '12pt'), paper size ('a4paper', 
'letterpaper', 'a5paper', 'legalpaper', 'executivepaper' and 'landscape') 
and font family ('sans' and 'roman')
\moderncvstyle{classic}                            % style options are 
'casual' (default), 'classic', 'oldstyle' and 'banking'
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
%\makeatletter
%\patchcmd{\makeletterhead}% <cmd>
%{\raggedright \@opening}% <search>
%{\@opening}% <replace>
%{}{}% <success><failure>
\makeatother
\usepackage{enumerate}
\moderncvcolor{green}                              % color options 'blue'         
(default), 
\usepackage[utf8]{inputenc}
\usepackage{chemformula}    
% adjust the page margins
\usepackage[scale=0.75]{geometry}
\usepackage{siunitx}
\AfterPreamble{\hypersetup{
colorlinks=true,
linkcolor=blue,
filecolor=magenta,      
urlcolor=blue,
}}
\usepackage{color}
%\usepackage{wasysym}
%\usepackage[misc]{ifsym}

     % personal data
  %Corresponding Author
 \name{\color{black}Somya}{Gupta}
  \phone{\color{black}+32-xxx-xxx-xxx}
  \email{email here}  
                      % optional, remove / 

\usepackage{etoolbox}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0.2pt}
\makeatletter
\patchcmd{\f@nch@head}{\rlap}{\color{red}\rlap}{}{}
\patchcmd{\headrule}{\hrule}{\color{red}\hrule}{}{}
\patchcmd{\f@nch@foot}{\rlap}{\color{gray}\rlap}{}{}
\patchcmd{\footrule}{\hrule}{\color{gray}\hrule}{}{}
\makeatother

\rfoot{ \fontsize{9}{12} \selectfont Register of Legal Entities \\ VAT BE         xx. xx. xx \\ Phone: xx xx xx xx}
\lfoot{\fontsize{9}{12} \selectfont \textbf{company} \\address \\ city \\ country}   


\makeatletter
%---------------------------------------------------------------------------    ----
%                letter style definition
%-------------------------------------------------------------------------------
% commands
\renewcommand*{\recomputeletterlengths}{%
\recomputecvlengths%
\setlength{\parskip}{6\p@}}

\newcommand*{\subject}[1]{\def\@subject{#1}}                    %% new     command added

\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%                               %%% \reggedleft changed to     raggedright                    
    \addressfont\textcolor{color2}{%            %%% change color here if you     want it black or...

   {\bfseries\upshape\@firstname~\@familyname}\@firstdetailselementfalse%
        \ifthenelse{\isundefined{\@addressstreet}}{}    
   {\makenewline\addresssymbol\@addressstreet%
            \ifthenelse{\equal{\@addresscity}{}}{}
   {\makenewline\@addresscity}}%
        \ifthenelse{\isundefined{\@mobile}}{}
   {\makenewline\mobilesymbol\@mobile}%
        \ifthenelse{\isundefined{\@phone}}{}{\makenewline\phonesymbol\@phone}%
        \ifthenelse{\isundefined{\@fax}}{}{\makenewline\faxsymbol\@fax}%
        \ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
        \ifthenelse{\isundefined{\@homepage}}{}{\makenewline\homepagesymbol\httplink{\@homepage}}%
        \ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}}%
\end{minipage}\\[2em]
% recipient block
Attention: \quad \begin{minipage}[t]{.5\textwidth}   
     \raggedright%
    \addressfont%
    {\bfseries\upshape\@recipientname}\\%
    \@recipientaddress\\[2em]%
    \@date\\[1.5em]%                                                  %%% Changed here
\end{minipage}
 % date
 \hfill% US style
%  \\[1em]% UK style
\null\\[2em]%                                                         %%%     Changed here    
\raggedright%
\ifthenelse{\isundefined{\@subject}}{}{%                              %% new command added
\begin{tabular}{ p{0.08\textwidth} p{0.92\textwidth} }
\textbf{Title}: & \@subject
\end{tabular}
\\[1.5em]}%
% opening
\raggedright%
\@opening\\[1.5em]%
[![enter image description here][1]][1]\hspace{0pt}\par\vspace{-\baselineskip}\vspace{-\parskip}}

     \renewcommand*{\makeletterclosing}{
        \@closing\\[3em]%
    {\bfseries \@firstname~\@familyname}%
    \ifthenelse{\isundefined{\@enclosure}}{}{%
    \\%
    \vfill%
    {\color{color2}\itshape\enclname: \@enclosure}}}
   \makeatother


\begin{document}
    \begin{flushleft}
    \includegraphics[width=0.16\linewidth]{logo}
    \end{flushleft}
  \recipient{Nano Letters}{ACS Publications} 
  \date{\today}
 \opening{Dear Editor,}
 \closing{Sincerely,}
 \subject{Title/subject of the letter}
\enclosure[Attached]{curriculum vit\ae{}}
\makelettertitle
\noindent

The content here .. 
\vspace{0.5cm}


\makeletterclosing

\end{document}


   %% end of file `template.tex'.
0
2

Please check which version of class moderncv you use! The current one is version 2.0.0.

For example the command for the phone \phone (old) has changed with current version to

\phone[fixed]{\color{black}+32-xxx-xxx-xxx} % <====================

With the following MWE (see important code changings marked with <=======)

%\listfiles %        to check used packages and version numbers
\documentclass[10pt,a4paper,roman]{moderncv}

\moderncvstyle{classic} % head[left,right] 1; body 1; foot
\moderncvcolor{green}

\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\usepackage{enumerate}


\usepackage[utf8]{inputenc}
\usepackage{chemformula}
% adjust the page margins
\usepackage[scale=0.75]{geometry}
\usepackage{siunitx}
\AfterPreamble{%
  \hypersetup{%
  colorlinks=true,
  linkcolor=blue,
  filecolor=magenta,
  urlcolor=blue,
}}
\usepackage{color}
%\usepackage{wasysym}
%\usepackage[misc]{ifsym}

% personal data
\name{\color{black}Somya}{Gupta}
\phone[fixed]{\color{black}+32-xxx-xxx-xxx} % <====================
\email{email here}  

\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0.2pt}
\makeatletter
\patchcmd{\f@nch@head}{\rlap}{\color{red}\rlap}{}{}
\patchcmd{\headrule}{\hrule}{\color{red}\hrule}{}{}
\patchcmd{\f@nch@foot}{\rlap}{\color{gray}\rlap}{}{}
\patchcmd{\footrule}{\hrule}{\color{gray}\hrule}{}{}
\makeatother

\rfoot{ \fontsize{9}{12} \selectfont Register of Legal Entities \\ VAT BE         xx. xx. xx \\ Phone: xx xx xx xx}
\lfoot{\fontsize{9}{12} \selectfont \textbf{company} \\address \\ city \\ country}   


\makeatletter
%---------------------------------------------------------------------------    ----
%                letter style definition
%-------------------------------------------------------------------------------
% commands
\renewcommand*{\recomputeletterlengths}{%
\recomputecvlengths%
\setlength{\parskip}{6\p@}}

\newcommand*{\subject}[1]{\def\@subject{#1}}                    %% new     command added

\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%                               %%% \reggedleft changed to     raggedright                    
  \addressfont\textcolor{color2}{%            %%% change color here if you     want it black or...
    {\bfseries\upshape\@firstname~\@familyname}\@firstdetailselementfalse%
    \ifthenelse{\isundefined{\@addressstreet}}{}{\makenewline\addresssymbol\@addressstreet%
      \ifthenelse{\equal{\@addresscity}{}}{}{\makenewline\@addresscity}}%
%   \ifthenelse{\isundefined{\@mobile}}{}{\makenewline\mobilesymbol\@mobile}% <=============
    \ifthenelse{\isundefined{\@phone}}{}{\makenewline\phonesymbol\@phone}%
%   \ifthenelse{\isundefined{\@fax}}{}{\makenewline\faxsymbol\@fax}% <======================
    \ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
    \ifthenelse{\isundefined{\@homepage}}{}{\makenewline\homepagesymbol\httplink{\@homepage}}%
    \ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}%
  }% <====================
\end{minipage}\\[2em]
% recipient bloc
\begin{minipage}[t]{\textwidth} % <=====================================
  \raggedleft% <========================================================
  \addressfont%
  {Attention: \hfill \bfseries\upshape\@recipientname}\\% <=============
  \@recipientaddress\\[2em]%
  \@date\\[1.5em]%                                                  %%% Changed here
\end{minipage}
 % date
 \hfill% US style
%  \\[1em]% UK style
\null\\[2em]%                                                         %%%     Changed here    
\raggedright%
\ifthenelse{\isundefined{\@subject}}{}{%                              %% new command added
  \begin{tabular}{ p{0.08\textwidth} p{0.92\textwidth} }
  \textbf{Title}: & \@subject
  \end{tabular}\\[1.5em]%
}%
% opening
\raggedright%
\@opening\\[1.5em]%
\hspace{0pt}\par\vspace{-\baselineskip}\vspace{-\parskip}}

\renewcommand*{\makeletterclosing}{%
  \@closing\\[3em]%
  {\bfseries \@firstname~\@familyname}%
  \ifthenelse{\isundefined{\@enclosure}}{}{%
    \\%
    \vfill%
    {\color{color2}\itshape\enclname: \@enclosure}%
  }%
}
\makeatother


\begin{document}

\begin{flushleft}
  \includegraphics[width=0.16\linewidth]{example-image-a}
\end{flushleft}
\recipient{Nano Letters}{ACS Publications} 
\date{\today}
\opening{Dear Editor,}
\closing{Sincerely,}
\subject{Subject of the letter}
\enclosure[Attached]{curriculum vit\ae{}}

\makelettertitle
\noindent

The content here .. 
\vspace{0.5cm}


\makeletterclosing

\end{document}

you get the (I think) wished result:

resulting pdf

Because your used version is not clear I simply commented the display of mobile and fax number. If you want an automatic solution we need to know which version of moderncv you use or simply update to current version 2.0.0.

To check which packages and version you use you can add command \listfiles as first line to your code, compile 3 times and check then the log file. There you will find an list of used packages and versions. Please copy it and add it to your question.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.