如何控制下表中单元格的大小?
\documentclass{article}
%\usepackage[utf8]{inputenc}
%\usepackage{array}
%\usepackage{wrapfig}
%\usepackage{multirow}
\usepackage{tabular}
\usepackage{makecell}
\setcellgapes{7pt}
\begin{document}
$\alpha$\quad
\begin{tabular}[t]{%
@{\rule[-1.5ex]{0pt}{4.5ex}}%
*{4}{>{\centering\arraybackslash}m{\dimexpr3ex-\tabcolsep}|}%
}
\multicolumn{1}{c}{} & \multicolumn{1}{c}{$i$} & \multicolumn{1}{c}{$j$} & \multicolumn{1}{c}{$k$} \\
\cline{2-4}
$i$ & T & F & T \\
\cline{2-4}
$j$ & T & F & T \\
\cline{2-4}
$k$ & F & T & F \\[-\arrayrulewidth]
\cline{2-4}
\end{tabular}
\end{document}
当我编译上述代码时,单元格并不像下面的图片那么小(正如我希望的那样):
答案1
和nicematrix
。
\documentclass{article}
\usepackage{nicematrix}
\begin{document}
\NiceMatrixOptions{cell-space-top-limit=2mm,cell-space-bottom-limit=1.5mm}
$B$\quad \begin{NiceTabular}[baseline=0]{ccc}%
[first-row,first-col,hvlines, columns-width=3.5mm]
& $i$ & $j$ & $k$ \\
$i$ & T & F & T \\
$j$ & T & F & T \\
$k$ & F & T & F \\
\end{NiceTabular}
\end{document}
答案2
像那样?
\documentclass{article}
\usepackage{array}
\begin{document}
\setlength{\tabcolsep}{2pt}
$\alpha$\quad
\begin{tabular}[t]{*{4}{c|}}
\multicolumn{1}{c}{} & \multicolumn{1}{c}{$i$} & \multicolumn{1}{c}{$j$} & \multicolumn{1}{c}{$k$} \\
\cline{2-4}
$i$ & T & F & T \\
\cline{2-4}
$j$ & T & F & T \\
\cline{2-4}
$k$ & F & T & F \\
\cline{2-4}
\end{tabular}
\end{document}
这也是使用 tikz 矩阵的侧视图。您可以使用选项、 和来控制单元格的高度和宽度以及字母和单元格边框之间的距离minimum height
:minimum width
inner sep
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}[cell/.style={rectangle,draw=black}, nodes in empty cells]
\matrix(table)[
matrix of nodes,
row sep =-\pgflinewidth,
column sep = -\pgflinewidth,
nodes={anchor=center,
minimum width=0.4cm,
minimum height=0.4cm,
fill=none,
draw=black,
inner sep=0pt},
column 1/.style = {nodes={draw=none}},
row 1/.style={nodes={draw=none}},
]
{ & $i$ & $j$ & $k$ \\
$i$ & T & F & T \\
$j$ & T & F & T \\
$k$ & F & T & F \\
};
\end{tikzpicture}
\end{document}