tsingke
Latex 表格内的公式实现换行的方法
 
 

 
简单的两步走:
 
  • 1.先将下面的语句放在latex正文的导言区:
\newcommand{\tabincell}[2]{\begin{tabular}{@{}#1@{}}#2\end{tabular}} %放在导言区

 

  • 2.然后在tabular内的格子内使用 \tabincell{c}{} 插入相应内容, 就可以在表格中自动换行

 
以下为一例子,可直接存为.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}\\ %换行,单元格内的每个元素用\tabincell{c}{放表格内容}
\hline
2 & \tabincell{c}{hello\\ aha\\ ok \\yes \\en} & \tabincell{c}{two \\ two \\ two} \\
\hline
\end{tabular}
%--------------------------------------------------------------------------------------------------
  \caption{longtitle}
\end{table}
\end{document}

 

结果如下图:

分类:

技术点:

相关文章:

  • 2021-04-20
  • 2021-09-25
  • 2021-10-19
  • 2022-12-23
  • 2022-12-23
  • 2021-10-06
  • 2022-12-23
  • 2021-11-07
猜你喜欢
  • 2021-10-12
  • 2022-01-06
  • 2021-08-24
  • 2022-12-23
  • 2022-12-23
  • 2021-11-12
  • 2021-07-05
相关资源
相似解决方案