我试图保持表格中不同单元格中方程的一致性。代码如下:
\begin{center}
\begin{tabular}{|c|c|c|}
\hline
$Y^{2}B^{2}$ & $Z^{2}\chi^{2}$ & $X^{2}\lambda^{2}$ \\ \hline
$\mathcal{O}_{1} = \mathrm{wc}_{1}(\partial_{\mu}A_{\nu}-\partial_{\nu}A_{\mu})(\partial^{\mu}A^{\nu}-\partial^{\nu}A^{\mu})$ & $\mathcal{O}_{7}= \mathrm{wc}_{7}Z^{\mu\nu}Z_{\mu}(\phi^{\dagger}\phi)^{2}$ & $\mathcal{O}_{9} = \gamma^{\mu}\gamma^{\nu}+\gamma^{\nu}\gamma^{\mu}$ \\ \hline
$\mathcal{O}_{2} = \mathrm{wc}_{2} X^{\mu}X_{\mu}B^{\rho\sigma}B_{\rho\sigma}$ & $\mathcal{O}_{8} = \mathrm{wc}_{8}\bar{\psi}(i\gamma^{\mu}\partial_{\mu}-m)\psi-\frac{1}{4}F_{\mu\nu}F^{\mu\nu}$ & $\mathcal{O}_{10} = g^{\mu\nu}$ \\ \hline
\end{tabular}
\end{center}
由于对齐不佳,它看起来很乱。除此之外,表达式彼此非常接近,使得方程式难以理解。有人能指导我如何解决这两个问题吗:
- 对于生活在不同细胞中的所有表达,都有相同的排列。
- 优化单元格大小以使表达式更易读。
答案1
你的意思是这样的吗:
\begin{center}
\renewcommand{\arraystretch}{1.5}
\begin{tabular}{|l|l|l|}
\hline
\multicolumn{1}{|c|}{$Y^{2}B^{2}$} & \multicolumn{1}{c|}{$Z^{2}\chi^{2}$} & \multicolumn{1}{c|}{$X^{2}\lambda^{2}$} \\ \hline
$\mathcal{O}_{1} = \mathrm{wc}_{1}(\partial_{\mu}A_{\nu}-\partial_{\nu}A_{\mu})(\partial^{\mu}A^{\nu}-\partial^{\nu}A^{\mu})$ & $\mathcal{O}_{7}= \mathrm{wc}_{7}Z^{\mu\nu}Z_{\mu}(\phi^{\dagger}\phi)^{2}$ & $\mathcal{O}_{9} = \gamma^{\mu}\gamma^{\nu}+\gamma^{\nu}\gamma^{\mu}$ \\ \hline
$\mathcal{O}_{2} = \mathrm{wc}_{2} X^{\mu}X_{\mu}B^{\rho\sigma}B_{\rho\sigma}$ & $\mathcal{O}_{8} = \mathrm{wc}_{8}\bar{\psi}(i\gamma^{\mu}\partial_{\mu}-m)\psi-\frac{1}{4}F_{\mu\nu}F^{\mu\nu}$ & $\mathcal{O}_{10} = g^{\mu\nu}$ \\ \hline
\end{tabular}
\end{center}
?
答案2
还有另一种变体:我 \arraystretch
用包中获得的单元格顶部和底部的一些垂直填充替换了cellspace
它们。另一个小改进是使用 定义的 medsize 分数 n nccmath
,以避免表格或数组环境中的分数与公式其余部分之间的大小差异。
\documentclass{article}
\usepackage[hmargin=2.5cm]{geometry}
\usepackage{nccmath}
\usepackage{array}
\usepackage[column=O, math]{cellspace}
\setlength{\cellspacetoplimit}{4pt}
\setlength{\cellspacebottomlimit}{4pt}
\begin{document}
\[
\begin{tabular}{|*{3}{>{$}Ol<{$}|}}
\hline
\multicolumn{1}{|c|}{$ Y^{2}B^{2} $}
& \multicolumn{1}{c|}{$ Z^{2}\chi^{2} $}
& \multicolumn{1}{c|}{$ X^{2}\lambda^{2} $} \\ \hline
\mathcal{O}_{1} = \mathrm{wc}_{1}(\partial_{\mu}A_{\nu}-\partial_{\nu}A_{\mu})(\partial^{\mu}A^{\nu}-\partial^{\nu}A^{\mu}) & \mathcal{O}_{7}= \mathrm{wc}_{7}Z^{\mu\nu}Z_{\mu}(\phi^{\dagger}\phi)^{2}
& \mathcal{O}_{9\phantom{1}} = \gamma^{\mu}\gamma^{\nu}+\gamma^{\nu}\gamma^{\mu} \\
\hline
\mathcal{O}_{2} = \mathrm{wc}_{2} X^{\mu}X_{\mu}B^{\rho\sigma}B_{\rho\sigma}
& \mathcal{O}_{8} = \mathrm{wc}_{8}\bar{\psi}(i\gamma^{\mu}\partial_{\mu}-m)\psi-\mfrac{1}{4}F_{\mu\nu}F^{\mu\nu}
& \mathcal{O}_{10} = g^{\mu\nu} \\
\hline
\end{tabular}
\]
\end{document}
答案3
基于 koleygr 的代码,这里有一个略有不同的版本,使用代替array
和tabular
来改善最后一列\phantom
的对齐:=
\documentclass{article}
\usepackage[margin=2cm]{geometry}
\begin{document}
\[
\renewcommand{\arraystretch}{1.5}
\begin{array}{|l|l|l|}
\hline
\multicolumn{1}{|c|}{Y^{2}B^{2}}
& \multicolumn{1}{c|}{Z^{2}\chi^{2}}
& \multicolumn{1}{c|}{X^{2}\lambda^{2}} \\ \hline
\mathcal{O}_{1} = \mathrm{wc}_{1}(\partial_{\mu}A_{\nu}-\partial_{\nu}A_{\mu})(\partial^{\mu}A^{\nu}-\partial^{\nu}A^{\mu}) & \mathcal{O}_{7}= \mathrm{wc}_{7}Z^{\mu\nu}Z_{\mu}(\phi^{\dagger}\phi)^{2}
& \mathcal{O}_{9\phantom{1}} = \gamma^{\mu}\gamma^{\nu}+\gamma^{\nu}\gamma^{\mu} \\
\hline
\mathcal{O}_{2} = \mathrm{wc}_{2} X^{\mu}X_{\mu}B^{\rho\sigma}B_{\rho\sigma}
& \mathcal{O}_{8} = \mathrm{wc}_{8}\bar{\psi}(i\gamma^{\mu}\partial_{\mu}-m)\psi-\frac{1}{4}F_{\mu\nu}F^{\mu\nu}
& \mathcal{O}_{10} = g^{\mu\nu} \\
\hline
\end{array}
\]
\end{document}
更新:
为了增加文本和垂直线之间的水平间距,您可以调整 的值\arraycolsep
以满足您的需要。要更改文本和水平线之间的垂直间距,您可以使用包\setcellgapes
中的makecell
。以下 MWE 包含三个有些夸张的示例来展示这两个命令的效果:
\documentclass{article}
\usepackage[margin=2cm]{geometry}
\usepackage{makecell}
\begin{document}
\[
\renewcommand{\arraycolsep}{10pt}
\setcellgapes{\arraycolsep}
\makegapedcells
\begin{array}{|l|l|l|}
\hline
\multicolumn{1}{|c|}{Y^{2}B^{2}}
& \multicolumn{1}{c|}{Z^{2}\chi^{2}}
& \multicolumn{1}{c|}{X^{2}\lambda^{2}} \\ \hline
\mathcal{O}_{1} = \mathrm{wc}_{1}(\partial_{\mu}A_{\nu}-\partial_{\nu}A_{\mu})(\partial^{\mu}A^{\nu}-\partial^{\nu}A^{\mu}) & \mathcal{O}_{7}= \mathrm{wc}_{7}Z^{\mu\nu}Z_{\mu}(\phi^{\dagger}\phi)^{2}
& \mathcal{O}_{9\phantom{1}} = \gamma^{\mu}\gamma^{\nu}+\gamma^{\nu}\gamma^{\mu} \\
\hline
\mathcal{O}_{2} = \mathrm{wc}_{2} X^{\mu}X_{\mu}B^{\rho\sigma}B_{\rho\sigma}
& \mathcal{O}_{8} = \mathrm{wc}_{8}\bar{\psi}(i\gamma^{\mu}\partial_{\mu}-m)\psi-\frac{1}{4}F_{\mu\nu}F^{\mu\nu}
& \mathcal{O}_{10} = g^{\mu\nu} \\
\hline
\end{array}
\]
\[
\renewcommand{\arraycolsep}{5pt}
\setcellgapes{20pt}
\makegapedcells
\begin{array}{|l|l|l|}
\hline
\multicolumn{1}{|c|}{Y^{2}B^{2}}
& \multicolumn{1}{c|}{Z^{2}\chi^{2}}
& \multicolumn{1}{c|}{X^{2}\lambda^{2}} \\ \hline
\mathcal{O}_{1} = \mathrm{wc}_{1}(\partial_{\mu}A_{\nu}-\partial_{\nu}A_{\mu})(\partial^{\mu}A^{\nu}-\partial^{\nu}A^{\mu}) & \mathcal{O}_{7}= \mathrm{wc}_{7}Z^{\mu\nu}Z_{\mu}(\phi^{\dagger}\phi)^{2}
& \mathcal{O}_{9\phantom{1}} = \gamma^{\mu}\gamma^{\nu}+\gamma^{\nu}\gamma^{\mu} \\
\hline
\mathcal{O}_{2} = \mathrm{wc}_{2} X^{\mu}X_{\mu}B^{\rho\sigma}B_{\rho\sigma}
& \mathcal{O}_{8} = \mathrm{wc}_{8}\bar{\psi}(i\gamma^{\mu}\partial_{\mu}-m)\psi-\frac{1}{4}F_{\mu\nu}F^{\mu\nu}
& \mathcal{O}_{10} = g^{\mu\nu} \\
\hline
\end{array}
\]
\[
\renewcommand{\arraycolsep}{20pt}
\setcellgapes{5pt}
\makegapedcells
\begin{array}{|l|l|l|}
\hline
\multicolumn{1}{|c|}{Y^{2}B^{2}}
& \multicolumn{1}{c|}{Z^{2}\chi^{2}}
& \multicolumn{1}{c|}{X^{2}\lambda^{2}} \\ \hline
\mathcal{O}_{1} = \mathrm{wc}_{1}(\partial_{\mu}A_{\nu}-\partial_{\nu}A_{\mu})(\partial^{\mu}A^{\nu}-\partial^{\nu}A^{\mu}) & \mathcal{O}_{7}= \mathrm{wc}_{7}Z^{\mu\nu}Z_{\mu}(\phi^{\dagger}\phi)^{2}
& \mathcal{O}_{9\phantom{1}} = \gamma^{\mu}\gamma^{\nu}+\gamma^{\nu}\gamma^{\mu} \\
\hline
\mathcal{O}_{2} = \mathrm{wc}_{2} X^{\mu}X_{\mu}B^{\rho\sigma}B_{\rho\sigma}
& \mathcal{O}_{8} = \mathrm{wc}_{8}\bar{\psi}(i\gamma^{\mu}\partial_{\mu}-m)\psi-\frac{1}{4}F_{\mu\nu}F^{\mu\nu}
& \mathcal{O}_{10} = g^{\mu\nu} \\
\hline
\end{array}
\]
\end{document}