2

I have been searching for a solution, but most modify all rows, or use a different packages. I would like to only add padding where the numbers are touching the horizontal lines, without modifying the other rows.

\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}

table with issues

5
  • why \dfrac not \frac? also min should be\mathrm{min} but \rule[xxx]{0pt}{yyy} will allow you to force any amount of space Commented May 29, 2023 at 18:16
  • @DavidCarlisle, Could you please elaborate on that? do you mean \rule.. instead of \hline? Commented May 29, 2023 at 18:37
  • If you would use solutions from case B and C (which use tabularray package for writing of tables) in my answer to your previous question (tex.stackexchange.com/questions/686961/…), than you would have desired behaviours of rows.
    – Zarko
    Commented May 29, 2023 at 20:56
  • @Zarko, I have a pretty long document, with dozens of tables only using tabular, I think last time I tried using other table packages, I got some conflicts, that is why I have been sticking to tabular only. Thanks for mentioning it though. Commented May 29, 2023 at 21:11
  • Well, then struggle with your problems. Using tabularray along other table doesn't make any conflict with other tables' packages. You have problems with some other consistency in your document. Since it is not known, to me I can't advice how to manage with them.
    – Zarko
    Commented May 30, 2023 at 5:40

4 Answers 4

7

I would use \frac not \dfrac but you can force space by adding a strut

enter image description here

from

$x_3$ & $(1)$   & $0$  & $6$  & $8$ & $1$  & $0$ & $0$ 
              & \rule[-12pt]{1pt}{30pt}$48 \to \dfrac{48}{ 6} = 8 $ \\

adjust the lengths to your requirements. The {1pt} width is just for easy debugging, change to {0pt} at the end so it is invisible.

5

I suggest you use strategically placed \mathstrut directives.

enter image description here

\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

Here, I use \addstackgap[gapsize]{} from the stackengine package. I have set \stackMath so that the argument is evaluated in math mode. Just for demonstration, I add 2pt of buffer above and below 48/6 and 4pt of buffer to 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}

enter image description here

3

By replacing the environment {tabular} by an environment {NiceTabular} of the package nicematrix with the key 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}

Output of the above code

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .