TransWikia.com

How to increase space between tabulars inside a table

TeX - LaTeX Asked by wit4r7 on August 12, 2021

I have a table with six tabular inside. They all belong to one problem and caption.

I positioned them with hfill, which works ok, but there could be more space between the two rows of tabular. hspace did not work.

How can I increase the space?

Here is my TeX

documentclass{scrartcl}
usepackage{float}
usepackage[a4paper, top=3cm,bottom=3cm,left=2.5cm,right=2cm]{geometry} 
usepackage{bm}
begin{document}

begin{table}[H]
    centering
    begin{tabular}{c|cccc}
      bm{$K_0$} & $Q_0$ & $Q_0$ & $bar Q_0$ & $bar Q_0$ 
      hline
      $Q_1$      & X & 1 & X & X 
      $bar Q_1$ & 1 & 1 & X & X 
      hline
      & $Q_2$ & $bar Q_2$ & $bar Q_2$ & $ Q_2$ 
    end{tabular}
    hfill
    begin{tabular}{c|cccc}
      bm{$J_0$} & $Q_0$ & $Q_0$ & $bar Q_0$ & $bar Q_0$ 
      hline
      $Q_1$      & X & X & 1 & 0 
      $bar Q_1$ & X & X & 1 & 1 
      hline
      & $Q_2$ & $bar Q_2$ & $bar Q_2$ & $ Q_2$ 
    end{tabular}
    hfill
    begin{tabular}{c|cccc}
      bm{$K_1$}  & $Q_0$ & $Q_0$ & $bar Q_0$ & $bar Q_0$ 
      hline
      $Q_1$      & X & 1 & 0 & 1 
      $bar Q_1$ & X & X & X & X 
      hline
      & $Q_2$ & $bar Q_2$ & $bar Q_2$ & $ Q_2$ 
    end{tabular}
    hfill
    begin{tabular}{c|cccc}
      bm{$J_1$}  & $Q_0$ & $Q_0$ & $bar Q_0$ & $bar Q_0$ 
      hline
      $Q_1$      & X & X & X & X 
      $bar Q_1$ & 1 & 1 & 0 & X 
      hline
      & $Q_2$ & $bar Q_2$ & $bar Q_2$ & $ Q_2$ 
    end{tabular}
    hfill
    begin{tabular}{c|cccc}
      bm{$K_2$}  & $Q_0$ & $Q_0$ & $bar Q_0$ & $bar Q_0$ 
      hline
      $Q_1$      & X & X & X & 1 
      $bar Q_1$ & 0 & X & 0 & X 
      hline
      & $Q_2$ & $bar Q_2$ & $bar Q_2$ & $ Q_2$ 
    end{tabular}
    hfill
    begin{tabular}{c|cccc}
      bm{$J_2$}  & $Q_0$ & $Q_0$ & $bar Q_0$ & $bar Q_0$ 
      hline
      $Q_1$      & X & 1 & X & X 
      $bar Q_1$ & X & X & 0 & X 
      hline
      & $Q_2$ & $bar Q_2$ & $bar Q_2$ & $ Q_2$ 
    end{tabular}
    hfill
    caption{Caption}
    label{tab:my_label}
end{table}
end{document}

This is what it looks like
Example of my tables

One Answer

(re-posting my earlier comment as an answer, so that this query can be considered to have received an "official" answer).

To achieve your formatting objective, you should replace the third hfill directive with an all-blank line (to induce a paragraph break) followed by bigskip before the next instance of begin{tabular}.

Some additional comments: (i) You may (actually, should) omit the centering directive as it doesn't do anything in the your setup. (ii) The sixth and final hfill directive should be deleted (or commented out). (iii) bm (short for "bold math") should be employed only in math mode; hence, do replace bm{$K_0$} with $bm{K_0}$, bm{$J_0$} with $bm{J_0}$, etc. (iv) Using [H] to force the placement of the table "right here, damn it!" can actually be counterproductive; use [ht!] instead.

enter image description here

documentclass{scrartcl}
usepackage{float}
usepackage[a4paper, vmargin=3cm, left=2.5cm, right=2cm]{geometry} 
usepackage{bm}
begin{document}

begin{table}[H]
    %centering % <-- not needed
    begin{tabular}{c|cccc}
      $bm{K_0}$ & $Q_0$ & $Q_0$ & $bar Q_0$ & $bar Q_0$ 
      hline
      $Q_1$      & X & 1 & X & X 
      $bar Q_1$ & 1 & 1 & X & X 
      hline
      & $Q_2$ & $bar Q_2$ & $bar Q_2$ & $ Q_2$ 
    end{tabular}
    hfill
    begin{tabular}{c|cccc}
      $bm{J_0}$ & $Q_0$ & $Q_0$ & $bar Q_0$ & $bar Q_0$ 
      hline
      $Q_1$      & X & X & 1 & 0 
      $bar Q_1$ & X & X & 1 & 1 
      hline
      & $Q_2$ & $bar Q_2$ & $bar Q_2$ & $ Q_2$ 
    end{tabular}
    hfill
    begin{tabular}{c|cccc}
      $bm{K_1}$  & $Q_0$ & $Q_0$ & $bar Q_0$ & $bar Q_0$ 
      hline
      $Q_1$      & X & 1 & 0 & 1 
      $bar Q_1$ & X & X & X & X 
      hline
      & $Q_2$ & $bar Q_2$ & $bar Q_2$ & $ Q_2$ 
    end{tabular}

    bigskip % <-- new, in lieu of hfill
    begin{tabular}{c|cccc}
      $bm{J_1}$  & $Q_0$ & $Q_0$ & $bar Q_0$ & $bar Q_0$ 
      hline
      $Q_1$      & X & X & X & X 
      $bar Q_1$ & 1 & 1 & 0 & X 
      hline
      & $Q_2$ & $bar Q_2$ & $bar Q_2$ & $ Q_2$ 
    end{tabular}
    hfill
    begin{tabular}{c|cccc}
      $bm{K_2}$  & $Q_0$ & $Q_0$ & $bar Q_0$ & $bar Q_0$ 
      hline
      $Q_1$      & X & X & X & 1 
      $bar Q_1$ & 0 & X & 0 & X 
      hline
      & $Q_2$ & $bar Q_2$ & $bar Q_2$ & $ Q_2$ 
    end{tabular}
    hfill
    begin{tabular}{c|cccc}
      $bm{J_2}$  & $Q_0$ & $Q_0$ & $bar Q_0$ & $bar Q_0$ 
      hline
      $Q_1$      & X & 1 & X & X 
      $bar Q_1$ & X & X & 0 & X 
      hline 
      & $Q_2$ & $bar Q_2$ & $bar Q_2$ & $ Q_2$ 
    end{tabular}
    %hfill % <-- not needed either
    caption{Caption}
    label{tab:my_label}
end{table}
end{document}

Correct answer by Mico on August 12, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP