moderncvstyle经典如何解决名称错误?

moderncvstyle经典如何解决名称错误?

在此处输入图片描述我正在尝试写一封求职信,但是

1) 我无法删除传真和手机的附加符号。 2) 如何将收件人的信息对齐到页面右侧?

你能帮忙吗?我将非常非常感激。以下是我的代码:

\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'.

答案1

请检查您使用的课​​程版本moderncv!当前版本是 2.0.0。

例如,手机(旧版)的命令\phone已随当前版本更改为

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

使用以下 MWE(参见标有 的重要代码更改<=======

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

你得到了(我认为)期望的结果:

生成的 pdf

因为不清楚您使用的版本,所以我只注释了手机和传真号码的显示。如果您想要自动解决方案,我们需要知道moderncv您使用的是哪个版本,或者只需更新到当前版本 2.0.0。

要检查您使用的软件包和版本,您可以将命令\listfiles作为代码的第一行添加,编译 3 次,然后检查日志文件。在那里,您将找到所用软件包和版本的列表。请复制它并将其添加到您的问题中。

相关内容