目前用到的公式换行情况主要有2种,分别为表格内的公式换行和常规的公式换行,现总结如下。
1. 表格内公式换行
- 1 先将下面的语句放在latex正文的导言区:
\newcommand{\tabincell}[2]{\begin{tabular}{@{}#1@{}}#2\end{tabular}}
- 2 在tabular内的格子内使用 \tabincell{c}{} 插入相应内容, 就可以在表格中自动换行。
\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}
效果如下:
2. 单公式换行
这里可以使用KaTeX parse error: Undefined control sequence: \split at position 1: \̲s̲p̲l̲i̲t̲实现公式内换行
效果如下: