我目前正在撰写硕士论文,用作矩阵的表格看起来很糟糕。我怎样才能让它们看起来好一些?
\begin{table}[H]
\centering
\begin{tabular}{c|c|c|c|c}
&\textgreater& =+ & =- & \textless \\
\hline
\textgreater & 1 & 0 & 0 & -1 \\
\hline
=+ & 0 & 1 & 0 & 0 \\
\hline
=- & 0 & 0 & 1 & 0 \\
\hline
\textless & -1 & 0 & 0 & 1 \\
\hline
\end{tabular}
\end{table}
答案1
虽然美貌取决于啤酒持有者的眼光,但这里有一个选择:
\documentclass{article}
\usepackage{array}
\newcolumntype{C}[1]{>{\centering\arraybackslash$}p{#1}<{$}}
\begin{document}
\[
\begin{array}{c| *{4}{C{2em}}}
& \multicolumn{1}{c}{>} & =\joinrel+ & =\joinrel- & \multicolumn{1}{c}{<} \\
\hline
> & \phantom{-}1 & 0 & 0 & -1 \\
=\joinrel+ & \phantom{-}0 & 1 & 0 & \phantom{-}0 \\
=\joinrel- & \phantom{-}0 & 0 & 1 & \phantom{-}0 \\
< & -1 & 0 & 0 & \phantom{-}1
\end{array}
\]
\end{document}
答案2
这里有一些空气,没有幻影,还有包裹siunitx
。一些颜色,以及不同宽度的水平和垂直规则:
\documentclass{article}
\usepackage{array}
\usepackage[x11names]{xcolor}
\usepackage{colortbl}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{makecell}
\renewcommand\theadfont{\color{LightSteelBlue3}\mathversion{bold}}
\setcellgapes{5pt}
\makegapedcells
\begin{document}
\[\setlength\arraycolsep{1em}\arrayrulecolor{Tomato3}\setlength\arrayrulewidth{0.8pt}
\begin{array}{ @{}>{\color{LightSteelBlue3}\mathversion{bold}}c@{\quad}!{\color{Tomato3}\vrule width 1.2pt}*{4}{S[table-format = 1.0]}}
& {\thead{>}} & {\thead{=\joinrel+}} & {\thead{=\joinrel-}} & {\thead{<}} \\[-1ex]
\hline
> & -1 & 0 & 0 & -1 \\
=\joinrel+ & 0 & 1 & 0 & 0 \\
=\joinrel- & 0 & 0 & 1 & 0 \\
< & -1 & 0 & 0 & 1 \\[-2ex]
&
\end{array}
\]
\end{document}
答案3
使用回忆录类你也可以按照如下所示进行操作
\documentclass{memoir}
\begin{document}
\begin{table}[H]
\begin{tabular*}{0.95\textwidth}{@{\extracolsep{\fill}}l|rrrr}
\toprule
& \textgreater& \textbf{ =+} & \textbf{=-} & \textbf{\textless} \\
\midrule
\textgreater & \textbf {1} & \textbf{0} & \textbf{0} & \textbf{ -1}\\
=+ &\textbf{ 0} &\textbf{1} & \textbf{0} & \textbf{0} \\
=- &\textbf{ 0} & \textbf{0} & \textbf{1}&\textbf{ 0} \\
\textless &\textbf{ -1} & \textbf{0} &\textbf{0} &\textbf{1}\\
\bottomrule
\end{tabular*}
\end{table}
\end{document}
输出: