1

I have the following table and I am trying to give a specific length for column 1, 2 and 3 which stays fixed. I found a trick by adding an "invisible" row at the bottom (& \multicolumn{1}{p{3.5cm}}{} & \multicolumn{1}{p{3.5cm}}{}\) but it doesn't seem a nice solution since I get obviously an empty row before my explanation of the table. Without that invisible row, although I put the sizes at the beginning of the table (\begin{tabular}{m{8.2cm} m{3.5} m{3.5cm}}), the table just adapt to the content and it is not what I want.

Do you have any solution? It is the first time I do some table like that in Latex therefore I think the code is highly "inefficient and weird".

Thank you!

\documentclass[11pt,a4paper]{article}
\renewcommand{\baselinestretch}{1.5}
\renewcommand\thesection{\arabic{section}}
\renewcommand\thesubsection{\thesection.\arabic{subsection}}
\usepackage{float}
\usepackage{array}
\usepackage{multirow}
\usepackage{arydshln}
\usepackage{geometry}
\usepackage[font=small, justification=justified, format=plain]{caption}


\begin{document}

\begin{table}[H]
    \centering
    \caption{Title of the table} 
    \label{my_label}
    \begin{tabular}{m{8.2cm} m{3.5} m{3.5cm}}
        \hline
        \multirow{2}{*}{Bulletpoint Title} & \multicolumn{2}{c}{Merged columns 2-3}
        \\
        & \multicolumn{1}{c}{column 2} & \multicolumn{1}{c}{column 3} \\
        \hline
        \begin{itemize}
            \item Bulletpoint 1
            \item Bulletpoint 2
        \end{itemize}
        & \multicolumn{1}{c}{abc}    & \multicolumn{1}{c}{abc}\\
        \hdashline
        \begin{itemize}
            \item Bulletpoint 3
            \item Bulletpoint 4
        \end{itemize}
        & \multicolumn{1}{c}{xyz}    & \multicolumn{1}{c}{xyz} \\
        \hline
        Total & \multicolumn{1}{c}{Total c1} & \multicolumn{1}{c}{Total c2}\\
        \hline
        & \multicolumn{1}{p{3.5cm}}{} & \multicolumn{1}{p{3.5cm}}{}\\
    \end{tabular}
    \caption*{\footnotesize This table shows *COMMENT*}
\end{table}

\end{document}

enter image description here

  • You are right, I added the preamble. I am sorry about that. – mrchrister Apr 09 '19 at 06:09
  • Commenting out the "tricky" row, I get this, isn't it what you want? –  Apr 09 '19 at 06:11
  • Unfortunately not. When you comment out the "tricky" row, columns 2 and 3 adapt their size to the content of the cell and I don't want that. I want to be able to define the size of the cell (in centimeters). In my original table I have some formulas of different lengths which are longer than "abc". I want columns 2 and 3 to have the same width despite the contents have different lengths. – mrchrister Apr 09 '19 at 06:21
  • 1
    You have m{3.5} m{3.5cm}. Without testing I think changing to m{3.5cm} m{3.5cm} may solve the problem. –  Apr 09 '19 at 06:23

1 Answers1

1
\documentclass[11pt,a4paper]{article}
\renewcommand{\baselinestretch}{1.5}
\renewcommand\thesection{\arabic{section}}
\renewcommand\thesubsection{\thesection.\arabic{subsection}}
%\usepackage{float}
\usepackage{array, multirow}
\usepackage{arydshln}
\usepackage{geometry}
\usepackage[font=small, justification=justified, format=plain]{caption}
\usepackage{enumitem}  % new


\begin{document}

\begin{table}[htb]
\setlist[itemize]{leftmargin=*,  % new
                  after=\vspace{-0.6\baselineskip}
                  }
    \centering
    \caption{Title of the table}
    \label{my_label}
    \begin{tabular}{m{8.2cm} *{2}{>{\centering\arraybackslash}m{3.5cm}}}
        \hline
\multirow{2}{*}{Bulletpoint Title}
        & \multicolumn{2}{c}{Merged columns 2-3}    \\
        &   column 2    &   column 3                \\
        \hline
\begin{itemize}
    \item Bulletpoint 1
    \item Bulletpoint 2
\end{itemize}
        &   abc         &   abc                     \\
        \hdashline
\begin{itemize}
    \item Bulletpoint 3
    \item Bulletpoint 4
\end{itemize}
        &   xyz         &   xyz                     \\
        \hline
Total   &   Total c1    &   Total c2                \\
        \hline
    \end{tabular}
    \caption*{\footnotesize This table shows *COMMENT*}
\end{table}

\end{document}

gives:

enter image description here

in above MWE i removed all unnecessary \multicolumn{1}{c}{...}'s and empty rows, redefined column types that column contents are centered and for lists use the enumitem package.

Zarko
  • 296,517