我有两个很短且连续的部分(对于CV),每个部分都包含一个小表:
\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
。但是,如果您因任何原因不想使用 array 包,那么其他解决方案也很棒。
答案 0 :(得分:17)
如果您使用array
包,则可以按如下方式将\hfill
放入标题中,这样您就不必记得将其放入(或\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}
给予:
alt text http://www.freeimagehosting.net/uploads/5e29f675e3.jpg
答案 1 :(得分:6)
以下是使用tabularx
包的@ RTBarnard答案的变体:
\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}
注意:
tabularx
?因为它经常
更容易知道你的宽度
适用于整个桌子,和
让TeX计算未知数
列宽。\textwidth
来填充typeblock的宽度,但您可以将其更改为您需要的任何度量。\raggedright
而不是\hfill
:如果商品流到第二行,\hfill
只会右对齐段落的第一行。\multicol
是否显着?我已将其删除,以使答案尽可能简单。在TeXLive下使用XeTeX运行。
答案 2 :(得分: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
并在左侧放置一个\hfill
。
答案 3 :(得分:1)
您可以同时提供两个p {width}选项,并使用\hfill
启动左侧的每个单元格。
答案 4 :(得分:1)
您可以使用array
包为第一列中的每一行指定填充命令:
\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}