2

i'm trying to make create this table using tabularx but for some reason the separator won't show up.

\begin{table}[h!]
\centering
\begin{small}
    \renewcommand*{\arraystretch}{1.4}
    \begin{tabularx}{\textwidth} { 
            >{\centering\arraybackslash}X |
            >{\centering\arraybackslash}X 
            >{\centering\arraybackslash}X |
            >{\centering\arraybackslash}X 
            >{\centering\arraybackslash}X |
            >{\centering\arraybackslash}X 
            >{\centering\arraybackslash}X 
        }
        \toprule\
        &   \multicolumn{2}{c}{$t_{1,B}$= 304,15K }& \multicolumn{2}{c}{$t_{1,D}$= 306,15K} & \multicolumn{2}{c}{$t_{1,S}$= 301,15K}\\ 
        & $EER_{real,min,B}$  [-]& $c_{gesamt,min}$ [€/kW]&$EER_{real,min,D}$ [-]& $c_{gesamt,min}$ [€/kW] & $EER_{real,min,S}$ [-] & $c_{gesamt,min}$ [€/kW]\\ 
        \midrule
        $t_{1}-1K$     &    2,93 & 1181    & 3,54 & 1878,96 & 5,23 & 1588,32\\
        $t_{1}$       & 2,80 & 1255,59 & 3,38 & 1969,74 & 4,95 & 1722,10\\
        $t_{1}+1K$     & 2,69 & 1326,91 & 3,25 & 2057,17 & 4,56 & 1847,59\\
        \bottomrule
    \end{tabularx}
\end{small}
\caption{Verschiebung der minimalen Punkt der Gesamtkosten (Index: \textbf{B}erlin, \textbf{D}ubai, \textbf{S}urabaya)}
\label{tab:EERreal_Verschiebung}

\end{table}

enter image description here

Thank you!

1
  • 1
    \multicolumn@{2}{c|}{...} should work. Apart from that, please be aware that the horizontal lines Form the booktabs package were designed to be used in tables without vertical lines, hence the small gaps around the intersections. – leandriis Jun 21 at 9:30
3

I would like to recommend that you (a) omit all vertical lines and (b) switch from a tabularx to a tabular* environment. I would also suggest distinguishing more systematically between material that belongs in caption and material that belongs in a legend.

enter image description here

\documentclass{article}
\usepackage{amsmath,array,booktabs}

\begin{document}
\begin{table}[h!]
\setlength\tabcolsep{0pt}
\small
    \renewcommand*{\arraystretch}{1.4}
    \begin{tabular*}{\textwidth} {@{\extracolsep{\fill}}
            l *{6}{c} }
        \toprule
        & \multicolumn{2}{c}{$t_{1,B}={}$304,15K}
        & \multicolumn{2}{c}{$t_{1,D}={}$306,15K} 
        & \multicolumn{2}{c}{$t_{1,S}={}$301,15K}\\ 
        \cmidrule{2-3} \cmidrule{4-5} \cmidrule{6-7}
        & $EER_{\mathrm{real,min},B}$ & $c_{\mathrm{ges.,min}}$  &
          $EER_{\mathrm{real,min},D}$ & $c_{\mathrm{ges.,min}}$  &
          $EER_{\mathrm{real,min},S}$ & $c_{\mathrm{ges.,min}}$ \\ {}
        & [--] & [€/kW] & [--] & [€/kW] & [--] & [€/kW] \\
        \midrule
        $t_{1}-1K$ & 2,93 & 1181\phantom{,00} & 3,54 & 1878,96 & 5,23 & 1588,32\\
        $t_{1}$    & 2,80 & 1255,59 & 3,38 & 1969,74 & 4,95 & 1722,10\\
        $t_{1}+1K$ & 2,69 & 1326,91 & 3,25 & 2057,17 & 4,56 & 1847,59\\
        \bottomrule
        \addlinespace
        \multicolumn{7}{l}{\footnotesize Index: \textbf{B}erlin, \textbf{D}ubai, \textbf{S}urabaya} 
    \end{tabular*}
\caption{Verschiebung der minimalen Punkte der Gesamtkosten}
\label{tab:EERreal_Verschiebung}
\end{table}
\end{document}
2

The only thing you need to change is inside your multicolumns:

\multicolumn{2}{c|}{$t_{1,B}$= 304,15K }& \multicolumn{2}{c|}{$t_{1,D}$= 306,15K} & \multicolumn{2}{c}{$t_{1,S}$= 301,15K}

You need to repeat that you want to have the horizontal rule.

NOTE: Type the vertical bar only once, so do not type |c| because this will look odd (like you have double line width).


If you are interested in some additional improvements:

  • Usually you write non-mathematical indices upright, that's why I would say EER_{\mathrm{real, min, B}} or EER_{\mathrm{real}, \mathrm{min}, \mathrm{B}} (assuming that 'B' is a non-mathematic index). Everything you can spell out to a 'natrual language word', like 'real', 'min', 'gesamt' I would write upright, everything else (like x_i, the i-th component of a vector) I'd leave in normal math mode.
  • As leandriis said, the booktabs package is designed for tabulars without vertical lines as the author doesn't like them at all.
2

Small variant of @Mico answer. By use of the makcell and siunitx package, defined new math operators:

\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator{\real}{real}
\DeclareMathOperator{\ges}{ges}
\usepackage{array, booktabs, makecell}
\NewExpandableDocumentCommand\mcc{O{1}m}{\multicolumn{#1}{c}{#2}}
\usepackage{siunitx}

\begin{document}
    \begin{table}[ht]
\setlength\tabcolsep{0pt}
\renewcommand*{\arraystretch}{1.4}
\sisetup{group-minimum-digits = 4,
         output-decimal-marker={,}}         
    \small
\begin{tabular*}{\textwidth} {@{\extracolsep{\fill}} 
                >{$}l<{$} *{3}{S[table-format=1.2]S[table-format=4.2]} 
                             }
    \toprule
    & \mcc[2]{$t_{1,\mathrm{B}} = \qty{304,15}{K}$}
        & \mcc[2]{$t_{1,\mathrm{D}} = \qty{306,15}{K}$}
            & \mcc[2]{$t_{1,\mathrm{S}}= \qty{301,15}{K}$}\\
    \cmidrule{2-3} \cmidrule{4-5} \cmidrule{6-7}
    & {\makecell{$EER_{\real,\min,\mathrm{B}}$\\ {[-]}}}    
        & {\makecell{$c_{\ges.,\min}$\\ {[€/kW]}}}  
            & {\makecell{$EER_{\real,\min,\mathrm{D}}$\\ {[-]}}}     
                & {\makecell{$c_{\ges.,\min}$\\ {[€/kW]}}} 
                    & {\makecell{$EER_{\real,\min,\mathrm{S}}$\\ {[-]}}}     
                        & {\makecell{$c_{\ges.,\min}$\\ {[€/kW]}}}          \\
    \midrule
t_{1}-\qty{1}{K}   
    & 2,93 & 1181    & 3,54 & 1878,96 & 5,23 & 1588,32\\
 t_{1}          
    & 2,80 & 1255,59 & 3,38 & 1969,74 & 4,95 & 1722,10\\
 t_{1}+\qty{1}{K}
    & 2,69 & 1326,91 & 3,25 & 2057,17 & 4,56 & 1847,59\\
        \bottomrule
        \addlinespace
        \multicolumn{7}{l}{\footnotesize Index: \textbf{B}erlin, \textbf{D}ubai, \textbf{S}urabaya}
    \end{tabular*}
\caption{Verschiebung der minimalen Punkte der Gesamtkosten}
\label{tab:EERreal_Verschiebung}
\end{table}
\end{document}

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.