2

How to make this line longer? And split the head of table to two-rows?

\documentclass[12pt,a4paper]{report}

\usepackage[usenames]{xcolor}

\usepackage[english,czech]{babel}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{textcomp}

\usepackage[utf8]{inputenc}

\usepackage{dcolumn}        % lepší zarovnání sloupců v tabulkách
\usepackage{booktabs}       % lepší vodorovné linky v tabulkách
\usepackage{paralist}       % lepší enumerate a itemize
\usepackage[usenames]{xcolor}  % barevná sazba
\usepackage{lmodern,textcomp}
\usepackage{booktabs, makecell}
\usepackage[output-decimal-marker={,}]{siunitx}
\usepackage{amsmath, amssymb, bm}
\usepackage[nottoc]{tocbibind}
\usepackage{icomma,dcolumn,booktabs}
\setlength\heavyrulewidth{0.25ex}
\usepackage{array, cellspace, multirow, tabularx}

\newcommand{\mc}[1]{\multicolumn{1}{c}{#1}}
\usepackage{tabularx, ragged2e}


\begin{document}


\begin{table}\small
\caption{Původy měření}
\setlength\tabcolsep{3pt}
\begin{tabularx}{\textwidth}{l| c c c}
\Xhline{4\arrayrulewidth}
&&&\\[-10pt]
Parametr & Hodnota & Krok konvergence & Interval hodnot  \\[0.33ex]
\midrule


Perioda $P$ (dny)&  5,732436&   0,0001& (0;1000)\\
Hlavní poloosa $a$& 43,89991&   0,1&    (0;1000)\\
Poměr hmotností $q$&    0,3827& 0,01&   (0;100)\\
Rychlost $V_{\gamma}$&  21,75108&   1&  (-1000;1000)\\
Sklon orbity $i$&   80,41989&   1&  (0;180)\\
Argument periastru ${\omega}$&  147,91851&  1&  (0;180)\\
Derivace argumentu periastra $\dot \omega$& 0,00422&    0,0006875493&   (-1;57,29578)\\
Excentricita $e$&   0,0883& 0,001&  (0;1)\\
Synchronický parametr primáru $F_1$&    1&  0,1&    (0;1)\\
Synchronický parametr primáru $F_1$&    1&  0,1&    (0;1)\\
Efektivní teplota primáru $T_1$ \ ($\mathrm{K}$)&   30000&  300&    (3500;50000)\\
Efektivní teplota sekundáru $T_1$ \ ($\mathrm{K}$)& 19424&  300&    (3500;50000)\\
Povrchový potenciál primáru&    3,50473&    0,2&    (0;1000)\\
Povrchový potenciál sekundáru&  5,59423&    0,2&    (0;1000)\\
Albedo primáru& 1&  0,01&   (0,6;1)\\
Albedo sekundáru&   1&  0,01&   (0;1)\\



\Xhline{4\arrayrulewidth}
\addlinespace

\end{tabularx}

\end{table}

\end{document}

enter image description here

EDIT

\setlength\textwidth{145mm}
\setlength\textheight{247mm}
\setlength\oddsidemargin{15mm}
\setlength\evensidemargin{15mm}
\setlength\topmargin{0mm}
\setlength\headsep{0mm}
\setlength\headheight{0mm}
\let\openright=\clearpage

enter image description here

  • Check out the package multirow. – Raaja Nov 28 '18 at 8:25
3

A solution with the optional parameter after \\ and the usage of nested tables plus \vphantom command:

\documentclass[12pt,a4paper]{report}

\usepackage[usenames]{xcolor}

\usepackage[english]{babel}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{textcomp}

\usepackage[utf8]{inputenc}

\usepackage{dcolumn}        % lepší zarovnání sloupců v tabulkách
\usepackage{booktabs}       % lepší vodorovné linky v tabulkách
\usepackage{paralist}       % lepší enumerate a itemize
\usepackage[usenames]{xcolor}  % barevná sazba
\usepackage{lmodern,textcomp}
\usepackage{booktabs, makecell}
\usepackage[output-decimal-marker={,}]{siunitx}
\usepackage{amsmath, amssymb, bm}
\usepackage[nottoc]{tocbibind}
\usepackage{icomma,dcolumn,booktabs}
\setlength\heavyrulewidth{0.25ex}
\usepackage{array, cellspace, multirow, tabularx}

\newcommand{\mc}[1]{\multicolumn{1}{c}{#1}}
\usepackage{tabularx, ragged2e}


\begin{document}

A long text here just to show where the line width is. This text should break at least once

\begin{table}\small
\caption{Původy měření}
\setlength\tabcolsep{3pt}
\begin{tabular*}{\linewidth}{l|@{\extracolsep{\fill}}c c c}
\Xhline{4\arrayrulewidth}
&&&\\[-10pt]
\begin{tabular}{@{}c@{}}\\[-14pt]Parametr\\[-9pt]\vphantom{0} \end{tabular}& \begin{tabular}{@{}c@{}}\\[-14pt]Hodnota\\[-9pt]\vphantom{0}\end{tabular} & \begin{tabular}{@{}c@{}}\\[-14pt]Krok \\[-2.5pt]konvergence\\[-6pt]\vphantom{0}\end{tabular} & \begin{tabular}{@{}c@{}}\\[-14pt]Interval\\[-2.5pt] hodnot\\[-6pt]\vphantom{0}\end{tabular}  \\[-6pt]
\midrule


Perioda $P$ (dny)&  5,732436&   0,0001& (0;1000)\\
Hlavní poloosa $a$& 43,89991&   0,1&    (0;1000)\\
Poměr hmotností $q$&    0,3827& 0,01&   (0;100)\\
Rychlost $V_{\gamma}$&  21,75108&   1&  (-1000;1000)\\
Sklon orbity $i$&   80,41989&   1&  (0;180)\\
Argument periastru ${\omega}$&  147,91851&  1&  (0;180)\\
Derivace argumentu periastra $\dot \omega$& 0,00422&    0,0006875493&   (-1;57,29578)\\
Excentricita $e$&   0,0883& 0,001&  (0;1)\\
Synchronický parametr primáru $F_1$&    1&  0,1&    (0;1)\\
Synchronický parametr primáru $F_1$&    1&  0,1&    (0;1)\\
Efektivní teplota primáru $T_1$ \ ($\mathrm{K}$)&   30000&  300&    (3500;50000)\\
Efektivní teplota sekundáru $T_1$ \ ($\mathrm{K}$)& 19424&  300&    (3500;50000)\\
Povrchový potenciál primáru&    3,50473&    0,2&    (0;1000)\\
Povrchový potenciál sekundáru&  5,59423&    0,2&    (0;1000)\\
Albedo primáru& 1&  0,01&   (0,6;1)\\
Albedo sekundáru&   1&  0,01&   (0;1)\\



\Xhline{4\arrayrulewidth}
\addlinespace

\end{tabular*}

\end{table}

\end{document}

Output:

enter image description here

Explanation:

The optional argument after \\ is used to reduce (or increase -but here reducing-) the space between current and next row. I am using it to fix the correct spacing and make the one line rows of the table to seem centered in the line, but Also to reduce the last line spacing in order the \midrule to not break the vertical lines. For this reason, I added a last line using \vphantom{} command and reduced the space there. Also, to break the cells, I used tabulars inside your tabulars that contains @{} before and after the c argument in order to nor create extra space for the column separation.

EDIT: Also used a tabluar* environment instead of tabularx and the command @{\extracolsep{\fill}} after the first column in order to meke the width of three last columns, filling the line width.

Do not hesitate to ask for more explanation or whatever.

PS:Sorry but didn't have your language installed and removed it from babel options.

  • Thank you very much for your code with explanation. Could I ask is it possible to set spaces between last three columns to filling hole space behind the line? Something like \textwidth but only for this part. I editted the question - I added setting of list if it is needed and a picture (I would like to spread space in the end). – Elisabeth Nov 28 '18 at 9:06
  • 1
    @Elisabeth, I didn't noticed it was a tabularx... tabularx needs at least one column with extendable width like X column type in order to expand this (or these) columns to fill line width. So, you could just change your last 3 c columns to X columns and this should possibly fix your problem. Since I used the simpler (in order of package usage) commands, I edited by using tabular* and \extracolsep command. You may adapt this way or the one of this comment: {l| X X X} – koleygr Nov 28 '18 at 9:21
  • 1
    The correct way with tabularx is {l | >{\centering\arraybackslash}X {\centering\arraybackslash}X >{\centering\arraybackslash}X} – koleygr Nov 28 '18 at 9:33
3

By using multirow package you can easily achieve this. Just use \usepackage{multirow} in your preamble, and put whatever the things you need inside the multirow environment. In this case, it is you basically your header.

\documentclass[12pt,a4paper]{report}

\usepackage[usenames]{xcolor}

\usepackage[english,czech]{babel}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{textcomp}

\usepackage[utf8]{inputenc}

\usepackage{dcolumn}        % lepší zarovnání sloupců v tabulkách
\usepackage{booktabs}       % lepší vodorovné linky v tabulkách
\usepackage{paralist}       % lepší enumerate a itemize
\usepackage[usenames]{xcolor}  % barevná sazba
\usepackage{lmodern,textcomp}
\usepackage{booktabs, makecell}
\usepackage[output-decimal-marker={,}]{siunitx}
\usepackage{amsmath, amssymb, bm}
\usepackage[nottoc]{tocbibind}
\usepackage{icomma,dcolumn,booktabs}
\setlength\heavyrulewidth{0.25ex}
\usepackage{array, cellspace, multirow, tabularx}

\newcommand{\mc}[1]{\multicolumn{1}{c}{#1}}
\usepackage{tabularx, ragged2e}

\usepackage{multirow}
\begin{document}


\begin{table}\small
\caption{Původy měření}
\setlength\tabcolsep{3pt}
\begin{tabularx}{\textwidth}{l| c c c}
\Xhline{4\arrayrulewidth}
&&&\\[-10pt]
\multirow{2}{*}{Parametr} & \multirow{2}{*}{Hodnota} & Krok  & Interval   \\[0.33ex]
 &  & konvergence & hodnot  \\[0.33ex]
\midrule


Perioda $P$ (dny)&  5,732436&   0,0001& (0;1000)\\
Hlavní poloosa $a$& 43,89991&   0,1&    (0;1000)\\
Poměr hmotností $q$&    0,3827& 0,01&   (0;100)\\
Rychlost $V_{\gamma}$&  21,75108&   1&  (-1000;1000)\\
Sklon orbity $i$&   80,41989&   1&  (0;180)\\
Argument periastru ${\omega}$&  147,91851&  1&  (0;180)\\
Derivace argumentu periastra $\dot \omega$& 0,00422&    0,0006875493&   (-1;57,29578)\\
Excentricita $e$&   0,0883& 0,001&  (0;1)\\
Synchronický parametr primáru $F_1$&    1&  0,1&    (0;1)\\
Synchronický parametr primáru $F_1$&    1&  0,1&    (0;1)\\
Efektivní teplota primáru $T_1$ \ ($\mathrm{K}$)&   30000&  300&    (3500;50000)\\
Efektivní teplota sekundáru $T_1$ \ ($\mathrm{K}$)& 19424&  300&    (3500;50000)\\
Povrchový potenciál primáru&    3,50473&    0,2&    (0;1000)\\
Povrchový potenciál sekundáru&  5,59423&    0,2&    (0;1000)\\
Albedo primáru& 1&  0,01&   (0,6;1)\\
Albedo sekundáru&   1&  0,01&   (0;1)\\



\Xhline{4\arrayrulewidth}
\addlinespace

\end{tabularx}

\end{table}

\end{document}

which will give you:

enter image description here

  • 1
    if you change your code to contain some negative space after some `\` in order the midrule not to be broken your answer will possibly chosen as the accepted answer because it is simpler than mine, but unfortunately does not (yet) solves the problem with the broken line... You may change it in order to solve this problem too and then will possibly be the accepted answer. (+1) – koleygr Nov 28 '18 at 8:57
  • @koleygr I will look into that :) thanks for the info :) – Raaja Nov 28 '18 at 8:59
  • 1
    Welcome @Raaja, \toprule, \midrule and \bottomrule are not supposed to used in combination with vertical lines and they are breaking them.... The solution is this kind of reducing line spacing if (and only if) the vertical lines are really needed there. Happy TeXing. – koleygr Nov 28 '18 at 9:02
2

your mwe (minimal work example) have many issues:

  • in preamble you have really meas with loaded packages (try to grout them regarding their purpose (fonts, tables, math, ...). on this way you will have better overview over used packages)
  • do you really need so many package?
  • it is sufficient that you load any package only ones
  • your report will be more nice if you will use the same design principle at all tables (some your previous table use booktabs rules, this use lines defined by makecell
  • use of tabularx require that at least one column had to be X type or type derived from it
  • use of \addlinespace after last rule in table has no sense

off-topic: beside used packages see if the use of the caption package can help you in design of tables' and figures' captions. also for page layout is simpler to use the geometry package as defining borders as you show in edited part of your question.

correction your table code (all changes are market by % <---), in which i didn't consider my off-topic comment, is:

\documentclass[12pt,a4paper]{report}

\usepackage[english,czech]{babel}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{textcomp}

\usepackage[utf8]{inputenc}

\usepackage{paralist}           % lepší enumerate a itemize
\usepackage[usenames]{xcolor}   % barevná sazba
\usepackage[output-decimal-marker={,}]{siunitx}
\usepackage{amsmath, amssymb, bm}
\usepackage[nottoc]{tocbibind}
\usepackage{icomma}             % <--
\usepackage{dcolumn}            % lepší zarovnání sloupců v tabulkách
\usepackage{array,
            booktabs,           % lepší vodorovné linky v tabulkách
            cellspace,
            makecell,
            multirow,
            tabularx}
\newcommand{\mc}[1]{\multicolumn{1}{c}{#1}}
\setlength\heavyrulewidth{0.25ex}

\usepackage{ragged2e}

\begin{document}
    \begin{table}
    \caption{Původy měření}
    \renewcommand\arraystretch{1.2}                 % <---
    \small
\begin{tabularx}{\textwidth}{ @{} X | c c c @{}}    % <---
    \Xhline{4\arrayrulewidth}
Parametr & Hodnota & \makecell{Krok\\ konvergence} & \makecell{Interval\\ hodnot}  \\
    \Xhline{2\arrayrulewidth}
Perioda $P$ (dny)       &  5,732436     & 0,0001    & (0;1000)      \\
Hlavní poloosa $a$      & 43,89991      & 0,1       & (0;1000)      \\
Poměr hmotností $q$     &  0,3827       & 0,01      & (0;100)       \\
Rychlost $V_{\gamma}$   &  21,75108     &   1       & (-1000;1000)  \\
Sklon orbity $i$        &  80,41989     &   1       & (0;180)       \\
Argument periastru ${\omega}$                       % <---
                        &  147,91851    &  1&  (0;180)              \\
Derivace argumentu periastra $\dot{\omega}$         % <---
                        & 0,00422       & 0,0006875493  & (-1;57,29578)\\
Excentricita $e$        &   0,0883      & 0,001     & 0;1)          \\
Synchronický parametr primáru $F_1$ & 1 &  0,1      & (0;1)         \\
Synchronický parametr primáru $F_1$ & 1 &  0,1      & (0;1)         \\
Efektivní teplota primáru $T_1$ ($\mathrm{K}$)      % <---
                        &   30000       & 300       & (3500;50000)  \\
Efektivní teplota sekundáru $T_1$ ($\mathrm{K}$)    % <---
                        & 19424         & 300       & (3500;50000)  \\
Povrchový potenciál primáru & 3,50473   & 0,2       & (0;1000)      \\
Povrchový potenciál sekundáru   & 5,59423  & 0,2    & (0;1000)      \\
Albedo primáru          & 1             & 0,01      & (0,6;1)       \\
Albedo sekundáru        & 1             & 0,01      & (0;1)         \\
    \Xhline{4\arrayrulewidth}
\end{tabularx}
    \end{table}
\end{document}

which gives

enter image description here

however, without use of vertical lines in table and with rules from booktabs you will obtain (according to my taste, of course) nicer table with the same design principle as we suggest you at your others similar question:

    \begin{table}
    \caption{Původy měření}
    \small
\begin{tabularx}{\textwidth}{ @{} X c c c @{}}    
    \toprule                                        % <---
Parametr & Hodnota & \makecell{Krok\\ konvergence}  & \makecell{Interval\\ hodnot}  \\
    \midrule                                        % <---
Perioda $P$ (dny)       &  5,732436     & 0,0001    & (0;1000)      \\
Hlavní poloosa $a$      & 43,89991      & 0,1       & (0;1000)      \\
Poměr hmotností $q$     &  0,3827       & 0,01      & (0;100)       \\
Rychlost $V_{\gamma}$   &  21,75108     &   1       & (-1000;1000)  \\
Sklon orbity $i$        &  80,41989     &   1       & (0;180)       \\
Argument periastru ${\omega}$                       % <---
                        &  147,91851    &  1&  (0;180)              \\
Derivace argumentu periastra $\dot{\omega}$         % <---
                        & 0,00422       & 0,0006875493  & (-1;57,29578)\\
Excentricita $e$        &   0,0883      & 0,001     & 0;1)          \\
Synchronický parametr primáru $F_1$ & 1 &  0,1      & (0;1)         \\
Synchronický parametr primáru $F_1$ & 1 &  0,1      & (0;1)         \\
Efektivní teplota primáru $T_1$ ($\mathrm{K}$)      % <---
                        &   30000       & 300       & (3500;50000)  \\
Efektivní teplota sekundáru $T_1$ ($\mathrm{K}$)    % <---
                        & 19424         & 300       & (3500;50000)  \\
Povrchový potenciál primáru & 3,50473   & 0,2       & (0;1000)      \\
Povrchový potenciál sekundáru   & 5,59423  & 0,2    & (0;1000)      \\
Albedo primáru          & 1             & 0,01      & (0,6;1)       \\
Albedo sekundáru        & 1             & 0,01      & (0;1)         \\
    \bottomrule                                     % <---
\end{tabularx}
    \end{table}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.