6

I have a table with two thick lines (one horizontal and one vertical) and with multirow and multicolumn cells. Now one of the clines is not connecting where I want it to.

This is what I have to create the other line types. (blatently stolen from this site):

\makeatletter
\newcommand{\thickhline}{%
    \noalign {\ifnum 0=`}\fi \hrule height 1pt
    \futurelet \reserved@a \@xhline
}
\newcolumntype{"}{@{\hskip\tabcolsep\vrule width 1pt\hskip\tabcolsep}}
\makeatother

and the table itself:

\begin{table}[h]
\centering
\begin{tabular}{|c|>{\centering\arraybackslash}p{1cm}">{\centering\arraybackslash}p{1cm}|>{\centering\arraybackslash}p{1cm}|>{\centering\arraybackslash}p{1cm}|}
\hline
\multicolumn{2}{|c"}{\multirow{2}{*}{}} & \multicolumn{3}{c|}{Retort Diameter (mm)}             \\ \cline{3-5} 
\multicolumn{2}{|c"}{}                              & 750          & 1000           & 1200      \\ \thickhline
\multirow{3}{*}{Gas Flow (SLM)}         & 25        & 5.7          & 3.2            & 2.2       \\ \cline{2-5} 
                                        & 50        & 11           & 6.4            & 4.4       \\ \cline{2-5} 
                                        & 75        & 17           & 9.6            & 6.6       \\ \hline
\end{tabular}
\caption{Approximate Peclet values}
\label{tb:Peclet}
\end{table}

The \cline{3-5} does not fully connect to the thick vertical line. Is there a way to fix this.

enter image description here

On a side note: Is there a neater way to center text in a column with defined with?

2
  • \newcolumntype{"}{!{\vrule width 1pt}} should work.
    – leandriis
    Dec 30, 2020 at 11:26
  • It does, thank you
    – Simon
    Dec 30, 2020 at 11:29

3 Answers 3

5

The array package offers !{decl.} with <decl.> being used instead of the vertical line. To get a 1pt wide vertical line, you can use \vrule width 1pt. You can also declare a new column type based on this, using something like \newcolumntype{V}{!{\vrule width 1pt}}. (I used V instead of your original " here to avoid possible conflicts with the babel package since " is a shorthand in some languages.)

Instead of your definition of the \thickrule command, you could also use \Xhline from the makecell package. It accepts a width as its argument: \Xhline{1pt}

If you plan on using the thicker vertical and horizontal lines multiple times throughout your document, you might be interested in defining their widths in the pramble as I did in the following example.

In the following MWE, I also included a second version of your table that makes use of the booktabs package for a layout without vertical and wih less horizontal lines. There I also added the siunitx pacage in order to typeset units:

enter image description here

\documentclass{article}
\usepackage{array}
\usepackage{multirow}
\usepackage{makecell}

\newlength{\mytablinewidth}
\setlength{\mytablinewidth}{1pt}
\newcommand{\myhline}{\Xhline{\mytablinewidth}}
\newcolumntype{V}{!{\vrule width \mytablinewidth}}

\usepackage{booktabs}
\usepackage{siunitx}


\begin{document}

\begin{table}[h]
\centering
\begin{tabular}{|c|>{\centering\arraybackslash}p{1cm}V>{\centering\arraybackslash}p{1cm}|>{\centering\arraybackslash}p{1cm}|>{\centering\arraybackslash}p{1cm}|}
\hline
\multicolumn{2}{|cV}{\multirow{2}{*}{}} & \multicolumn{3}{c|}{Retort Diameter (mm)}             \\ \cline{3-5} 
\multicolumn{2}{|cV}{}                              & 750          & 1000           & 1200      \\ \myhline
\multirow{3}{*}{Gas Flow (SLM)}         & 25        & 5.7          & 3.2            & 2.2       \\ \cline{2-5} 
                                        & 50        & 11           & 6.4            & 4.4       \\ \cline{2-5} 
                                        & 75        & 17           & 9.6            & 6.6       \\ \hline
\end{tabular}
\caption{Approximate Peclet values}
\label{tb:Peclet}
\end{table}


\begin{table}[h]
\centering
\begin{tabular}{ccccc}
\toprule
                                                 &          & \multicolumn{3}{c}{Retort Diameter}   \\
                                                 &          & \multicolumn{3}{c}{(\si{\mm})}        \\
\cmidrule{3-5} 
                                                 &          & 750          & 1000           & 1200  \\ 
\midrule
\multirow{3}{*}{\makecell[cl]{Gas Flow \\ (SLM)}}& 25       & 5.7          & 3.2            & 2.2   \\  
                                                 & 50       & 11           & 6.4            & 4.4   \\
                                                 & 75       & 17           & 9.6            & 6.6   \\ 
\bottomrule
\end{tabular}
\caption{Approximate Peclet values}
\label{tb:Peclet2}
\end{table}


\end{document}
2

In addition to the ! trick already mentioned by leandriis, you can use the w column type that's much lighter codewise.

Also you could remove the empty rectangle at the upper left. But there are better ways to typeset the table, in my opinion, and I present one below.

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

\makeatletter
\newcommand{\thickhline}{%
    \noalign {\ifnum 0=`}\fi \hrule height 1pt
    \futurelet \reserved@a \@xhline
}
\newcolumntype{"}{!{\vline width 1pt}}
\makeatother

\newcommand{\smashedheader}[2][c]{%
  \smash{\begin{tabular}[t]{@{}#1@{}}#2\end{tabular}}%
}

\begin{document}

\begin{tabular}{| c | w{c}{1cm} " w{c}{1cm} | w{c}{1cm} | w{c}{1cm} |}
\cline{3-5}
\multicolumn{2}{c"}{\multirow{2}{*}{}} & \multicolumn{3}{c|}{Retort Diameter (mm)} \\
\cline{3-5} 
\multicolumn{2}{c"}{}                               & 750          & 1000           & 1200 \\
\thickhline
\multirow{3}{*}{Gas Flow (SLM)}         & 25        & 5.7          & 3.2            & 2.2  \\
\cline{2-5} 
                                        & 50        & 11           & 6.4            & 4.4  \\
\cline{2-5} 
                                        & 75        & 17           & 9.6            & 6.6  \\
\hline
\end{tabular}

\bigskip

\begin{tabular}{ @{} c w{c}{1.5cm} w{c}{1.5cm} w{c}{1.5cm} @{} }
\toprule
\smashedheader{Gas Flow \\ (SLM)} & \multicolumn{3}{c@{}}{Retort Diameter (mm)} \\
\cmidrule(l){2-4} 
          & 750          & 1000           & 1200 \\
\midrule
25        & 5.7          & 3.2            & 2.2  \\
50        & 11           & 6.4            & 4.4  \\
75        & 17           & 9.6            & 6.6  \\
\bottomrule
\end{tabular}

\end{document}

enter image description here

1

Here is a way to do that tabular with {NiceTabular} of nicematrix.

\documentclass{article}

\usepackage{nicematrix}
\usepackage{tikz}

\begin{document}

\begin{table}[h]
\centering
\renewcommand{\arraystretch}{1.2}
\begin{NiceTabular}{ccwc{1cm}wc{1cm}wc{1cm}}[hvlines]
\Block{2-2}{}               &     & \Block{1-3}{Retort Diameter (mm)} \\ 
                            &     & 750 & 1000 & 1200 \\ 
\Block{3-1}{Gas Flow (SLM)} & 25  & 5.7  & 3.2 & 2.2  \\ 
                            & 50  & 11   & 6.4 & 4.4  \\ 
                            & 75  & 17   & 9.6 & 6.6  
\CodeAfter
\tikz \draw [line width = 1pt ] (3-|1) -- (3-|6) (1-|3) -- (6-|3) ;
\end{NiceTabular}
\caption{Approximate Peclet values}
\label{tb:Peclet}
\end{table}
    

\begin{table}[h]
\centering
\renewcommand{\arraystretch}{1.2}
\begin{NiceTabular}{ccwc{1cm}wc{1cm}wc{1cm}}[hvlines-except-corners=NW]
                            &     & \Block{1-3}{Retort Diameter (mm)} \\ 
                            &     & 750 & 1000 & 1200 \\ 
\Block{3-1}{Gas Flow (SLM)} & 25  & 5.7  & 3.2 & 2.2  \\ 
                            & 50  & 11   & 6.4 & 4.4  \\ 
                            & 75  & 17   & 9.6 & 6.6  
\CodeAfter
\tikz \draw [line width = 1pt ] (3-|1) -- (3-|6) (1-|3) -- (6-|3) ;
\end{NiceTabular}
\caption{Approximate Peclet values}
\label{tb:Peclet}
\end{table}

\end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes).

Output of the above code

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.