0

I built a multipage table containing multirows using the ltablex and multirow packages. My question is, how can I now prevent Latex from breaking such a multirow?

\begin{center}
    \begin{footnotesize}
        \renewcommand{\arraystretch}{1.25}\aboverulesep = 0mm \belowrulesep = 0mm
        \captionsetup{type=table}
        \begin{tabularx}{1\textwidth}{|p{0.1\textwidth}|p{0.1\textwidth}|p{0.1\textwidth}|X|p{0.1\textwidth}|}
            \cline{1-5}
            \textbf{Direction} & \textbf{Signal Name} & \textbf{Symbol} & \textbf{Description} & \textbf{Type}  \\\cline{1-5}
            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}
        \end{tabularx}
        %\caption{Table Cap}
\end{footnotesize}
\end{center}
  • \ltablex change X column features. To restore it back, you need to add \keepXColumns. Please extend your code snippet to cmall but complete document, which we can compile as it is. – Zarko Sep 11 at 9:19
1

I have now updated with an MWE to solve the missing line on page 2, and I assumed that you do not want repeating header.

Since you have not provided a working MWE, it is difficult to be more specific, so I give you some possible solutions.

Remember that a multirow is only an overlay over the cells underneath. Therefore, for longtable, which is use behind ltablex, each row underneath a multirow is a possible breaking point. Page 9 in the longtable manual describes different commands you may use either to force a page break before the multirow, or to avoid a page break between the said rows.

Remember that you also can use the LaTeX command \enlargethispage{<val>} to increase or decrease available space on a given page. For example:

\enlargethispage{\baselineskip}

may give room for an additional row. A negative value:

\enlargethispage{-\baselineskip}

will decrease the available space, forcing a earlier page break.

To have rules at the top of the next page, you put the rule command in the table header:

\cline{1-5}\endfirsthead\cline{1-5}

Instead of \cline{1-5} you may use a simple \hline.

enter image description here

\documentclass[12pt]{article}
\usepackage[a4paper,
            vmargin=0.7in, hmargin=0.7in%
            ]{geometry}

\usepackage{array, hhline, ltablex, tabularx, multirow, caption}

\begin{document}

\begin{center}
    \begin{footnotesize}
        \renewcommand{\arraystretch}{1.25}%\aboverulesep = 0mm \belowrulesep = 0mm
        \captionsetup{type=table}
        \begin{tabularx}{1\textwidth}{|p{0.1\textwidth}|p{0.1\textwidth}|p{0.1\textwidth}|X|p{0.1\textwidth}|}

\caption{Table Cap}\\

\endfirsthead
\cline{1-5} % Or \hline
\endhead
\cline{1-5} % Or \hline

\textbf{Direction} & \textbf{Signal Name} & \textbf{Symbol} & \textbf{Description} & \textbf{Type}  \\\cline{1-5}
          in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}
          in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}
          in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}
          in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}
          in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}
          in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}
          in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}
          in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}
          in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

            in  & \multirow[t]{2}{\hsize}{ready signal} & ready-v1  & Some description & 1 \\ \cline{1-1} \cline{3-5}
            out & & ready-v2 & Some description & 1  \\\cline{1-5}

        \end{tabularx}
\end{footnotesize}
\end{center}

\end{document}
  • Okay, I did it using pagebreak, altough I was hoping to find a more "Word"ish approach. Tables are still a weakness of Latex in my opinion. You might have an idea how I now can add the missing \cline on the new page? – po.pe Sep 11 at 9:26
  • @Humpawumpa You put the cline in the longtable header, before the table body, try to add the command \cline{1-5}\endhead and \cline{1-5}\endhead. But since you spanne all five columns, why do you not use \hline instead? The documentation for ltablex is very rudimentary, so you have to look at longtable's manual. As Zako suggests, I too recommend the use of xltabular instead. – Sveinung Sep 11 at 11:02
2

From your code snippet is not clear, why you need ltablex package. If you really need long table with tabularx features, then I suggest you rather use xltabular package (which is combination longtable and tabularx package).

In case the you persist to use ltablex then, in case that you like to have X column (in any tabularx table) with the same features as in standard tabularx, you need to add \keepXColumns in the document preamble.

In your case, I would redesign your table as follows:

\documentclass{article}
\usepackage{makecell, multirow, tabularx}
\renewcommand\theadfont{\small\bfseries}
\renewcommand\theadgape{}
\setcellgapes{3pt}

\begin{document}
    \begin{table}
\makegapedcells
    \caption{Table Cap}\label{tab:mytable}
\begin{tabularx}{\linewidth}{|c|p{0.1\linewidth}| l | X | c|}
            \cline{1-5}
\thead[b]{Direction} 
    &   \thead[b]{Signal\\ Name} 
                    &   \thead[b]{Symbol} 
                                        &   \thead[b]{Description} 
                                                            & \thead[b]{Type}           \\  \cline{1-5}
in  & \multirow{2.4}{=}{ready signal} 
                    & ready-v1          & Some description  & 1         \\ \cline{1-1}      \cline{3-5}
out &               & ready-v2          & Some description  & 1         \\  \cline{1-5}
in  & \multirow{2.4}{=}{ready signal}
                    & ready-v1          & Some description  & 1         \\ \cline{1-1}      \cline{3-5}
out &               & ready-v2          & Some description  & 1         \\  \cline{1-5}
in  & \multirow{2.4}{=}{ready signal}
                    & ready-v1          & Some description  & 1         \\ \cline{1-1}      \cline{3-5}
out &               & ready-v2          & Some description  & 1         \\  \cline{1-5}
in  & \multirow{2.4}{=}{ready signal}
                    & ready-v1          & Some description  & 1         \\ \cline{1-1}      \cline{3-5}
out &               & ready-v2          & Some description  & 1         \\  \cline{1-5}
        \end{tabularx}
\end{table}
\end{document}

which gives the following result:

enter image description here

In above table design I anticipated that in all columns except of second column, where you have multirows' cells and fourth (with X type) column you will have only short one line text.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.