0

I want to have a table that looks like this but without the horizontal lines above and below MULTI: Table

My code is the following:

\documentclass{article}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{multirow}

\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}

\begin{document}


\begin{table}
\centering
\caption{Table}
\label{tab:table}
\begin{tabular}{M{0.1\textwidth} M{0.2\textwidth} M{0.2\textwidth} M{0.23\textwidth} M{0.12\textwidth}}
TEXT & TEXT & TEXT & TEXT & TEXT \\ \specialrule{.2em}{.1em}{.1em} 
TEXT & \multirow{3}{*}[-2pt]{MULTI} & TEXT & TEXT & TEXT \\ \hline
TEXT &  & TEXT & TEXT & TEXT \\ \hline
TEXT &  & TEXT & TEXT & TEXT \\  \specialrule{.1em}{.05em}{.05em}
\end{tabular}

\end{table}

\end{document}

I checked this but I cannot make it work.

3
  • Is this the output you want to achieve?
    – leandriis
    Mar 10 '20 at 18:33
  • yes! @leandriis I was wondering if that could be done if it doesn't look too weird Mar 11 '20 at 7:24
  • This can be done using \cline{1-1}\cline{3-5} instead of the corresponding \hline commands. To be honest though, I wouldn't recommend that kind of layout. Depending on the actual conents of the table, I would switch the first and second column and place the "multi" text in the upper of the three lines, leaving the following two in this column empty. I also wouldn't use \hlines at all.
    – leandriis
    Mar 11 '20 at 18:38
1

Just remove \hline that you have in your MWE. Hope it works!

\documentclass{article}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{multirow}

\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}

\begin{document}


\begin{table}
\centering
\caption{Table}
\label{tab:table}
\begin{tabular}{M{0.1\textwidth} M{0.2\textwidth} M{0.2\textwidth} M{0.23\textwidth} M{0.12\textwidth}}
TEXT & TEXT & TEXT & TEXT & TEXT \\ \specialrule{.2em}{.1em}{.1em} 
TEXT & \multirow{3}{*}[-2pt]{MULTI} & TEXT & TEXT & TEXT \\
TEXT &  & TEXT & TEXT & TEXT \\
TEXT &  & TEXT & TEXT & TEXT \\  \specialrule{.1em}{.05em}{.05em}
\end{tabular}

\end{table}

\end{document}

Example

0

As mentioned @Sebastián V. Romero in his answer, if you not like to have horizontal lines (in your case they are drawn by by command \hline), remove those commands from your table body code.

Beside this your MWE has two issues:

  • table is wider than text area (see first table)
  • that \multirow cell will not become wider than prescribed width of the column, in which it is, use intesd * option=, which overtake column width setting.
\documentclass{article}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\usepackage{array, booktabs, multirow}
\usepackage{caption}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}

\begin{document}
    \begin{table}[ht]
    \centering
\caption{Table (1)}
\label{tab:table}
\begin{tabular}{*{5}{M{0.2\textwidth}}}
    \toprule %?
TEXT & TEXT                     & TEXT & TEXT & TEXT \\ 
    \midrule
TEXT & \multirow{3}{=}{MULTI}   & TEXT & TEXT & TEXT \\
TEXT &                          & TEXT & TEXT & TEXT \\
TEXT &                          & TEXT & TEXT & TEXT \\  
    \bottomrule
\end{tabular}
    \end{table}

    \begin{table}[ht]
    \centering
\caption{Table (2)}
\label{tab:table}
\begin{tabular}{ *{5}{M{\dimexpr0.2\textwidth-2\tabcolsep}} }
    \toprule %?
TEXT & TEXT                     & TEXT & TEXT & TEXT \\
    \midrule
TEXT & \multirow{3}{=}{MULTI}   & TEXT & TEXT & TEXT \\
TEXT &                          & TEXT & TEXT & TEXT \\
TEXT &                          & TEXT & TEXT & TEXT \\
    \bottomrule
\end{tabular}
    \end{table}
\end{document}

enter image description here

(red lines indicate page layout)

Addedndum (edited): In the case, that content of the multi row cell (MULTI) should be horizontally centered, you need to change \multirowsetup:

\renewcommand\multirowsetup{\centering}  

i.e.: complete MWE for the second table is than:

\documentclass{article}
\usepackage{array, booktabs, multirow}
\usepackage{caption}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}

\begin{document}

    \begin{table}[ht]
    \centering
\caption{Table (2)}
\label{tab:table}
\renewcommand\multirowsetup{\centering}  % <---
\begin{tabular}{ *{5}{M{\dimexpr0.2\textwidth-2\tabcolsep}} }
    \toprule %?
TEXT & TEXT & TEXT & TEXT & TEXT \\
    \midrule
TEXT & \multirow{3}{=}{MULTI}    
            & TEXT & TEXT & TEXT \\
TEXT &      & TEXT & TEXT & TEXT \\
TEXT &      & TEXT & TEXT & TEXT \\
    \bottomrule
\end{tabular}
    \end{table}
\end{document}

enter image description here

4
  • thanks for this! but why isn't MULTI allinged with upper TEXT? Mar 11 '20 at 7:25
  • @GoldenFlecha, because you show us, that should be in the middle of the second column and not mentioned demand, that you like to have on the top. See addendum to answer.
    – Zarko
    Mar 11 '20 at 7:55
  • @Zarko: I guess op refers to "multi" not being horizontally aligned with "text" in the column header of the second column.
    – leandriis
    Mar 11 '20 at 8:29
  • @leandriis, you are right! It was to early for me :-). I will correct asap!
    – Zarko
    Mar 11 '20 at 10:05

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.