如何将单元格中的文本与左上角对齐?

如何将单元格中的文本与左上角对齐?

我有此代码,但我希望左列中的日期与其单元格的左上角对齐。

我将{ L L }其用于左对齐,效果很好,但将其用于[t]上对齐,效果不好。如何正确进行上对齐?

\section*{Work Experience} 
\begin{tabular}[t]{  L{5cm}  L{9cm} }
\renewcommand{\arraystretch}{2.0}
Jun 2016 - Aug 2016 & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus maximus ullamcorper eros vel convallis. Integer felis velit, consequat sit amet lectus id, dignissim lobortis enim. Proin eu eleifend lacus, id vestibulum turpis. Lorem ipsum dolor sit amet, consectetur adipiscing elit.   \\
Jun 2015 - Aug 2015 & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla porttitor bibendum nisl, quis hendrerit quam finibus nec. Morbi imperdiet congue dolor. Interdum et malesuada fames ac ante ipsum. \\
Jun 2011 - Aug 2011 & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas tellus risus, feugiat non vulputate et, congue quis sem. Morbi eleifend, felis vel sollicitudin congue, quam lorem convallis felis.end{tabular}

谢谢

答案1

我猜想,你说的“左上角对齐”是指第一列左侧不应有空格。(你没有说明如何L定义列类型,但我有理由相信它确实有某种左对齐(又称右对齐)。)如果这个猜测是正确的,只需替换

\begin{tabular}[t]{  L{5cm}  L{9cm} }

\begin{tabular}{@{} L{5cm} L{9cm} @{}}

元素@{}指导 LaTeX不是\tabcolsep在第一列的左侧和最后一列的右侧插入列间空白(宽度为)。

完整的 MWE:

在此处输入图片描述

\documentclass{article}
\usepackage{array,ragged2e}
\newcolumntype{L}[1]{>{\RaggedRight\arraybackslash}p{#1}} % just a guess...
\renewcommand{\arraystretch}{2.0} % this needs to occur before "\begin{tabular}"
\begin{document}

\section*{Work Experience} 
\begin{tabular}{@{} L{3.5cm} L{9cm} @{}}
Jun 2016--Aug 2016 & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus maximus ullamcorper eros vel convallis. Integer felis velit, consequat sit amet lectus id, dignissim lobortis enim. Proin eu eleifend lacus, id vestibulum turpis. Lorem ipsum dolor sit amet, consectetur adipiscing elit.   \\
Jun 2015--Aug 2015 & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla porttitor bibendum nisl, quis hendrerit quam finibus nec. Morbi imperdiet congue dolor. Interdum et malesuada fames ac ante ipsum. \\
Jun 2011--Aug 2011 & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas tellus risus, feugiat non vulputate et, congue quis sem. Morbi eleifend, felis vel sollicitudin congue, quam lorem convallis felis.
\end{tabular}
\end{document}

相关内容