2010-05-24 123 views
48

我正在尝试使用LaTeX编写一篇简短的论文,并且需要添加一个带有3列的表格。如何使用多行单元格对表进行编码

+-------------+-----------------+--------------------------------------+ 
| AAAAAAAAAA | BBBBBBBBBBBBBBB | Betty Botter Bought a Bit of Butter | 
|    |     | but the Butter's Bitter    | 
+-------------+-----------------+--------------------------------------+ 
| CCCCCCCC | DDDD   | Betty Botter Thought:    | 
|    |     | If I Put This Bitter Butter in My | 
|    |     | Batter it Will Make My Batter Bitter | 
+-------------+-----------------+--------------------------------------+ 

不幸的是,我似乎无法找到正确的方法来做到这一点。


我想:

\begin{tabular}{lll} 
    AAAAAAAAAA & BBBBBBBBBBBBBBB & Betty Botter Bought a Bit of Butter but 
    the Butter's Bitter \\ 
    CCCCCCCC & DDDD & Betty Botter Thought: \newline If I Put This Bitter Butter in My Batter it Will Make My Batter Bitter 
\end{tabular} 

但latex没有在小区内做任何换行或格式化。我想我需要告诉它这样做。但是,怎么样?

+1

重复的问题:http://stackoverflow.com/questions/2687033/multiple-lines-in-a-cell-of-a-table(这个问题有点更一般的范围)。 – 2010-05-24 11:52:28

回答

66

使用p列描述符:

变化

\begin{tabular}{lll} 

\begin{tabular}{llp{5cm}} 

要明确插入换行符:

CCCCCCCC & DDDD & \parbox{5cm}{Betty Botter Thought: \\ If I Put This Bitter Butter in My Batter it Will Make My Batter Bitter} 
+5

是否有任何方法将p {}与其他列描述符之一结合?意思是说,一个p {5cm}的列应该左对齐,右对齐还是居中对齐? – jja 2013-08-12 01:05:07

+0

@jja作为解决方案的对齐权在{}内,我在每行的开头使用\ hfill。 – Frizi 2013-10-23 18:13:33

2

这是我发现迄今为止我的需求:Link here

它创建了一个新的命令,这将使表的表内以更适当的方式:

\newcommand{\specialcell}[2][c]{% 
\begin{tabular}[#1]{@{}[email protected]{}}#2\end{tabular}} 

所以,如果要执行强制断行细胞内就像这里:

\begin{tabular}{|c|c|c|} 
\hline 
Foo bar & Foo <forced line break here> bar & Foo bar \\ 
\hline 
\end{tabular} 

最后你会使用这样的代码:

Foo bar & \specialcell{Foo\\bar} & Foo bar \\ % vertically centered 
Foo bar & \specialcell[t]{Foo\\bar} & Foo bar \\ % aligned with top rule 
Foo bar & \specialcell[b]{Foo\\bar} & Foo bar \\ % aligned with bottom rule 

水平对齐可以在被控制通过改变Ç@升@R 7

所有信用卡的新命令的声明,从Tex forum

0

egreg这里是没有花哨的编码答案。用不同的行写你的行。除了最后一行(行),省略\ hline它的快速和肮脏,但是,嘿,它的工作原理和给我正是我想要的,对于简单的表格无论如何。我正在做汽车挡风玻璃上的广告。我在每个单元中有3个居中行

iTutor Grahamstown 
Mathematics Tutor 
0793296211 

我想在我的表中反复使用这个。我刚刚排除了前两行的\ hline。多个\ hlines和'|'是为了使打印输出更容易。

\begin{tabular}{||c||c||c||c||} 
\hline\hline 

iTutor Grahamstown &iTutor Grahamstown&iTutor Grahamstown &iTutor Grahamstown \\ %No \hline 

Mathematics Tutor & Mathematics Tutor & Mathematics Tutor&Mathematics Tutor \\ %No \hline 

0793296211 & 0793296211 & 0793296211 & 0793296211\\ \hline\hline\hline %\hline now 


\end{tabular} 

我希望这有助于。

相关问题