我一直在寻找解决方案,但大多数情况下,修改所有行,或使用不同的包。我只想在数字接触水平线的地方添加填充,而不修改其他行。
\documentclass[12pt, a4paper]{report}
\usepackage[top=3cm,bottom=2.5cm,right=2.5cm,left=4cm]{geometry}
\usepackage{array}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{times}
\begin{document}
\begin{table}[h]
\centering
\small
% \renewcommand\cellalign{bc}
\setlength\tabcolsep{5pt}
\begin{tabular}{c|c|c|c|c|c|c|c|l}
\hline
\multirow{2}{2.5em}{\textbf{Var. basica}}
& \multirow{2}{*}{\textbf{ Eq.}}
& \multicolumn{6}{c|}{\textbf{Coeficiente}}
& \multirow{2}{*}{\textbf{Lado der.}} \\
\cline{3-8}
& &
$Z$ & $x_1$ & $x_2$ & $x_3$ & $x_4$ & $x_5$ \\
\hline
$Z$ & $(0)$ & $1$ & $-180$ & $-90$ & $0$ & $0$ & $0$ & $0$ \\
\hline
$x_3$ & $(1)$ & $0$ & $6$ & $8$ & $1$ & $0$ & $0$ & $48 \to \dfrac{48}{ 6} = 8 $ \\
\hline
$x_4$ & $(2)$ & $0$ & $1$ & $0$ & $0$ & $1$ & $0$ & $6 \to \dfrac{6}{1} = 6 \leftarrow min$ \\
\hline
$x_5$ & $(3)$ & $0$ & $0$ & $1$ & $1$ & $1$ & $1$ & $4$ \\
\hline
\end{tabular}
\caption{Aplicacion de la prueba de proporcion minima}
\label{tab:simplex_tabular_1}
\end{table}
\end{document}
答案1
答案2
我建议您使用策略性放置的\mathstrut
指令。
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
\begin{array}{c}
\hline \frac{48}{6}\\ \hline
\end{array}
\quad\text{vs.}\quad
\begin{array}{c}
\hline \frac{48^{\mathstrut}}{6_{\mathstrut}}\\ \hline
\end{array}
\hspace{1cm}
\begin{array}{c}
\hline \dfrac{48}{6}\\ \hline
\end{array}
\quad\text{vs.}\quad
\begin{array}{c}
\hline \dfrac{48^{\mathstrut}}{6_{\mathstrut}}\\ \hline
\end{array}
\]
\end{document}
答案3
这里,我使用了包\addstackgap[gapsize]{}
中的stackengine
值。我已设置\stackMath
,以便在数学模式下评估参数。为了演示,我在上方和下方添加了 2pt 的缓冲区48/6
,并在 中添加了 4pt 的缓冲区6/1
。
\documentclass[12pt, a4paper]{report}
\usepackage[top=3cm,bottom=2.5cm,right=2.5cm,left=4cm]{geometry}
\usepackage{array}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{times}
\usepackage{stackengine}
\stackMath
\begin{document}
\begin{table}[h]
\centering
\small
% \renewcommand\cellalign{bc}
\setlength\tabcolsep{5pt}
\begin{tabular}{c|c|c|c|c|c|c|c|l}
\hline
\multirow{2}{2.7em}{\textbf{Var. basica}}
& \multirow{2}{*}{\textbf{ Eq.}}
& \multicolumn{6}{c|}{\textbf{Coeficiente}}
& \multirow{2}{*}{\textbf{Lado der.}} \\
\cline{3-8}
& &
$Z$ & $x_1$ & $x_2$ & $x_3$ & $x_4$ & $x_5$ \\
\hline
$Z$ & $(0)$ & $1$ & $-180$ & $-90$ & $0$ & $0$ & $0$ & $0$ \\
\hline
$x_3$ & $(1)$ & $0$ & $6$ & $8$ & $1$ & $0$ & $0$ & $48 \to \addstackgap[2pt]{\dfrac{48}{ 6}} = 8 $ \\
\hline
$x_4$ & $(2)$ & $0$ & $1$ & $0$ & $0$ & $1$ & $0$ & $6 \to \addstackgap[4pt]{\dfrac{6}{1}} = 6 \leftarrow min$ \\
\hline
$x_5$ & $(3)$ & $0$ & $0$ & $1$ & $1$ & $1$ & $1$ & $4$ \\
\hline
\end{tabular}
\caption{Aplicacion de la prueba de proporcion minima}
\label{tab:simplex_tabular_1}
\end{table}
\end{document}
答案4
通过用带有密钥的包的{tabular}
环境替换该环境。{NiceTabular}
nicematrix
cell-space-limits=2pt
\documentclass[12pt, a4paper]{report}
\usepackage[top=3cm,bottom=2.5cm,right=2.5cm,left=4cm]{geometry}
\usepackage{array}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{times}
\usepackage{nicematrix}
\begin{document}
\begin{table}[h]
\centering
\small
% \renewcommand\cellalign{bc}
\setlength\tabcolsep{5pt}
\begin{NiceTabular}{c|c|c|c|c|c|c|c|l}[cell-space-limits=2pt]
\hline
\multirow{2}{2.5em}{\textbf{Var. basica}}
& \multirow{2}{*}{\textbf{ Eq.}}
& \multicolumn{6}{c|}{\textbf{Coeficiente}}
& \multirow{2}{*}{\textbf{Lado der.}} \\
\cline{3-8}
& &
$Z$ & $x_1$ & $x_2$ & $x_3$ & $x_4$ & $x_5$ \\
\hline
$Z$ & $(0)$ & $1$ & $-180$ & $-90$ & $0$ & $0$ & $0$ & $0$ \\
\hline
$x_3$ & $(1)$ & $0$ & $6$ & $8$ & $1$ & $0$ & $0$ & $48 \to \dfrac{48}{ 6} = 8 $ \\
\hline
$x_4$ & $(2)$ & $0$ & $1$ & $0$ & $0$ & $1$ & $0$ & $6 \to \dfrac{6}{1} = 6 \leftarrow min$ \\
\hline
$x_5$ & $(3)$ & $0$ & $0$ & $1$ & $1$ & $1$ & $1$ & $4$ \\
\hline
\end{NiceTabular}
\caption{Aplicacion de la prueba de proporcion minima}
\label{tab:simplex_tabular_1}
\end{table}
\end{document}