Help with table

The changes I made with respect to your MWE are the following:

  1. you can use \centering instead of \begin{center} ... \end{center} inside the table environment
  2. you need to embed the content of the first row (the heading) in a \multicolumn{1}{c}{} command to override the D column type
  3. the syntax *{n}{t} allows you to define n columns of type t
  4. I added the \otoprule separator so that you can have the same line thickness of \toprule but equal spacing between the rows for the headings
  5. the extra spacing between the columns (which appears in your reference image) can be achieved with \setlength{\tabcolsep}{10pt}. Instead of 10pt you can put the length you prefer. If you want to stick with the default column spacing, just comment out the line.
  6. Even though in your reference image the caption is at the bottom of the table, it is better to keep it on top, as you already did.

So you have:

\documentclass[10pt,a4paper,twoside]{article}
\usepackage{dcolumn}
\usepackage{booktabs}
\usepackage{multirow}

\newcommand{\otoprule}{\midrule[\heavyrulewidth]} % vertically centered with respect to the row above and below, but same thickness as \{top,bottom}rule

\begin{document}

\begin{table}[h!]
    \centering
    \caption{Experimentální výsledky}
    \label{tab:table1}
    \setlength{\tabcolsep}{10pt}
    \begin{tabular}{l *{5}{D{,}{,}{3.5}}}
        \toprule
        & \multicolumn{1}{c}{$\alpha$} & \multicolumn{1}{c}{$\beta$} & \multicolumn{1}{c}{$\gamma$} & \multicolumn{1}{c}{$\delta$} & \multicolumn{1}{c}{$\chi$} \\ \otoprule
        Pokus 1                  & 9,03983  & 20,7265 & 70,905  & -31,83   & -75,2      \\ \midrule
        \multirow{4}{*}{Pokus 2} & 84,99683 & -88,7   & 33,551  & 83,436   & -59,9      \\
                                 & -67      & -81,46  & -98     & 54,0456  & -28        \\
                                 & -23,8    & -63     & -9,47   & 58,03674 & -89,1      \\
                                 & -61,4    & -68,19  & -13,2   & -80,2    & -47,3      \\ \midrule
        Pokus 6                  & -87,94   & -52     & 68,548  & 17,0284  & -49,1      \\ \midrule
        Pokus 7                  & -72,55   & -66,06  & -50     & -66,3    & 92,27074   \\ \midrule
        Pokus 8                  & 12,475   & 73,464  & 23,9323 & 52,959   & -87,71     \\ \midrule
        Pokus 9                  & 99,24615 & -27,17  & 49,5099 & 88,7448  & 87,22619   \\ \midrule
        Pokus 10                 & 99,268   & 83,8816 & -94,4   & -25,5    & 47,873     \\
        \bottomrule
    \end{tabular}
\end{table}

\end{document}

enter image description here


With siunitx and correct defined numbers format the MWE is:

\documentclass[10pt,a4paper,twoside]{article}
\usepackage{booktabs, multirow}
\usepackage{siunitx}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
    \begin{table}[h!]
    \centering
    \sisetup{output-decimal-marker={,}}
\caption{Experimentální výsledky}
\label{tab:table1}
\begin{tabular}{ l S[table-format=-2.5]
              *{2}{S[table-format=-2.4]}
              *{2}{S[table-format=-2.5]}
               }
        \toprule
        & {$\alpha$} & {$\beta$} & {$\gamma$} & {$\delta$} & {$\chi$} \\ 
        \midrule
Pokus 1     & 9,03983  & 20,7265 & 70,905  & -31,83   & -75,2 \\ 
        \midrule
Pokus 1     & 9,03983  & 20,7265 & 70,905  & -31,83   & -75,2 \\ \hline
\multirow{4}{*}{Pokus 2}
            & 84,99683 & -88,7   & 33,551  & 83,436   & -59,9       \\
            & -67      & -81,46  & -98     & 54,0456  & -28         \\
            & -23,8    & -63     & -9,47   & 58,03674 & -89,1       \\
            & -61,4    & -68,19  & -13,2   & -80,2    & -47,3       \\
    \midrule
Pokus 6     & -87,94   & -52     & 68,548  & 17,0284  & -49,1       \\
Pokus 7     & -72,55   & -66,06  & -50     & -66,3    & 92,27074    \\
Pokus 8     & 12,475   & 73,464  & 23,9323 & 52,959   & -87,71      \\
Pokus 9     & 99,24615 & -27,17  & 49,5099 & 88,7448  & 87,22619    \\
Pokus 10    & 99,268   & 83,8816 & -94,4   & -25,5    & 47,873      \\
    \bottomrule
\end{tabular}
    \end{table}
\end{document}

enter image description here

(red lines indicate text borders)

siunitx enable simple rounding all number for example to three decimal digits:

\documentclass[a4paper,twoside]{article}
\usepackage{booktabs, multirow}
\usepackage{siunitx}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
    \begin{table}[h!]
    \centering
    \sisetup{output-decimal-marker={,},
             round-mode=places,
             round-precision=3,
             round-integer-to-decimal,
             table-format=-2.3            
             }          
\caption{Experimentální výsledky}
\label{tab:table1}
\begin{tabular}{ l *{5}{S} }
        \toprule
        & {$\alpha$} & {$\beta$} & {$\gamma$} & {$\delta$} & {$\chi$} \\ 
        \midrule
Pokus 1     & 9,03983  & 20,7265 & 70,905  & -31,83   & -75,2 \\ 
        \midrule
\multirow{4}{*}{Pokus 2}
            & 84,99683 & -88,7   & 33,551  & 83,436   & -59,9       \\
            & -67      & -81,46  & -98     & 54,0456  & -28         \\
            & -23,8    & -63     & -9,47   & 58,03674 & -89,1       \\
            & -61,4    & -68,19  & -13,2   & -80,2    & -47,3       \\
    \midrule
Pokus 6     & -87,94   & -52     & 68,548  & 17,0284  & -49,1       \\
Pokus 7     & -72,55   & -66,06  & -50     & -66,3    & 92,27074    \\
Pokus 8     & 12,475   & 73,464  & 23,9323 & 52,959   & -87,71      \\
Pokus 9     & 99,24615 & -27,17  & 49,5099 & 88,7448  & 87,22619    \\
Pokus 10    & 99,268   & 83,8816 & -94,4   & -25,5    & 47,873      \\
    \bottomrule
\end{tabular}
    \end{table}
\end{document}

enter image description here

Tags:

Tables