0

I have created the table below. However, there are some formatting problems that I can't get fixed.

The table looks like this atm

In the first line, "content" and "This is a very" do not start at the same place.

The content of the first row in the last column runs across the row. Actually, the first line should simply adapt to the content i.e. extend itself

The text in the left column always starts below the text in the middle column. But they should start at the same height

The space between "Subheading 1" and the text below it is larger than between "This is a very ... long centered Subheading 2..." and the text below it.

\documentclass[9pt,twocolumn]{article}

\usepackage{tabularx}
\usepackage[format=plain, indention=1cm]{caption}
\usepackage{booktabs}
\usepackage{multirow}

\begin{document}

Here some text.

%.......................................Table..................................
\begin{table*}[!htb]
\captionsetup{size=footnotesize}
\caption{Heading}
\label{tab:Test1}
\setlength\tabcolsep{0pt}
 
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}p{2cm}p{5cm}p{5cm}p{5cm}}

\hline \toprule
Col 1 & \multicolumn{2}{c}{Col 2} & Col 3\\
\hline \midrule

\multirow{4}{*}{\parbox{1.5cm}{This is row 1}}
  & \multicolumn{2}{c}{Subheading 1}
  & \multirow{4}{*}{\parbox{4.5cm}{This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text \\ with a line break \\ and a second one}}\\
 
& \parbox[t][][t]{4.5cm}{content, content, content, content, content, content, content, content, content, content, content}
& \parbox[t][][t]{4.5cm}{content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content} & \\

  & \multicolumn{2}{c}{\parbox[t][][t]{10cm}{\centering This is a very very very very very long centered Subheading 2 over two lines}} & \\
 
& \multicolumn{2}{c}{\parbox[t][][t]{9.5cm}{This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text}} & \\

\hline

    \multirow{3}{*}{\parbox[t][][c]{1.5cm}{This is row 2}}
  & \multicolumn{2}{c}{\parbox[t][][c]{9.5cm}{This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text}}
 
    & \multirow{6}{*}{\parbox{4.5cm}{This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text}} \\
  & \multicolumn{2}{c}{\parbox[t][][t]{2cm}{\centering Subheading 3}} & \\
 
& \multicolumn{2}{c}{\parbox[t][][t]{9.5cm}{This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text}} & \\

\cline{1-3}

  \multirow{3}{*}{\parbox[t][][c]{1.5cm}{This is row 3}}
  & \multicolumn{2}{c}{\parbox[t][][c]{9.5cm}{fleet, older generation, preceding generation, previous generation}} & \\
  & \multicolumn{2}{c}{\parbox[t][][t]{2cm}{\centering Subheading 4}} & \\
& \multicolumn{2}{c}{\parbox[t][][t]{9.5cm}{This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text}} & \\

\bottomrule
\hline

\end{tabular*}
\end{table*}
%................
\end{document}

2 Answers 2

1

With complicated tables like this multirow isn't the proper solution. It is beyond its capacity, since it actually counts in lines, not in multi-line table rows.

The package tabularray is a much better fit for these kinds of tables. Here is a solution. It might need some fine tuning. For example some \parboxes might perhaps be eliminated.

I have left most of the \multirow parameters in braces, although they don't need that.

\documentclass[twocolumn]{article}

\usepackage[format=plain, indention=1cm]{caption}

\usepackage{tabularray}
\UseTblrLibrary{booktabs}

\begin{document}

Here some text.

%.......................................Table..................................
\begin{table*}[!htb]
\captionsetup{size=footnotesize}
\caption{Heading}
\label{tab:Test1}
 
\begin{tblr}{colspec={p{1.5cm} l l p{4.5cm}},colsep=2pt,width=\textwidth}
  \toprule
  Col 1 & \SetCell[c=2]{c}{Col 2} & & Col 3\\
  \midrule
  \SetCell[r=4]{l}This is row 1 & \SetCell[c=2]{c}Subheading 1 & &
      \SetCell[r=4]{l}\parbox{4.5cm}{This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text \\ with a line break \\ and a second one} \\
& \parbox[t][][t]{4.5cm}{content, content, content, content, content, content, content, content, content, content, content}
& \parbox[t][][t]{4.5cm}{content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content} & \\
  & \SetCell[c=2]{c}{\parbox[t][][t]{10cm}{\centering This is a very very very very very long centered Subheading 2 over two lines}} & & \\
& \SetCell[c=2]{c}{\parbox[t][][t]{9.5cm}{This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text}} & \\
\hline
    \SetCell[r=3]{l}This is row 2
  & \SetCell[c=2]{c}{\parbox[t][][c]{9.5cm}{This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text}}
  &
    & \SetCell[r=6]{l}{\parbox{4.5cm}{This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text}} \\
  & \SetCell[c=2]{c}{\parbox[t][][t]{2cm}{\centering Subheading 3}} & & \\
  & \SetCell[c=2]{c}{\parbox[t][][t]{9.5cm}{This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text}} & & \\
\cline{1-3}
  \SetCell[r=3]{l}This is row 3
  & \SetCell[c=2]{c}{\parbox[t][][c]{9.5cm}{fleet, older generation, preceding generation, previous generation}} & & \\
  & \SetCell[c=2]{c}{\parbox[t][][t]{2cm}{\centering Subheading 4}} & \\
& \SetCell[c=2]{c}{\parbox[t][][t]{9.5cm}{This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text}} & & \\

\bottomrule

\end{tblr}

\end{table*}
%................
\end{document}

enter image description here

1
  • Thanks a lot, I will try it.
    – xxxyyy
    May 16, 2022 at 7:01
1
  • If you are wiling to use tabularray package, than your table is not difficult to write.
  • Your table example is huge and can not be simple . To insert it in your document, you have the following possibilities:
    • Table write as long table spread over two pages. In this case instead tblr should be used longtblr table environment. However, now table had not to be incapsulated in table float and you need to change
    • Increase text area size by use of geometry package.
    • Use smaller font size, for example footnotesize and also reduce \baselineskip.
  • If real table is not so huge than aforementioned measure will not needed.

Solution with long table:

\documentclass[twocolumn]{article}
%---------------- Show page layout. Don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

%\usepackage[format=plain, indention=1cm]{caption}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, varwidth}

\begin{document}
\onecolumn
\begin{longtblr}[
caption = {Heading},
  label = {tab:Test1}
                ]{%
        colspec={@{} Q[l, 3em] X[j] X[j] X[j] @{}},
        row{1} = {font=\bfseries, c},
        hspan = minimal,
             }
    \toprule
Col 1   &   \SetCell[c=2]{c}   Col 2
            &   &   Col 3           \\
    \midrule
        & \SetCell[c=2]{c}  Subheading 1
            &   &                   \\
    \midrule[dashed]
\SetCell[r=2]{h}  This is row 1
        & content, content, content, content, content, content, content, content, content, content, content
            &   content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content
                &   \SetCell[r=2]{l}  {This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text\\
            with a line break           \\
            and a second one}           \\
        &   &   &                       \\
        & content, content, content, content, content, content, content, content, content, content, content
            &   content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content
                &                       \\
    \midrule    
    \pagebreak  % <--- insert manualy
        &   \SetCell[c=2]{c}  This is a very very very very very long centered Subheading 2 over two lines
            &   &                       \\
    \midrule[dashed]
\SetCell[r=2]{h}  This is row 2
        &   \SetCell[c=2]{j}  This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text
            &   &   \SetCell[r=3]{l}  This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text\\
        &   \SetCell[c=2]{c}  Subheading 3
            &   &                       \\
        &   \SetCell[c=2]{j}  This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text
            &   &                       \\
    \midrule
\SetCell[r=2]{h}  This is row 3
        &   \SetCell[c=2]{c}  fleet, older generation, preceding generation, previous generation
            &   &                       \\
        &   \SetCell[c=2]{c}  Subheading 4
            &   &                       \\
        &   \SetCell[c=2]{c}  This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text
            &   &                       \\
    \bottomrule
\end{longtblr}
\end{document}

enter image description here

(red lines show page layout).

In the following MWE, the last of the aforementioned options is taken into account. Table is inserted in table* float:

\documentclass[twocolumn]{article}

\usepackage[format=plain, indention=1cm]{caption}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, varwidth}

\begin{document}
    \begin{table*}[!htb]
\caption{Heading}
\label{tab:Test1}

\begin{tblr}{colspec={@{} Q[l, 3em] X[j] X[j] X[j] @{}},
             row{1} = {font=\bfseries, c}, 
             hspan = minimal, 
             rows = {font=\footnotesize\linespread{0.84}\selectfont}
             }
    \toprule
Col 1   &   \SetCell[c=2]{c}   Col 2   
            &   &   Col 3           \\
    \midrule
        & \SetCell[c=2]{c}  Subheading 1
            &   &                   \\          
\SetCell[r=2]{h}  This is row 1
        & content, content, content, content, content, content, content, content, content, content, content
            &   content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content
                &   \SetCell[r=2]{l}  {This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text\\
            with a line break\\
            and a second one}           \\
        &   &   &       \\
        & content, content, content, content, content, content, content, content, content, content, content 
            &   content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content, content
                &                       \\
    \midrule
        &   \SetCell[c=2]{c}  This is a very very very very very long centered Subheading 2 over two lines
            &   &                       \\
\SetCell[r=2]{h}  This is row 2 
        &   \SetCell[c=2]{j}  This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text
            &   &   \SetCell[r=3]{l}  This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text\\
        &   \SetCell[c=2]{c}  Subheading 3
            &   &                       \\
        &   \SetCell[c=2]{j}  This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text
            &   &                       \\
    \midrule
\SetCell[r=2]{h}  This is row 3
        &   \SetCell[c=2]{c}  fleet, older generation, preceding generation, previous generation
            &   &                       \\
        &   \SetCell[c=2]{c}  Subheading 4
            &   &                       \\
        &   \SetCell[c=2]{c}  This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text
            &   &                       \\
    \bottomrule
\end{tblr}
    \end{table*}
\end{document}

enter image description here

1
  • Thanks. Atm the table is short enough for one page.
    – xxxyyy
    May 16, 2022 at 7:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .