16

我有两个非常短且连续的部分(用于简历),每个部分都包含一个小表格:

\section{Work Experience}

\begin{tabular}{r|p{11cm}}
Current & Your job at Your Company, Town \\
Jan 2009 & What your company does \\
& A description of what you do\\
\multicolumn{2}{c}{}\ 
\end{tabular}

\section{Education}

\begin{tabular}{r|p{11cm}}
Slightly wider first column & University, Town \\
Jan 2009 & Thesis subject \\
& A description of what you did\\
\multicolumn{2}{c}{}\ 
\end{tabular}

所以每个表都有两列:第一列包含句点,向右对齐。第二个:具有一定宽度的更多信息,顶部(和左侧)对齐。

问题是两个表中左列的宽度不同,并且看起来不太好,因为这些部分(因此是表)是连续的并且在一页中。我不能给出r这样的宽度p

\begin{tabular}{r{11cm}|p{11cm}}

不工作。如何使两个表的第一列的宽度具有相同的长度,同时又使它们右对齐?

编辑感谢您的回答,它们都对我有用,所以我对所有这些都投了赞成票,并接受了对我最有吸引力(也是最赞成)的一个,因为您不必\hfill在每一行中指定。但是,如果您出于任何原因不想使用数组包,那么其他解决方案也很棒。

4

5 回答 5

17

如果你使用array包,你可以\hfill按如下方式将它放在表头中,这样你就不必记住将它(或 a \parbox)放在每一行中。

\documentclass{article}
\usepackage{multicol}
\usepackage{array}
\begin{document}
\section{Work Experience}

\begin{tabular}{>{\hfill}p{5cm}|p{11cm}}
  Current & Your job at Your Company, Town \\
  Jan 2009 & What your company does \\
  & A description of what you do\\
  \multicolumn{2}{c}{} 
\end{tabular}

\section{Education}

\begin{tabular}{>{\hfill}p{5cm}|p{11cm}}
  Slightly wider first column & University, Town \\
  Jan 2009 & Thesis subject \\
  & A description of what you did\\
  \multicolumn{2}{c}{} 
\end{tabular}
\end{document}

给:

替代文字 http://www.freeimagehosting.net/uploads/5e29f675e3.jpg

于 2010-02-19T09:56:41.460 回答
6

这是使用包的@RTBarnard 答案的变体tabularx

\documentclass[a4paper,twoside,draft,12pt]{article}
\usepackage{tabularx}
\begin{document}

\section{Work Experience}

\begin{tabularx}{\textwidth}{>{\raggedleft}X|p{8cm}}
Current & Your job at Your Company, Town \\
Jan 2009 & What your company does \\
& A description of what you do\\
\end{tabularx}

\section{Education}

\begin{tabularx}{\textwidth}{>{\raggedleft}X|p{8cm}}
Somewhat wider than first column, 
overflowing into additional lines & University, Town \\
Jan 2009 & Thesis subject \\
& A description of what you did\\
\end{tabularx}
\end{document}

笔记:

  1. 为什么tabularx?因为通常更容易知道整个表格的可用宽度,并让 TeX 计算未知的列宽。
  2. 第一个参数是整个表格宽度。在这里,我指定\textwidth填充类型块的宽度,但您可以将其更改为您需要的任何尺寸。
  3. 我使用\raggedright了而不是\hfill:如果项目流到第二行,\hfill则只会右对齐段落的第一行。
  4. 意义重大吗\multicol?我已将其删除以使答案尽可能简单。

在 TeXLive 下使用 XeTeX 运行。

于 2010-02-19T11:36:22.117 回答
3

这是多种可能性的一种解决方案:

\begin{tabular}{r|p{11cm}}
\parbox{11cm}{\hfill Current} & Your job at Your Company, Town \\
Jan 2009 & What your company does \\
& A description of what you do\\
\multicolumn{2}{c}{}\ 
\end{tabular}

基本上,创建\parbox具有所需宽度的 a 并将 a 放在\hfill左侧。

于 2010-02-19T09:39:49.653 回答
1

您可以同时提供 p{width} 选项,并在左侧的每个单元格中以\hfill.

于 2010-02-19T09:35:33.900 回答
1

您可以使用arraypackage 为第一列中的每一行指定一个填充命令:

\begin{tabular}{>{\hfill}p{11cm}|p{11cm}|}

例如:

\documentclass{article}
\usepackage{array}
\begin{document}

\begin{tabular}{>{\hfill}p{5cm}|p{11cm}|}
This is a test & test
\end{tabular}

\begin{tabular}{>{\hfill}p{5cm}|p{11cm}|}
Test & this is a test
\end{tabular}
\end{document}
于 2010-02-19T10:11:01.210 回答