Use multiple rows along with vertical centering

I have this code...

\documentclass[a4paper]{article}

\usepackage[margin=1.25in]{geometry}
\usepackage{float}
\usepackage{tabularx}
\renewcommand{\arraystretch}{1.5}
\usepackage{multirow}

\title{}
\author{}
\date{}

\begin{document}
\begin{table}[H]
\centering
\begin{tabularx}{\textwidth}{|p{2cm}|X|m{3cm}|}
\hline
\textbf{Participant} & \textbf{Answer} & \textbf{Themes} \\
\hline\hline
Short text here & I think I think I think I think I think I think I think I think I think I think I think I think I think I think I think I think I think I think I think I think I think I think I think I think I think I think I think I think & \multirow{5}{*}{Something here} \\
\hline
Short text here & test & \\
\hline
Short text here & test & \\
\hline
Short text here & test & \\
\hline
Short text here & test & \\
\hline
\end{tabularx}
\end{table}
\end{document}


How can I make themes column take up whole table column without the hline. I still want hline for the other columns. Also vertical center it.

Welcome to TeX SX! You have to use the \cline{1-2}command to ensure the horizontal line stop at the end of the second column. You also have to know that the first argument of the \multirow command denotes the number of rows that will replaced by its contents if the rows are single-lined. In other cases, you have to count the number of lines in the adjacent columns (12 in the present case). Furthermore, changing the value af \arraystretch makes it more complex, and the best is to estimate the number of equivalent rows and proceed by trial and error – decimal numbers are allowed to fine-tune the position of the centents. Last point: I replaced the {*} argument with {=} since the third column has a fixed width.

\documentclass[a4paper]{article}

\usepackage[margin=1.25in]{geometry}
\usepackage{float}
\usepackage{tabularx}
\renewcommand{\arraystretch}{1.5}
\usepackage{multirow}

\title{}
\author{}
\date{}

\begin{document}

\begin{table}[H]
\centering
\begin{tabularx}{\textwidth}{|p{2cm}|X|m{2.5cm}|}
\hline
\textbf{Participant} & \textbf{Answer} & \textbf{Themes} \\
\hline\hline
Short text here & I think I think I think I think I think I think I think I think I think I think I think I think I think I think I think I think I think I think I think I think I think I think I think I think I think I think I think I think & \multirow{9.5}{=}{Something here} \\
\cline{1-2}
Short text here & test & \\
\cline{1-2}
Short text here & test & \\
\cline{1-2}
Short text here & test & \\
\cline{1-2}
Short text here & test & \\
\hline
\end{tabularx}
\end{table}

\end{document}


• Thanks! Do you know that the w column is used for and what package provides it like in tex.stackexchange.com/a/522048/231495? Never heard of it. – ketena3886 Jan 1 at 16:37
• Also is there no automatic solution? – ketena3886 Jan 1 at 16:41
• wand W are new column specifier for fixed width column, to which you can append a horizontal position specifier, e.g. wc{2cm} is for a horizontally centred column 2cm wide. It comes with recent versions of array. – Bernard Jan 1 at 16:42
• I'm afraid not, if you have multilined cells in other columns. It is not very long to proceed, though. – Bernard Jan 1 at 16:44

The nicematrix package by itself provides all the necessary elements for this table. Moreover, the code is clean and simple.

The main command used, \Block, allows the identification and format of the multi row/column cells.

(Important: The command \Block{} creates a monoblock cell that allows the use of \\ inside, thus cutting the line where you want it instead of relying on the width of the column in left-align text.)

Notice that all cell are (nicely) vertically centered without the need of any manually adjustable parameters, and using natural width of the cell.

\documentclass[a4paper]{article}

\usepackage[margin=1.25in]{geometry}
\usepackage{float}
%\usepackage{tabularx}
%\renewcommand{\arraystretch}{1.5}
%\usepackage{multirow}

\usepackage{nicematrix}

\title{}
\author{}
\date{}

\begin{document}

\begin{table}[H]
\centering
%\begin{NiceTabular}{>{\raggedright\arraybackslash}p{2cm} l wc{3cm}}[%  use this to retain your original width values
\begin{NiceTabular}{clc}[%
cell-space-top-limit = 5pt,
cell-space-bottom-limit = 5pt,
hvlines]
\hline
\textbf{Participant} & \Block[c]{}{\textbf{Answer}} & \textbf{Themes} \\
\hline
Short text here &\Block{}{I think I think I think I think I think \\I think I think I think I think\\ I think I think I think I think I think I think I think \\I think I think I think I think I think I think I think\\ I  think \\I think I think I think I think} & \Block{5-1}{Something here} \\
Short text here & test & \\
Short text here & test & \\
Short text here & test & \\
Short text here & test & \\
\end{NiceTabular}
\end{table}

\end{document