防止左列换行符强制右列换行

防止左列换行符强制右列换行

我正在用 LaTeX 写简历,从名为使用 LaTeX 撰写简历

我正在尝试修改它,以便左列中的换行符不会强制右列中的换行符。以下是我目前得到的结果:

前言:

\definecolor{lightgray}{gray}{0.8}
\newcolumntype{L}{>{\raggedleft}p{0.14\textwidth}}
\newcolumntype{R}{p{0.8\textwidth}}
\newcommand\VRule{\color{lightgray}\vrule width 0.5pt}

列:

\section*{Professional Experience}
\begin{tabular}{L!{\VRule}R}
June 2012 -- present&{\bf Pixel Pusher at Vandalay Industries}\\
&\lipsum[66]\vspace{5pt}\\
Sept. 2011 -- Apr. 2012&{\bf Intern Pixel Pusher at Vandalay Industries}\\
&\lipsum[66]\\
\end{tabular}

输出如下:输出

我添加了箭头来指示我想消除的右列换行符。任何有关此的指示都很好。

答案1

那么嵌套怎么样(必须在这个语境中是一个新词)是tabular

在此处输入图片描述

\documentclass{article}

\usepackage{lipsum,xcolor,array}

\definecolor{lightgray}{gray}{0.8}
\newcolumntype{L}{>{\raggedleft}p{\dimexpr0.2\textwidth-2\tabcolsep-0.25pt}}
\newcolumntype{R}{p{\dimexpr0.8\textwidth-2\tabcolsep-0.25pt}}
\newcommand\VRule{\color{lightgray}\vrule width 0.5pt}

\begin{document}

\section*{Professional Experience}
\noindent
\begin{tabular}{L!{\VRule}R}
  June 2012 -- present & \begin{tabular}[t]{@{}R@{}}
    \textbf{Pixel Pusher at Vandalay Industries} \\
    \lipsum[66]
  \end{tabular} \\[\bigskipamount]
  Sept. 2011 -- Apr. 2012 & \begin{tabular}[t]{@{}R@{}}
    \textbf{Intern Pixel Pusher at Vandalay Industries} \\
    \lipsum[66]
  \end{tabular}
\end{tabular}

\end{document}

对代码的一些修改包括:

答案2

multirow包可以在这里帮助您。

如果您更愿意设置手动换行符,您可以明确地将文本划分在第一列,即

\begin{tabular}{L!{\VRule}R}
    June 2012 --  & {\bf Pixel Pusher at Vandalay Industries}        \\
    present       & \lipsum[66]\vspace{5pt}                          \\
    Sept. 2011 -- & {\bf Intern Pixel Pusher at Vandalay Industries} \\
    Apr. 2012     & \lipsum*[66]                                     \\
\end{tabular}

代码

\documentclass[10pt]{article}
\usepackage[margin=3cm]{geometry}
\usepackage{xcolor,array,lipsum,multirow}
\definecolor{lightgray}{gray}{0.8}
\newcolumntype{L}{>{\raggedleft}p{0.14\textwidth}}
\newcolumntype{R}{p{0.8\textwidth}}
\newcommand\VRule{\color{lightgray}\vrule width 0.5pt}
\begin{document}
\section*{Professional Experience (Orig)}
\begin{tabular}{L!{\VRule}R}
    June 2012 -- present    & {\bf Pixel Pusher at Vandalay Industries}        \\
                            & \lipsum[66]\vspace{5pt}                          \\
    Sept. 2011 -- Apr. 2012 & {\bf Intern Pixel Pusher at Vandalay Industries} \\
                            & \lipsum[66]                                      \\
\end{tabular}
\section*{Professional Experience (multirow)}
\begin{tabular}{L!{\VRule}R}
    \multirow{2}{\linewidth}{\raggedleft June~2012 -- present}    & {\bfseries Pixel Pusher at Vandalay Industries}        \\
                                                                  & \lipsum[66]\vspace{5pt}                                \\
    \multirow{2}{\linewidth}{\raggedleft Sept.~2011 -- Apr.~2012} & {\bfseries Intern Pixel Pusher at Vandalay Industries} \\
                                                                  & \lipsum*[66]
\end{tabular}
\end{document}

输出

在此处输入图片描述

答案3

\multirow或嵌套tabular环境:

\documentclass[10pt]{article}
\usepackage[margin=3cm]{geometry}

\usepackage{xcolor,array,lipsum,collcell}

\definecolor{lightgray}{gray}{0.8}

\newcolumntype{L}{>{\collectcell\MyDates}l<{\endcollectcell}}
\newcommand{\MyDates}[1]{\parbox[t][0pt]{.14\textwidth}{\raggedleft#1}}

\newcolumntype{R}{p{0.8\textwidth}}
\newcommand\VRule{\color{lightgray}\vrule width 0.5pt}
\begin{document}
\section*{Professional Experience}
\begin{tabular}{L!{\VRule}R}
June~2012 -- present     & \bfseries Pixel Pusher at Vandalay Industries        \\
                         & \lipsum[66]                                          \\[5pt]
Sept.~2011 -- Apr.~2012  & \bfseries Intern Pixel Pusher at Vandalay Industries \\
                         & \lipsum*[66]
\end{tabular}
\end{document}

只需确保右列单元格至少有两行,这应该相当简单。

诀窍是让 TeX 相信左列单元格在基线下没有深度:内容通过 Martin Scharrer 的方式吸收collcell并放入\parbox我们赋予垂直尺寸为零的区域中。

在此处输入图片描述

当然还有一个更简单的解决方案:

\begin{tabular}{>{\raggedleft}p{0.14\textwidth}!{\VRule}p{0.8\textwidth}}
June~2012 -- present     &
 \textbf{Pixel Pusher at Vandalay Industries}\newline
 \lipsum[66]
\\[5pt]
Sept.~2011 -- Apr.~2012  &
 \textbf{Intern Pixel Pusher at Vandalay Industries}\newline
 \lipsum*[66]
\end{tabular}

(使用 Werner 的方法获取完整线宽。)

相关内容