代码改变世界

Latex 表格内文字过长自动换行

2015-04-30 12:24  zhaoyang10  阅读(29198)  评论(0编辑  收藏  举报

法一:

  1. \begin{tabular}{m{5cm}}  

法二:

  1. \begin{tabular}{p{0.9\columnwidth}}  
 法三:multirow 宏包
 
  \multirow{nrows}[bigstructs]{width}[fixup]{text}  

 

  1.  nrows      设定所占用的行数。
  2. bigstructs      此为可选项,主要是在你使用了 bigstruct 宏包时使用。
  3. width      设定该栏文本的宽度。如果想让 LaTeX 自行决定文本的宽度,则用 * 即可。
  4. fixup      此为可选项,主要用来调整文本的垂直位置。
  5. text      所要排版的文本。可用 \\ 来强迫换行。

 

法四:

 

 
  1. /newcommand{/tabincell}[2]{/begin{tabular}{@{}#1@{}}#2/end{tabular}}  
然后使用&/tabincell{c}{}&就可以在表格中自动换行

 

比如这么用

 

  1. /begin{tabular}{|c|c|}  
  2. /hline  
  3.  1 & the first line //  
  4. /hline  
  5.  2 & /tabincell{c}{haha// heihei//zeze} //  
  6. /hline  
  7. /end{tabular}  
 
  1. /begin{tabular}{|c|c|}  
  2. /hline  
  3.  1 & the first line //  
  4. /hline  
  5.  2 & /tabincell{c}{haha// heihei//zeze} //  
  6. /hline  
  7. /end{tabular}