![我如何在 LaTeX 中创建这样的单纯形表?](https://linux22.com/image/307802/%E6%88%91%E5%A6%82%E4%BD%95%E5%9C%A8%20LaTeX%20%E4%B8%AD%E5%88%9B%E5%BB%BA%E8%BF%99%E6%A0%B7%E7%9A%84%E5%8D%95%E7%BA%AF%E5%BD%A2%E8%A1%A8%EF%BC%9F.png)
我想在 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}