我想知道,我有点绝望,如何将我的顶部个人数据移到左侧,并删除底部的我的名字?
\documentclass[11pt,a4paper,roman]{moderncv}
\usepackage[french]{babel}
\usepackage[utf8]{inputenc}
\moderncvstyle{classic}
\moderncvcolor{green}
\nopagenumbers{}
\usepackage[scale=0.75]{geometry}
\usepackage{etoolbox}
\usepackage{lipsum}
\name{\Large {Michel}}{\Large {Dupont}}
\title{Resumé title}
\address{1, Rue de France}{Paris — 75000}{France}
\phone[mobile]{06 11 11 11 11}
\email{[email protected]}
\begin{document}
\recipient{Destinatario}{Departamento, Empresa}
\date{le \today}
\opening{Estimado Destinatario,}
\raggedleft{
\closing{Muchas gracias por su tiempo e interés y reciba un cordial saludo.}
\enclosure[Adjunto]{CV}
\makelettertitle
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque ultrices ultricies sapien et vehicula. Sed ut quam mattis, dignissim augue et, volutpat libero. Nulla facilisi. Nulla facilisi. Suspendisse eu libero ac mi tincidunt ullamcorper eu id risus. Maecenas dignissim tortor ac tellus tristique, et hendrerit risus finibus. Morbi rhoncus, ex in placerat lacinia, justo tortor posuere ipsum, ac scelerisque urna lectus porttitor quam. Quisque quis neque massa. Aenean metus ante, lacinia vitae eros ut, porta ullamcorper mi. Sed varius bibendum interdum. Aenean at ligula iaculis nulla egestas tristique sit amet eget eros. Nam tincidunt tempor neque a sollicitudin. Integer risus sapien, tempor vel congue eget, mattis sed mi. Nullam condimentum imperdiet pulvinar.
Nam in mi sagittis, rhoncus nisl id, elementum tortor. Pellentesque id risus laoreet mi ullamcorper gravida. Nunc eget orci vitae eros efficitur consectetur a porttitor urna. Suspendisse dapibus sapien ac nulla tincidunt fermentum. Suspendisse eleifend iaculis ex et porta. Morbi at dignissim velit. Nunc non lacus ut arcu luctus dapibus. Nulla facilisis vehicula ligula non malesuada. Sed fermentum placerat mi eu finibus. Morbi nulla velit, volutpat quis efficitur in, vestibulum sed odio. In tempus, quam quis bibendum iaculis, nulla mauris rutrum leo, pellentesque molestie est lacus ut neque. Integer luctus elementum ipsum sed molestie. Vestibulum non rutrum enim. Nulla iaculis finibus elementum. Phasellus faucibus ante et pretium semper.
Morbi volutpat in ligula ut blandit. Vivamus et arcu venenatis, faucibus ante nec, suscipit dolor. Duis id molestie sapien, nec dictum ante. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut at ante sem. Ut porttitor, tortor at convallis convallis, neque mi convallis ipsum, vel ultrices enim dolor sed diam. In dictum vulputate massa id molestie. Donec sollicitudin nisi vestibulum diam varius aliquet.
\vspace{0.6cm}
\makeletterclosing
\end{document}
结果:
答案1
步骤1:
要在类中更改moderncv
发送方数据的位置,您必须找到定义数据的部分。您将找到一个minipage
,我们可以使用环境flushleft
(以下代码中的第 3 行和第 14 行)将个人数据移到左侧。使用\hfill
(参见第 5 行)我们可以将名称移到右侧。看到原始小页面只有文本宽度的一半长,我将其更改为总文本宽度(第 2 行)。
我更改的代码的重要部分(标记为<=========
)是:
% sender contact info
\begin{minipage}{\textwidth}% <=======================================
\begin{flushleft}% <================================================
\addressfont\textcolor{color2}{%
{\hfill\bfseries\upshape\@firstname~\@lastname}\@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{flushleft}% <================================================
\end{minipage}\\[1em]
为了能够更改 moderncv 中使用的代码,我们只需复制从 moderncv 中取出部分,并在加载代码中的最后一个包后将其插入。然后我们可以进行上面显示的更改。
完整的、编译的 MWE 具有您想要的结果(更改的行用 标记;您会在两个命令之间找到< =========
添加的代码,我们需要在命令中使用字母):moderncv
\makeatletter
\makeatother
@
\documentclass[11pt,a4paper,roman]{moderncv}
\usepackage[french]{babel} % error french
\usepackage[utf8]{inputenc}
\moderncvstyle{classic}
\moderncvcolor{green}
\nopagenumbers{}
\usepackage[scale=0.75]{geometry}
\makeatletter
\renewcommand*{\makelettertitle}{%
% recompute lengths (in case we are switching from letter to resume, or vice versa)
\recomputeletterlengths%
% sender contact info
\begin{minipage}{\textwidth}% <=======================================
\begin{flushleft}% <================================================
\addressfont\textcolor{color2}{%
{\hfill\bfseries\upshape\@firstname~\@lastname}\@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{flushleft}% <================================================
\end{minipage}\\[1em]
% recipient block
\begin{minipage}[t]{.5\textwidth}
\raggedright%
\addressfont%
{\bfseries\upshape\@recipientname}\\%
\@recipientaddress%
\end{minipage}
% 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}}
\renewcommand*{\makeletterclosing}{
\@closing\\[3em]%
\ifthenelse{\isundefined{\@enclosure}}{}{%
\vfill%
{\color{color2}\itshape\enclname: \@enclosure}}}
\makeatother
\name{\Large {Michel}}{\Large {Dupont}}
\title{Resumé title}
\address{1, Rue de France}{Paris — 75000}{France}
\phone[mobile]{06 11 11 11 11}
\email{[email protected]}
\begin{document}
\recipient{Destinatario}{Departamento, Empresa}
\date{le \today}
\opening{Estimado Destinatario,}
\raggedleft{
\closing{Muchas gracias por su tiempo e interés y reciba un cordial saludo.}
\enclosure[Adjunto]{CV}
\makelettertitle
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque ultrices ultricies sapien et vehicula. Sed ut quam mattis, dignissim augue et, volutpat libero. Nulla facilisi. Nulla facilisi. Suspendisse eu libero ac mi tincidunt ullamcorper eu id risus. Maecenas dignissim tortor ac tellus tristique, et hendrerit risus finibus. Morbi rhoncus, ex in placerat lacinia, justo tortor posuere ipsum, ac scelerisque urna lectus porttitor quam. Quisque quis neque massa. Aenean metus ante, lacinia vitae eros ut, porta ullamcorper mi. Sed varius bibendum interdum. Aenean at ligula iaculis nulla egestas tristique sit amet eget eros. Nam tincidunt tempor neque a sollicitudin. Integer risus sapien, tempor vel congue eget, mattis sed mi. Nullam condimentum imperdiet pulvinar.
Nam in mi sagittis, rhoncus nisl id, elementum tortor. Pellentesque id risus laoreet mi ullamcorper gravida. Nunc eget orci vitae eros efficitur consectetur a porttitor urna. Suspendisse dapibus sapien ac nulla tincidunt fermentum. Suspendisse eleifend iaculis ex et porta. Morbi at dignissim velit. Nunc non lacus ut arcu luctus dapibus. Nulla facilisis vehicula ligula non malesuada. Sed fermentum placerat mi eu finibus. Morbi nulla velit, volutpat quis efficitur in, vestibulum sed odio. In tempus, quam quis bibendum iaculis, nulla mauris rutrum leo, pellentesque molestie est lacus ut neque. Integer luctus elementum ipsum sed molestie. Vestibulum non rutrum enim. Nulla iaculis finibus elementum. Phasellus faucibus ante et pretium semper.
Morbi volutpat in ligula ut blandit. Vivamus et arcu venenatis, faucibus ante nec, suscipit dolor. Duis id molestie sapien, nec dictum ante. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut at ante sem. Ut porttitor, tortor at convallis convallis, neque mi convallis ipsum, vel ultrices enim dolor sed diam. In dictum vulputate massa id molestie. Donec sollicitudin nisi vestibulum diam varius aliquet.
\vspace{0.6cm}
\makeletterclosing
\end{document}
您在本答案开头看到的结果。
第二步:
为了获取发件人部分底部的名称,我们必须稍微更改重要部分。请参阅此代码:
% sender contact info
\begin{minipage}{\textwidth}% <=======================================
\begin{flushleft}% <================================================
\addressfont\textcolor{color2}{%
\@firstdetailselementfalse% <==========deleted name first line here
\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}%
\ifthenelse{\isundefined{\@firstname}}{}{\makenewline\hfill\bfseries\upshape\@firstname~\@lastname}}% <===== added name last line
\end{flushleft}% <================================================
\end{minipage}\\[1em]
在倒数第三行我添加了
\ifthenelse{\isundefined{\@firstname}}{}{\makenewline\hfill\bfseries\upshape\@firstname~\@lastname}}%
检查是否@firstname
不为空(当然不是)新建一行\makenewline
添加名称,就像我之前做的那样。当然,我删除了第一行中名称的代码。我相信您可以通过将此代码与第一个显示的代码进行比较来发现差异。现在请使用上面的代码更改第 15 行到第 30 行,编译,然后瞧,您想要的:
答案2
加载包后添加此代码(顺便问一下,为什么要加载?如果在 MWE 中放置虚拟文本,etoolbox
为什么要加载?):lipsum
\makeatletter
\renewcommand*{\makelettertitle}{%
% recompute lengths (in case we are switching from letter to resume, or vice versa)
\recomputeletterlengths%
% sender contact info
\begin{minipage}{.5\textwidth}%
\raggedright%
\addressfont\textcolor{color2}{%
{\bfseries\upshape\@firstname~\@lastname}\@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}
% 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}}
\renewcommand*{\makeletterclosing}{
\@closing\\[3em]%
\ifthenelse{\isundefined{\@enclosure}}{}{%
\vfill%
{\color{color2}\itshape\enclname: \@enclosure}}}
\makeatother
基本上,我从中取出代码moderncvclassic.sty
并删除了,\hfill
并将一个改为了\raggedleft
,\raggedright
并\makelettertitle
删除了中的名称部分和换行符\makeletterclosing
。