Latex 表格内的公式实现换行的方法
简单的两步走:
- 1.先将下面的语句放在latex正文的导言区:
ewcommand{ abincell}[2]{egin{tabular}{@{}#1@{}}#2end{tabular}} %放在导言区
- 2.然后在tabular内的格子内使用 abincell{c}{} 插入相应内容, 就可以在表格中自动换行
以下为一例子,可直接存为.tex文件编译运行:
documentclass[a4paper,12pt]{article}
egin{document}
%-------------------------------------------------------------------------------------------------
egin{table}
ewcommand{ abincell}[2]{egin{tabular}{@{}#1@{}}#2end{tabular}} %导言区
centering
egin{tabular}{|c|c|c|}
hline
1 & abincell{c}{the first line \ the next\the next\ last} & abincell{c}{one \ one}\ %换行,单元格内的每个元素用 abincell{c}{放表格内容}
hline
2 & abincell{c}{hello\ aha\ ok \yes \en} & abincell{c}{two \ two \ two} \
hline
end{tabular}
%--------------------------------------------------------------------------------------------------
caption{longtitle}
end{table}
end{document}
结果如下图: