-1

I have an issue with utsing Multirow in LaTeX, namely there is a sort of row skip every time i use it. The Code is as follows:

\begin{table}[!ht]
    \centering
    \caption{Caption}
    \begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|}
        \hline & & K1 & K2 & S1 & S2 & C1 & C2 & C3 & C4 & C5 & C6 & C7 & C8 \\
        \hline \multirow{6}{*}{\rotatebox[origin=c]{270}{Year 1}} & KD &
        & & & & & & & & & & & & \\ \cline{2-14}
        & KD & & & & & & & & & & & & \\ \cline{2-14}
        & KD & & & & & & & & & & & & \\ \cline{2-14}
        & KD & & & & & & & & & & & & \\ \cline{2-14}
        & KD & & & & & & & & & & & & \\ \cline{2-14}
        & KD & & & & & & & & & & & & \\ 
        \hline \multirow{4}{*}{\rotatebox[origin=c]{270}{Year 2}} & KD & & & & & & & & & & & & & \\ \cline{2-14}
        & KD & & & & & & & & & & & & \\ \cline{2-14}
        & KD & & & & & & & & & & & & \\ \cline{2-14}
        & KD & & & & & & & & & & & & \\ \cline{2-14}
        \hline \multirow{4}{*}{\rotatebox[origin=c]{270}{Year 3}} & KD & & & & & & & & & & & & & \\ \cline{2-14}
        & KD & & & & & & & & & & & & \\ \cline{2-14}
        & KD & & & & & & & & & & & & \\ \cline{2-14}
        & KD & & & & & & & & & & & & \\ \hline
    \end{tabular}
    \label{tab:my_label}
\end{table}

with the following output: enter image description here

As you can see, every row where there is a multirow command there is a gap to the next.

Any help is much appreciated!

2

2 Answers 2

3

As I placed your code in a MWE, I got an error. Aligning all & of the second row to the first row showed there was an & too many in all \multirowlines.

This MWE doesn't show the gap after the use of \multirow and compiles in both LuaLaTeX and PDFLaTeX:

\documentclass[a4paper,11pt]{article}

\usepackage{caption}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{graphicx}

\begin{document}
    
\begin{table}[!ht]
    \centering
    \caption{Caption}
    \begin{tabular}{|*{14}{c|}}
        \hline
            &       & K1 & K2 & S1 & S2 & C1 & C2 & C3 & C4 & C5 & C6 & C7 & C8 \\ \hline
        \multirow{6}{*}{\rotatebox[origin=c]{270}{Year 1}} 
            & KD    &
                        &    &    &    &    &    &     &    &    &    &    &  \\ \cline{2-14}
        & KD & & & & & & & & & & & & \\ \cline{2-14}
        & KD & & & & & & & & & & & & \\ \cline{2-14}
        & KD & & & & & & & & & & & & \\ \cline{2-14}
        & KD & & & & & & & & & & & & \\ \cline{2-14}
        & KD & & & & & & & & & & & & \\ 
        \hline \multirow{4}{*}{\rotatebox[origin=c]{270}{Year 2}} & KD & & & & & & & & & & & &  \\ \cline{2-14}
        & KD & & & & & & & & & & & & \\ \cline{2-14}
        & KD & & & & & & & & & & & & \\ \cline{2-14}
        & KD & & & & & & & & & & & & \\ \cline{2-14}
        \hline \multirow{4}{*}{\rotatebox[origin=c]{270}{Year 3}} & KD & & & & & & & & & & & &  \\ \cline{2-14}
        & KD & & & & & & & & & & & & \\ \cline{2-14}
        & KD & & & & & & & & & & & & \\ \cline{2-14}
        & KD & & & & & & & & & & & & \\ \hline
    \end{tabular}
    \label{tab:my_label}
\end{table}

\end{document}

enter image description here

2

You should care about that each row in table has $n-1$ ampersands, where $n$ is number of defined columns in table. In your case you define 14 columns, so each row should have 13 ampersands (&), but in rows, where you start multi row cells, you have on more and consequently reported problem.

Off topic: For your table I would use tblr of tabularray package and for rotated cells rotating and makecell packages. Using them table code is a bit shorter and cells' contents is better vertically spaced:

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

\usepackage[skip=1ex, font=small,labelfont=bf]{caption}
\usepackage{rotating}
\usepackage{makecell}
\renewcommand\theadfont{}
\usepackage{tabularray}

\begin{document}
    \begin{table}[!ht]
    \caption{Caption}
    \label{tab:my_label}
\settowidth\rotheadsize{Year 3}
\begin{tblr}{hlines, vlines, 
             colspec = { *{14}{X[c]} },
             }
    &   & K1 & K2 & S1 & S2 & C1 & C2 & C3 & C4 & C5 & C6 & C7 & C8 \\ 
\SetCell[r=6]{cmd=\rothead} Year 1  
        & KD & & & & & & & & & & & & \\  
        & KD & & & & & & & & & & & & \\  
        & KD & & & & & & & & & & & & \\  
        & KD & & & & & & & & & & & & \\  
        & KD & & & & & & & & & & & & \\  
        & KD & & & & & & & & & & & & \\
\SetCell[r=4]{cmd=\rothead} Year 2
        & KD & & & & & & & & & & & & \\
        & KD & & & & & & & & & & & & \\
        & KD & & & & & & & & & & & & \\
        & KD & & & & & & & & & & & & \\
\SetCell[r=4]{cmd=\rothead} Year 3
        & KD & & & & & & & & & & & & \\
        & KD & & & & & & & & & & & & \\
        & KD & & & & & & & & & & & & \\
        & KD & & & & & & & & & & & & \\
\end{tblr}
    \end{table}
\end{document}

enter image description here

(red lines indicate document page layout)

You must log in to answer this question.

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