\parbox 宽度问题

\parbox 宽度问题

我正在使用 LaTeX 中的简历模板,但在使内容正确对齐方面遇到了一些困难。

我指的代码是

\newcommand{\NewEntry}[3]{% Define a command for each new block - change spacing and font sizes here: #1 is the left margin, #2 is the italic date field and #3 is the position/employer/location field
    \noindent\hangindent=0em\hangafter=0
    \parbox{\datebox}{\small\textit{#1}}
    \hspace{1em} #2 #3
    }

在此处输入图片描述

如您所见,“Feb'14--current”显示在两行而不是一行中。有没有办法可以编辑指令,\newcommnad以便获得所需的结果,即显示在一行中。

答案1

正如我在评论中所建议的那样,最好多了解一下 CV 样式。但问题是长度\datebox不足以容纳字符串。您可以增加\datebox,或者手动强制字符串超出分配的空间(存在重叠的风险)。

原始大小\datebox=.7in是凭空而来的,仅用于显示与输入数据不匹配的大小。需要参考您的 CV 样式来确定为其分配的实际长度。

我还使用该选项制作了\parbox[t]功能,这样任何超出范围(如果允许)都不会改变日期框文本的垂直位置。

\documentclass{article}
\newlength\datebox
\datebox=.7in\relax% OR PREFERABLY \setlength{\datebox}{0.7in}
\newcommand{\NewEntry}[3]{\noindent\hangindent=0em\hangafter=0 %
  \parbox[t]{\datebox}{\small\textit{#1}}\hspace{1em} #2 #3 }
\begin{document}
\parindent 0in\parskip 1ex
AS IS (approximately):

\NewEntry{Feb'14--current}{Technical Service Manager}{Blah}

INCREASING datebox:

\datebox=.9in
\NewEntry{Feb'14--current}{Technical Service Manager}{Blah}

BRUTE FORCE:

\datebox=.7in% RESTORE ORIGINAL
\renewcommand{\NewEntry}[3]{\noindent\hangindent=0em\hangafter=0 %
  \parbox[t]{\datebox}{\small\makebox[0pt][l]{\textit{#1}}}\hspace{1em} #2 #3 }
\NewEntry{Feb'14--current}{Technical Service Manager}{Blah}

\end{document}

在此处输入图片描述

答案2

无论如何,我不建议使用此模板。但是,您的问题可以在给定的设置内解决:您需要将宽度设置\datebox为最长的日期标题。假设这是有问题的“2014 年 2 月-当前”,您会说

\settowidth{\datebox}{Feb'14--current}

在此处输入图片描述

如果您确实想使用该模板,您应该强烈考虑接受我的调整(请参阅下面的完整代码)。

\documentclass{scrartcl}
\usepackage[nochapters]{classicthesis}
\usepackage[LabelsAligned]{currvita}
  \renewcommand{\cvheadingfont}{\LARGE\color{Maroon}}
\usepackage{hyperref}
  \hypersetup{colorlinks,breaklinks,urlcolor=Maroon,linkcolor=Maroon}

\reversemarginpar

\newlength{\datebox}
\settowidth{\datebox}{Feb'14--current}

\newcommand{\MarginText}[1]{\marginpar{\raggedleft\itshape\small#1}}
\newcommand{\NewEntry}[3]{%
  \par\noindent\hangindent=2em\hangafter=0
  \parbox[t]{\datebox}{\small \textit{#1}}
  \hspace{1.5em} #2 #3
  \vspace{0.5em}
  \par}
\newcommand{\Description}[1]{%
  \par\noindent\hangindent=2em\hangafter=0
  {\raggedright\footnotesize #1\par}
  \vspace{1em}
  \par}

\begin{document}

\begin{cv}{\spacedallcaps{John Smith}}\vspace{1.5em} % Your name

\section*{Personal Information}

\NewEntry{}{\textit{Born in Canada,}}{20 November 1987} % Birthplace and date

\NewEntry{email}{\href{mailto:[email protected]}{[email protected]}} % Email address

\NewEntry{website}{\href{http://www.johnsmith.com}{http://www.johnsmith.com}} % Personal website

\NewEntry{phone}{(H) +1 (000) 111 1111\ \ $\cdotp$\ \ (M) +1 (000) 111 1112} % Phone number(s)

\vspace{1em} % Extra white space between the personal information section and goal


\section*{Goal}

\Description{Gain fundamental experience in my area of interest and expertise.}\vspace{2em}


\section*{Work Experience}

\NewEntry{2012--Present}{1\textsuperscript{st} Year Analyst, \textsc{Lehman Brothers}}

\Description{%
  \MarginText{Lehman Brothers}%
  Developed spreadsheets for risk analysis on exotic derivatives on a wide array of commodities (ags, oils, precious and base metals), managed blotter and secondary trades on structured notes, liaised with Middle Office, Sales and Structuring for bookkeeping.
  \newline Reference: John \textsc{McDonald}\ \ $\cdotp$\ \ +1 (000) 111 1111\ \ $\cdotp$\ \ \href{mailto:[email protected]}{[email protected]}}

\NewEntry{2010--2011}{Summer Intern, \textsc{Initech Inc}  --- Chicago}

\Description{%
  \MarginText{Initech Inc}%
  Rated "truly distinctive" for Analytical Skills and Teamwork.
  \newline Reference: Bill \textsc{Lumbergh}\ \ +1 (000) 111 1111\ \ $\cdotp$\ \ \href{mailto:[email protected]}{[email protected]}}

\NewEntry{Feb'14--current}{Technical Service Manager, \textsc{Gilette, PnG}}

\Description{%
  \MarginText{Buy More}%
  Worked in the Nerd Herd and helped to solve computer problems by asking customers to turn their computers off and on again.
  \newline Reference: Big \textsc{Mike}\ \ +1 (000) 111 1111\ \ $\cdotp$\ \ \href{mailto:[email protected]}{[email protected]}}

\end{cv}
\end{document}

笔记。模板的更改包括硬编码问题,例如替换\noindent\spacedlowsmallcaps{<heading text>}\section*{<heading text>}误用\footnotesize宏以及更好地处理间距。

附录

为了 100% 确保没有“日期项目”会与其框的边框相夹,您可以测量每个项目并设置\datebox为最宽的测量宽度自动地有一个答案,其方法也可以应用于这个问题:

维护结构工作簿样式

另一种方法是检查每个项目并将最大值写入主辅助文件,并在开始时检索该值 - 这需要两个编译周期才能看到实际变化:

\documentclass{scrartcl}
\usepackage[nochapters]{classicthesis}
\usepackage[LabelsAligned]{currvita}
  \renewcommand{\cvheadingfont}{\LARGE\color{Maroon}}
\usepackage{hyperref}
  \hypersetup{colorlinks,breaklinks,urlcolor=Maroon,linkcolor=Maroon}

\reversemarginpar

\newdimen\datebox
\newdimen\tempdima \tempdima0pt
\newdimen\maxdatedimen \maxdatedimen30pt%default value

\newcommand{\NewEntry}[3]{%
  \settowidth\tempdima{#1}%
  \ifdim\tempdima>\maxdatedimen%
    \global\maxdatedimen\the\tempdima\fi%
  \par\noindent\hangindent=2em\hangafter=0
  \parbox[t]{\datebox}{\small \textit{#1}}
  \hspace{1.5em} #2 #3
  \vspace{0.5em}
  \par}
\newcommand{\MarginText}[1]{\marginpar{\raggedleft\itshape\small#1}}
\newcommand{\Description}[1]{%
  \par\noindent\hangindent=2em\hangafter=0
  {\raggedright\footnotesize #1\par}
  \vspace{1em}
  \par}

\usepackage{atveryend}

\makeatletter
\AtBeginDocument{%
  \settowidth{\datebox}{\hbox to \the\maxdatedimen{\hfil}}
  \maxdatedimen0pt}
\AfterLastShipout{%
  \if@filesw
    \immediate\write\@mainaux{%
      \global\string\maxdatedimen=\the\maxdatedimen\relax
    }%
  \fi}
\makeatother

\begin{document}

\begin{cv}{\spacedallcaps{John Smith}}\vspace{1.5em} % Your name

\section*{Personal Information}

\NewEntry{}{\textit{Born in Canada,}}{20 November 1987} % Birthplace and date

\NewEntry{email}{\href{mailto:[email protected]}{[email protected]}} % Email address

\NewEntry{website}{\href{http://www.johnsmith.com}{http://www.johnsmith.com}} % Personal website

\NewEntry{phone}{(H) +1 (000) 111 1111\ \ $\cdotp$\ \ (M) +1 (000) 111 1112} % Phone number(s)

\vspace{1em} % Extra white space between the personal information section and goal


\section*{Goal}

\Description{Gain fundamental experience in my area of interest and expertise.}\vspace{2em}


\section*{Work Experience}

\NewEntry{2012--Present}{1\textsuperscript{st} Year Analyst, \textsc{Lehman Brothers}}

\Description{%
  \MarginText{Lehman Brothers}%
  Developed spreadsheets for risk analysis on exotic derivatives on a wide array of commodities (ags, oils, precious and base metals), managed blotter and secondary trades on structured notes, liaised with Middle Office, Sales and Structuring for bookkeeping.
  \newline Reference: John \textsc{McDonald}\ \ $\cdotp$\ \ +1 (000) 111 1111\ \ $\cdotp$\ \ \href{mailto:[email protected]}{[email protected]}}

\NewEntry{2010--2011}{Summer Intern, \textsc{Initech Inc}  --- Chicago}

\Description{%
  \MarginText{Initech Inc}%
  Rated "truly distinctive" for Analytical Skills and Teamwork.
  \newline Reference: Bill \textsc{Lumbergh}\ \ +1 (000) 111 1111\ \ $\cdotp$\ \ \href{mailto:[email protected]}{[email protected]}}

\NewEntry{Feb'14--current}{Technical Service Manager, \textsc{Gilette, PnG}}

\Description{%
  \MarginText{Buy More}%
  Worked in the Nerd Herd and helped to solve computer problems by asking customers to turn their computers off and on again.
  \newline Reference: Big \textsc{Mike}\ \ +1 (000) 111 1111\ \ $\cdotp$\ \ \href{mailto:[email protected]}{[email protected]}}

\end{cv}
\end{document}

结果与上面的截图相同,但是现在一切都是自动完成的。

相关内容