TeX - LaTeX Asked by Mass on June 18, 2021
I am trying to maintain the uniformity of equations living in different cells inside a table. Here is the code:
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^{munu}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^{rhosigma}B_{rhosigma}$ & $mathcal{O}_{8} = mathrm{wc}_{8}bar{psi}(igamma^{mu}partial_{mu}-m)psi-frac{1}{4}F_{munu}F^{munu}$ & $mathcal{O}_{10} = g^{munu}$ hline
end{tabular}
end{center}
It looks like a mess because of poor alignment. In addition to that, the expressions are very close to each other makes the equations unreadable. Can anyone guide me on how to fix these two issues:
Do you mean something like this:
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^{munu}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^{rhosigma}B_{rhosigma}$ & $mathcal{O}_{8} = mathrm{wc}_{8}bar{psi}(igamma^{mu}partial_{mu}-m)psi-frac{1}{4}F_{munu}F^{munu}$ & $mathcal{O}_{10} = g^{munu}$ hline
end{tabular}
end{center}
?
Correct answer by koleygr on June 18, 2021
Building upon koleygr's code, here is a slightly different version using an array
instead of a tabular
and phantom
to improve the alignment of the =
in the last column:
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^{munu}Z_{mu}(phi^{dagger}phi)^{2}
& mathcal{O}_{9phantom{1}} = gamma^{mu}gamma^{nu}+gamma^{nu}gamma^{mu}
hline
mathcal{O}_{2} = mathrm{wc}_{2} X^{mu}X_{mu}B^{rhosigma}B_{rhosigma}
& mathcal{O}_{8} = mathrm{wc}_{8}bar{psi}(igamma^{mu}partial_{mu}-m)psi-frac{1}{4}F_{munu}F^{munu}
& mathcal{O}_{10} = g^{munu}
hline
end{array}
]
end{document}
Update:
In order to increase the horizontal space between the text and a vertical line, you can adjust the value of arraycolsep
to suit your needs. To change the vertical space between the text and a horizontal line, you could use setcellgapes
from the makecell
package. The following MWE contains three somewhat exaggerated examples to show the effect of the two commands:
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^{munu}Z_{mu}(phi^{dagger}phi)^{2}
& mathcal{O}_{9phantom{1}} = gamma^{mu}gamma^{nu}+gamma^{nu}gamma^{mu}
hline
mathcal{O}_{2} = mathrm{wc}_{2} X^{mu}X_{mu}B^{rhosigma}B_{rhosigma}
& mathcal{O}_{8} = mathrm{wc}_{8}bar{psi}(igamma^{mu}partial_{mu}-m)psi-frac{1}{4}F_{munu}F^{munu}
& mathcal{O}_{10} = g^{munu}
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^{munu}Z_{mu}(phi^{dagger}phi)^{2}
& mathcal{O}_{9phantom{1}} = gamma^{mu}gamma^{nu}+gamma^{nu}gamma^{mu}
hline
mathcal{O}_{2} = mathrm{wc}_{2} X^{mu}X_{mu}B^{rhosigma}B_{rhosigma}
& mathcal{O}_{8} = mathrm{wc}_{8}bar{psi}(igamma^{mu}partial_{mu}-m)psi-frac{1}{4}F_{munu}F^{munu}
& mathcal{O}_{10} = g^{munu}
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^{munu}Z_{mu}(phi^{dagger}phi)^{2}
& mathcal{O}_{9phantom{1}} = gamma^{mu}gamma^{nu}+gamma^{nu}gamma^{mu}
hline
mathcal{O}_{2} = mathrm{wc}_{2} X^{mu}X_{mu}B^{rhosigma}B_{rhosigma}
& mathcal{O}_{8} = mathrm{wc}_{8}bar{psi}(igamma^{mu}partial_{mu}-m)psi-frac{1}{4}F_{munu}F^{munu}
& mathcal{O}_{10} = g^{munu}
hline
end{array}
]
end{document}
Answered by leandriis on June 18, 2021
Stll another variant: I replaced arraystretch
with some vertical padding at the top and bottom of cells obtained with the cellspace
package. Another small improvement is the use of the medsize fractions n defined by nccmath
, to avoid the size discrepancy between fractions in a tabular or array environment and the rest of the formula.
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^{munu}Z_{mu}(phi^{dagger}phi)^{2}
& mathcal{O}_{9phantom{1}} = gamma^{mu}gamma^{nu}+gamma^{nu}gamma^{mu}
hline
mathcal{O}_{2} = mathrm{wc}_{2} X^{mu}X_{mu}B^{rhosigma}B_{rhosigma}
& mathcal{O}_{8} = mathrm{wc}_{8}bar{psi}(igamma^{mu}partial_{mu}-m)psi-mfrac{1}{4}F_{munu}F^{munu}
& mathcal{O}_{10} = g^{munu}
hline
end{tabular}
]
end{document}
Answered by Bernard on June 18, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP