0

I like the hybrid of longtable and tabulary environments, that was devised on this site, so much, that I came to use it exclusively.

References:

And also

I wish it was released officially as a package. I should also mention perhaps, that I am not familiar with TeX intrinsics, and so have no clue how the code below works, I simply copy-pasted it together.

Now to the problems. I need to use multirow. It recommends to prevent page breaks of the multirow rows with \\*. However, it still breaks after first row (and \nopagebreak doesn't help either).

   \documentclass[papersize,paper=a4]{scrreprt}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{tabulary}
%after gathering tthe code together
\makeatletter
\newcommand*\TY@cap@gobble[2][]{\\}% from ltxtable (adjusted)
\def\ltabulary{%
    \def\caption{% from ltxtable (adjusted)
        \@ifstar\TY@cap@gobble\TY@cap@gobble}
    \def\endfirsthead{\\}%
    \def\endhead{\\}%
    \def\endfoot{\\}%
    \def\endlastfoot{\\}%
    \def\tabulary{%
        \def\TY@final{%
            \def\endfirsthead{\LT@end@hd@ft\LT@firsthead}%
            \def\endhead{\LT@end@hd@ft\LT@head}%
            \def\endfoot{\LT@end@hd@ft\LT@foot}%
            \def\endlastfoot{\LT@end@hd@ft\LT@lastfoot}%
            \longtable}%
        \let\endTY@final\endlongtable
        \TY@tabular}%
    \dimen@\columnwidth
    \advance\dimen@-\LTleft
    \advance\dimen@-\LTright
    \tabulary\dimen@}
\def\endltabulary{\endtabulary}
\makeatother
\makeatletter
\def\@cline#1-#2\@nil{%
    \omit
    \@multicnt#1%
    \advance\@multispan\m@ne
    \ifnum\@multicnt=\@ne\@firstofone{&\omit}\fi
    \@multicnt#2%
    \advance\@multicnt-#1%
    \advance\@multispan\@ne
    \leaders\hrule\@height\arrayrulewidth\hfill
    \cr
    \noalign{\nobreak\vskip-\arrayrulewidth}}
\makeatother

\begin{document}
\vspace*{8cm}

\setlength{\tymin}{2.8cm}
\begin{ltabulary}{|L|L|L|L|}

    \caption{Befehle und Parameter des UART-Protokolls\label{tab:protokoll}}\\
    \hline 
    \textbf{Befehl} &\textbf{erster Parameter} &\textbf{zweiter Parameter}& \textbf{Funktion des Anerkennungswerts}  \endhead\hline 
    \multirow{5}{=}{\texttt{0}: Steuerung der Verarbeitungsmodulen}&\texttt{0}: Schaltet die externe Steuerung ab und aktiviert die interne Steuerung beginnend mit dem Module angegeben im zweiten Parameter.&\multirow{3}{=}{Nummer des Moduls an dem den Befehl ausgeführt werden soll }&\multirow{3}{=}{Der Anerkennungswert wird zurück gesendet sobald der Befehl ausgeführt wurde.}\\*\cline{2-2}
    &\texttt{1}: Aktiviert ein Modul extern.&&\\*\cline{2-2}
    &\texttt{2}: Wie \texttt{1}, aber Mikrocontroller wartet dann, bis der Modul seine  Aufgabe erledigt, bevor  den Anerkennungswert zu senden&&\\*\cline{2-3}
    &\texttt{3}: Mikrocontroller sendet den Anerkennungswert, sobald der aktive Modul seine  Aufgabe erledigt. Dies ist primär dafür gedacht, wenn der FPGA auf die interne Steuerung eingestellt ist&\multirow{2}{=}[-1cm]{Der zweite Parameter wird ignoriert. }&\\*\cline{2-2 }
    &\texttt{4}: Die Verarbeitungsmodule werden in Reset-Zustand versetzt. Er wird durch die Parameterwert \texttt{0-2} deaktiviert.&&\\\hline
\end{ltabulary}
\end{document}

I use latest MikTex and lualatex

  • Could you please turn your code fragments into a real compilable minimal working example (MWE) that reproduces such an unwanted page break? – leandriis Jul 13 at 14:09
  • Could you please also include the reason for your usage of all the \multirow commands. As far as I can see from the soce you posted, there is actually not really a need for them, unless you want to vertically center the contents of thouse cells with respect to the adjacent rows. – leandriis Jul 13 at 14:14
  • edited the question to make it compilable. Also corrected the first question and remove the second one, because it is irrelevant if the first is solved. – Andrey Pro Jul 13 at 14:57
  • @leandriis Multirow also makes the column height indepenent from each other. – Andrey Pro Jul 13 at 14:58
  • That's indeed true. Could you please also add, where you would want your pagebreak to happen? Probably you could also benefit from using a landscape page for your table. – leandriis Jul 13 at 18:43

Your Answer

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

Browse other questions tagged or ask your own question.