分享

LaTeX 表格内单元格内容强制换行

 Echosite 2016-01-08
转自 http://blog.sina.com.cn/s/blog_531bb7630101841e.html


/newcommand{/tabincell}[2]{/begin{tabular}{@{}#1@{}}#2/end{tabular}}%放在导言区
%然后使用&/tabincell{c}{}&就可以在表格中自动换行
%比如这么用
/begin{tabular}{|c|c|}
/hline
1 & the first line //
/hline
2 & /tabincell{c}{haha// heihei//zeze} //
/hline
/end{tabular}
以下为一例子,可直接存为.tex文件编译运行:
\documentclass[a4paper,12pt]{article}
\begin{document}
\begin{table}
\newcommand{\tabincell}[2]{\begin{tabular}{@{}#1@{}}#2\end{tabular}}
  \centering
  \begin{tabular}{|c|c|c|}\hline
1 & \tabincell{c}{the first line \\ the next\\the next\\ last} & \tabincell{c}{one \\ one}\\\hline
2 & \tabincell{c}{hello\\ aha\\ ok \\yes \\en} & \tabincell{c}{two \\ two \\ two} \\\hline
\end{tabular}
  \caption{longtitle}
\end{table}
\end{document}

结果如图:

 
 

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多