我想在 LaTeX 中创建这样的表格:
我该如何做呢?
答案1
只需耐心一点就可以删除不需要的规则。让分数不触及规则的间隙是通过一条不可见的规则获得的(顺便说一下,我会使用斜线形式)。
\documentclass{article}
\begin{document}
\[
\begin{array}{l|c|rr|c|c|}
\multicolumn{2}{c}{} & % omit the vertical lines
\multicolumn{1}{c}{x_1} &
\multicolumn{1}{c}{\mbox{\boldmath$x_6$}} &
\multicolumn{2}{c}{} \\
\cline{2-5}
& -1 & 1 & 3 & 0 & \multicolumn{1}{c}{} \\
\cline{2-6}
\mbox{\boldmath$x_1$}
& 1 & 7 & 2 & 5 & \rule{0pt}{1.2\ht\strutbox}\frac{5}{2} \\[1ex]
x_2
& 0 & 1 & -6 & 9 & - \\[1ex]
x_3
& 2 & -10 & 4 & 20 & 5 \\[1ex]
x_4
& 3 & -1 & 0 & 8 & - \\
\cline{2-6}
\multicolumn{2}{c|}{}
& -17 & 13 & 69 & \multicolumn{1}{c}{} \\
\cline{3-5}
\end{array}
\]
\end{document}
答案2
解决方案如下blkarray
:
% arara: pdflatex
\documentclass{article}
\usepackage{blkarray}
\usepackage{bm}
\begin{document}
\[
\renewcommand{\arraystretch}{1.1}
\begin{blockarray}{l*{5}{r}} % for your image, you will have to change column 2, 5, and 6 to `c` in all blocks.
& & x_5&\boldsymbol{x_6}&\\\cline{2-5}
\begin{block}{l|r|rr|r|r}
\null& -1 & 1 & -3 & 0 &\\
\end{block}\cline{2-6}
\begin{block}{l|r|rr|r|r|}
\boldsymbol{x_1} & 1 & 7 & 2 & 5 & \frac{5}{2}\\
x_2 & 0 & 1 & -6 & 9 & -\\
x_3 & 2 & -10 & 4 & 20 & 5\\
x_4 & 3 & -1 & 0 & 8 & -\\
\end{block}\cline{2-6}
\begin{block}{lr|rr|r|r}
\null& \null & -17 & 13 & 69 &\\
\end{block}\cline{3-5}
\end{blockarray}
\]
\end{document}
答案3
有tabular
\documentclass{article}
\usepackage{array,bm}
\newcolumntype{R}{>{$}r<{$}}
\newcolumntype{C}{>{$}c<{$}}
\renewcommand{\arraystretch}{1.2}
\begin{document}
\begin{tabular}{C|C|RR|C|C|}
\multicolumn{2}{c}{} & x_5 & \multicolumn{1}{r}{$\bm{x_6}$} \\
\cline{2-5}
& -1 & 1 & -3 & 0 \\
\cline{2-6}
\bm{x_1} & 1 & 7 & 2 & 5 & \frac{5}{2} \\
x_2 & 0 & 1 & -6 & 9 & - \\
x_3 & 2 & -10 & 4 & 20 & 5 \\
x_4 & 3 & -1 & 0 & 8 & - \\
\cline{2-6}
\multicolumn{2}{c|}{} & -17 & 13 & 69 \\
\cline{3-5}
\end{tabular}
\end{document}