我正在为演示文稿写一封求职信,但其中有以下文字:
巴尔的摩大学机电一体化系是破碎的因为有行 Date。如您所见,它们位于同一行:
该文本机电一体化应该在同一行大学...。我已经尝试了一些命令,例如:\nolinebreak
,和字符~
,但是不起作用。这是我的最小工作示例:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% "ModernCV" CV and Cover Letter
% LaTeX Template
% Version 1.3 (29/10/16)
%----------------------------------------------------------------------------------------
% PACKAGES AND OTHER DOCUMENT CONFIGURATIONS
%----------------------------------------------------------------------------------------
\documentclass[11pt,a4paper,roman]{moderncv}
\moderncvstyle{classic}
\moderncvcolor{blue}
\usepackage{ngerman}
\usepackage[utf8]{inputenc}
\usepackage[scale=0.75]{geometry}
\setlength{\hintscolumnwidth}{3.9cm}
\nopagenumbers{}
%----------------------------------------------------------------------------------------
% NAME AND CONTACT INFORMATION SECTION
%----------------------------------------------------------------------------------------
\firstname{John} % Your first name
\familyname{Smith} % Your last name
% All information in this block is optional, comment out any lines you don't need
\address{xxxxx}{4444, Paris}
\mobile{+123456789}
\email{[email protected]}
%----------------------------------------------------------------------------------------
\begin{document}
\clearpage
\recipient{University of Baltimore, Department of mechatronics}{Prof. Micky Mouse \\Somewhere in the world\\98763 Baltimore} % Letter recipient
\date{Paris, \today} % Letter date
\opening{} % Opening greeting
\closing{Sincerely} % Closing phrase
\makelettertitle % Print letter title
\textbf{Letter of presentation}
Dear Prof....
\makeletterclosing % Print letter signature
\newpage
\end{document}
我怎样才能更改我的代码,以便文本和日期不在同一行?
答案1
你可以用以下方法欺骗 LaTeX \rlap
:
\documentclass[11pt, a4paper, roman]{moderncv}
\moderncvstyle{classic}
\moderncvcolor{blue}
\usepackage{ngerman}
\usepackage[utf8]{inputenc}
\usepackage[scale=0.75]{geometry}
\setlength{\hintscolumnwidth}{3.9cm}
\nopagenumbers{}
%----------------------------------------------------------------------------------------
% NAME AND CONTACT INFORMATION SECTION
%----------------------------------------------------------------------------------------
\firstname{John} % Your first name
\familyname{Smith} % Your last name
% All information in this block is optional, comment out any lines you don't need
\address{xxxxx}{4444, Paris}
\mobile{+123456789}
\email{[email protected]}
%----------------------------------------------------------------------------------------
\begin{document}
\clearpage
\recipient{University of Baltimore, Department of \rlap{mechatronics}}{Prof. Micky Mouse \\Somewhere in the world\\98763 Baltimore} % Letter recipient
\date{Paris, \today} % Letter date
\opening{} % Opening greeting
\closing{Sincerely} % Closing phrase
\makelettertitle % Print letter title
\textbf{Letter of presentation}
Dear Prof....
\makeletterclosing % Print letter signature
\newpage
\end{document}
答案2
嗯,我认为更好的解决方案是在左侧新建部门行,
\recipient{University of Baltimore, \\Department of mechatronics}{Prof. Micky Mouse \\Somewhere in the world\\98763 Baltimore} % Letter recipient
% ^^^^
如果你不想这样做,你必须重新定义命令\makeletterhead
。在其中,你可以找到放置收件人地址的迷你页面的代码
\begin{minipage}[t]{.5\textwidth}
\raggedright%
\addressfont%
{\bfseries\upshape\@recipientname}\\%
\@recipientaddress%
\end{minipage}
在这里根据您的需要更改小页面的宽度,例如.7\textwidth
:
\begin{minipage}[t]{.7\textwidth} % <==================== .5\textwidth
\raggedright%
\addressfont%
{\bfseries\upshape\@recipientname}\\%
\@recipientaddress%
\end{minipage}
使用以下代码(请注意,我使用了类的当前版本 2.0.0 moderncv
;您可能正在使用旧版本,如该注释所示Version 1.3 (29/10/16)
:):
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% "ModernCV" CV and Cover Letter
% LaTeX Template
% Version 1.3 (29/10/16)
%----------------------------------------------------------------------------------------
% PACKAGES AND OTHER DOCUMENT CONFIGURATIONS
%----------------------------------------------------------------------------------------
\documentclass[11pt,a4paper,roman]{moderncv}
\moderncvstyle{classic} % head 1 body 1 foot
\moderncvcolor{blue}
\usepackage{ngerman}
\usepackage[utf8]{inputenc}
\usepackage[scale=0.75]{geometry}
\setlength{\hintscolumnwidth}{3.9cm}
\nopagenumbers{}
\makeatletter
\renewcommand*{\makeletterhead}{%
% recompute lengths (in case we are switching from letter to resume, or vice versa)
\recomputeletterlengths%
% sender contact info
\hfill%
\begin{minipage}{.5\textwidth}%
% optional detailed information
\if@details%
\raggedleft%
\addressfont\textcolor{color2}{%
{\bfseries\upshape\@firstname~\@lastname}\@firstdetailselementfalse%
% optional detailed information
\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}}\fi%
\end{minipage}\\[1em]
% recipient block
\begin{minipage}[t]{.7\textwidth} % <==================== .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}}
\makeatother
%----------------------------------------------------------------------------------------
% NAME AND CONTACT INFORMATION SECTION
%----------------------------------------------------------------------------------------
\firstname{John} % Your first name
\familyname{Smith} % Your last name
% All information in this block is optional, comment out any lines you don't need
\address{xxxxx}{4444, Paris}
\mobile{+123456789}
\email{[email protected]}
%----------------------------------------------------------------------------------------
\begin{document}
\clearpage
\recipient{University of Baltimore, Department of mechatronics}{Prof. Micky Mouse \\Somewhere in the world\\98763 Baltimore} % Letter recipient
\date{Paris, \today} % Letter date
\opening{} % Opening greeting
\closing{Sincerely} % Closing phrase
\makelettertitle % Print letter title
\textbf{Letter of presentation}
Dear Prof....
\makeletterclosing % Print letter signature
\newpage
\end{document}
得到结果:
正如 @egreg 所提到的,您可以使用etoolbox
已由 class 加载的包来使用较短的代码moderncv
。但请注意,只有在您还使用 2.0.0 版的 class 时才能使用此较短的代码moderncv
。请检查您的日志文件以获取版本号!
较短的代码
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% "ModernCV" CV and Cover Letter
% LaTeX Template
% Version 1.3 (29/10/16)
%----------------------------------------------------------------------------------------
% PACKAGES AND OTHER DOCUMENT CONFIGURATIONS
%----------------------------------------------------------------------------------------
\documentclass[11pt,a4paper,roman]{moderncv}
\moderncvstyle{classic} % head 1 body 1 foot
\moderncvcolor{blue}
\usepackage{ngerman}
\usepackage[utf8]{inputenc}
\usepackage[scale=0.75]{geometry}
\setlength{\hintscolumnwidth}{3.9cm}
\nopagenumbers{}
% to patch the code of moderncv, version 2.0.0
%\usepackage{etoolbox} % already loaded in moderncv <===================
\patchcmd{\makeletterhead}%
{[t]{.5\textwidth}}% code to patch
{[t]{0.7\textwidth}}% new code <======================================
{}% success
{}% failure
%----------------------------------------------------------------------------------------
% NAME AND CONTACT INFORMATION SECTION
%----------------------------------------------------------------------------------------
\firstname{John} % Your first name
\familyname{Smith} % Your last name
% All information in this block is optional, comment out any lines you don't need
\address{xxxxx}{4444, Paris}
\mobile{+123456789}
\email{[email protected]}
%----------------------------------------------------------------------------------------
\begin{document}
\clearpage
\recipient{University of Baltimore, Department of mechatronics}{Prof. Micky Mouse \\Somewhere in the world\\98763 Baltimore} % Letter recipient
\date{Paris, \today} % Letter date
\opening{} % Opening greeting
\closing{Sincerely} % Closing phrase
\makelettertitle % Print letter title
\textbf{Letter of presentation}
Dear Prof....
\makeletterclosing % Print letter signature
\newpage
\end{document}
导致结果如上所示...