79

Is it possible to create a table like this one?

enter image description here

The usual structure of tables I use looks like this:

\begin{table}[H]
    \begin{adjustbox}{width=\textwidth,center}
    % \begin{adjustbox}{center}
        \begin{tabular}{lll}
            \hline
            \multicolumn{1}{l}{\head{XXX}} & \multicolumn{1}{l}{\head{XXX}} & \multicolumn{1}{l}{\head{XXX}} \\
            \hline
            \ttfamily xxx & \ttfamily xxx & \ttfamily xxx \\
            \hline
        \end{tabular}
    \end{adjustbox}
    \vspace{ - 05 mm}
    \caption{xxx}
    \label{tab:xxx}
\end{table}
0

3 Answers 3

100

You can use multirow If you are trying to align four rows of a particular column, put

\multirow{4}{*}{XXX}

in the first row and leave three subsequent rows below empty like

\multirow{4}{*}{XXX} &
                     &
                     &
                     &

Then the contents are vertically aligned.

\documentclass[a4paper,12pt]{article}
\usepackage[margin=2cm]{geometry}
\usepackage{adjustbox}
\usepackage{multirow}

\begin{document}
\begin{table}[h]
\centering
%     \begin{adjustbox}{width=\textwidth,center}
    % \begin{adjustbox}{center}
        \begin{tabular}{lll}
            \hline
            \multirow{4}{*}{XXX} & \multicolumn{1}{l}{XXX} & \multicolumn{1}{l}{XXX} \\\cline{2-3}
                                 & \multicolumn{1}{l}{XXX} & \multicolumn{1}{l}{XXX} \\\cline{2-3}
                                 & \multicolumn{1}{l}{XXX} & \multicolumn{1}{l}{XXX} \\\cline{2-3}
                                 & \multicolumn{1}{l}{XXX} & \multicolumn{1}{l}{XXX} \\\hline
            \ttfamily xxx & \ttfamily xxx & \ttfamily xxx \\                \hline
        \end{tabular}
%     \end{adjustbox}
%     \vspace{ - 05 mm}
    \caption{xxx}
    \label{tab:xxx}
\end{table}


\end{document}

enter image description here

3
  • How can I do it with the TexStudio tables wizard?
    – skan
    Dec 1, 2016 at 17:26
  • 4
    what exactly does the asterisk do there?
    – eli44
    Jan 7, 2022 at 10:50
  • As far as I can tell, the width of the column is specified at where the asterisk is put and the asterisk itself is used if the width should be automatically inherited from the data in the columns (tex.stackexchange.com/questions/73283/how-to-use-multirow) Oct 21, 2022 at 11:27
6

You can use \multirow to do this!

\multirow{<number of rows>}{<width>}{<text>}

Make sure to include \usepackage{multirow} at the top.

0
5

Here is a stripped down version of what you want (I had to get rid of a few things because I didn't know which packages you had loaded and the code wouldn't compile without them):

\begin{table}[h]
        \begin{tabular}{lll}
            \hline
            \multicolumn{1}{l}{XXX} & \multicolumn{1}{l}{XXX} & \multicolumn{1}{l}{XXX} \\\cline{2-3}
             \ttfamily xxx & \ttfamily xxx & \ttfamily xxx \\
            \hline
        \end{tabular}
    \vspace{ -05mm}
    \caption{xxx}
    \label{tab:xxx}
\end{table}

In summary, what you need is the command \cline{2-3} at the end of a line to indicate where the line should start and finish (in this case it starts at column 2 and finishes at column 3).

2
  • OK. I think I got it. But how to align the left-hand side element to the centre?
    – eualin
    Sep 17, 2012 at 20:31
  • Align it vertically to the centre you mean? This construct doesn't give a way to do that. I think you can tweak it to give the result you want, but in the example you gave this doesn't even make sense. I suggest you give a better example in your question (more rows so that alignment is an issue), but to be honest, I am pretty sure there is a way to actually merge the cells, instead of just dealing with the lines, I just don't know it.
    – Vivi
    Sep 17, 2012 at 20:50

You must log in to answer this question.

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