目前用到的公式換行情況主要有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̲實現公式內換行
效果如下: