[Tex/LaTex] Table does not break properly between tables

longtablemultirowpage-breaking

Table overdraw footer, when I expect that this should be break on new page after fifth line (after this text 'Uuuuuuuuuu ttt ppppppp')

Here is the generated PDF: http://web-engineering.com.ua/mtest3.pdf

And code:

\documentclass[a4paper,oneside]{book}
\usepackage[paper=a4paper, left=1.5cm, right=1cm, top=1.7cm, bottom=2.5cm]{geometry}
\usepackage{ltablex}
\usepackage{calc}
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage{color}
\usepackage{colortbl}
\usepackage{fancyhdr}

%\usepackage{mylayout}

%fancyhdr way
\pagestyle{fancy}
\setlength{\headheight}{1cm}
\definecolor{White}{rgb}{1, 1, 1}

\lhead{}
\chead{}
\rhead{}
\lfoot{\textbf{2001-2012 FOOTERT FOOTER FOOTER FOOTER}}
\cfoot{}
\rfoot{}

\makeatletter

\newcommand\nobreakcline[1]{\@nobreakcline#1\@nil}%
\def\@nobreakcline#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\\*
  \noalign{\vskip-\arrayrulewidth}}

%code takes from http://tex.stackexchange.com/questions/6350/how-to-disable-pagebreak-on-hline-in-longtable
%intended to fix issue #339
\def\nobreakhline{%
  \noalign{\ifnum0=`}\fi
    \penalty\@M
    \futurelet\@let@token\LT@@nobreakhline
}
\def\LT@@nobreakhline{%
  \ifx\@let@token\hline
    \global\let\@gtempa\@gobble
    \gdef\LT@sep{\penalty\@M\vskip\doublerulesep}
  \else
    \global\let\@gtempa\@empty
    \gdef\LT@sep{\penalty\@M\vskip-\arrayrulewidth}
  \fi

  \ifnum0=`{\fi}%
  \multispan\LT@cols
     \unskip\leaders\hrule\@height\arrayrulewidth\hfill\cr
  \noalign{\LT@sep}%
  \multispan\LT@cols
     \unskip\leaders\hrule\@height\arrayrulewidth\hfill\cr
  \noalign{\penalty\@M}%
  \@gtempa}

\makeatother

%For tables
\newdimen{\newtblsparewidth}
\newdimen{\newtblstarfactor}
\setlength{\extrarowheight}{5pt}
\definecolor{Blue}{rgb}{0,0,1}
\definecolor{White}{rgb}{1,1,1}
\arrayrulewidth=1pt

\setlength{\parskip}{1.7ex}

\begin{document}
Here some text. Here some text. Here some text. Here some text. Here some text. Here some text. Here some text. Here some text. 
Here some text. Here some text. Here some text. Here some text. Here some text. Here some text. Here some text. Here some text.
Here some text. Here some text. Here some text. Here some text. Here some text. Here some text. Here some text. Here some text. 
Here some text. Here some text. Here some text. Here some text. Here some text. Here some text. Here some text. Here some text. 
\subsection{Here some text. Here some text. h}
\begin{itemize}
\item Here some list item. here some list Item. here some list item. here some list
\end{itemize}

\hangindent=30pt
\hangafter=0
\noindent \texttt{Some bold text. Bold text BBBBBBBB}

\begin{itemize}
\item Another item. Another item. Anorther item. Naother Item. Another Item Another item. Naother Item. Another item. Another item. Another item. Another item item item just :
\end{itemize}

\hangindent=30pt
\hangafter=0
\noindent \texttt{Latex text content Latex. Page content Latex Page Content . some text Another text Latex text. This is LaTeX Dummy text. And another some }

\begin{itemize}
\item Some command and this is dummy latex text. Dont read this. Thsi is just a dummy
\end{itemize}

\hangindent=30pt
\hangafter=0
\noindent \texttt{Mail Latex. This is Lmeainingless text. This is medaningless text XXXXXXXX-XXXXXXXXXX-XXXXXX-XXX-XX n: Something meaningless . somethong foolish   }

\begin{itemize}
\item Senseless text. Don't read it. Thsi is text without meaning. Just for filling:
\end{itemize}

\hangindent=30pt
\hangafter=0
\noindent \texttt{Bold meaningless LaTexX Content here . YYY}

\begin{itemize}
\item Xxxxxxxxxxe MMM-cccccc gg ddddddd Latex ghff ghf fgfgfas fga afsg agsyyg gshf ghg  ghg hghghhg:
\end{itemize}

\hangindent=30pt
\hangafter=0
\noindent \texttt{XXXXXwer.exe COmhjehhebf ;lkslkhfhjf,fjf helpb, djksdjh /helele 'Vvvvvvvvvvvvvv}

\section{Section section section section section}
Wwwwwww w Iiiiiiiiii  00000   0.0 

\texttt{mmmmmmm /O00000 <Rrrrrrrr Ppppppppp> [Oooooooo Ppppppppp]}

\textbf{Bbbbbb dddd iiii seeeeees -- ttttt aaa ttt swwwwwww aaa wwww eeee dddd:}

\setlength{\newtblsparewidth}{\linewidth-2\tabcolsep-2\tabcolsep-2\tabcolsep-2\tabcolsep}
\setlength{\newtblstarfactor}{\newtblsparewidth / \real{3}}
\begin{tabularx}{\linewidth}{l|X|X|}
\hline\noalign{\vskip-\arrayrulewidth}\endhead
\noalign{\vskip-\arrayrulewidth}\hline\endfoot
\nobreakhline

\multicolumn{1}{|>{\columncolor{Blue}\color{White}}m{0.15\newtblsparewidth}}{\centering OOOOOOO} & 
\multicolumn{1}{|>{\columncolor{Blue}\color{White}}m{0.4\newtblsparewidth}}{\centering SSSsSssS} & 
\multicolumn{1}{|>{\columncolor{Blue}\color{White}}m{0.45\newtblsparewidth}|}{\centering DDDDDDDDDDD} \\ *\nobreakhline

\multicolumn{1}{|m{0.15\newtblsparewidth}}{\multirow{4}{0.15\newtblsparewidth}{IIIIIIl OOOOOOO}} & 
\multicolumn{1}{|m{0.4\newtblsparewidth}}{\textbf{</ppppppp | /i> <Ppppppt.mmm>}} & 
\multicolumn{1}{|m{0.45\newtblsparewidth}|}{Iiiiiiii oo cccccccccs a ppppppp} \\ \cline{2-3}

\multicolumn{1}{|l}{} & 
\multicolumn{1}{|m{0.4\newtblsparewidth}}{\textbf{/a <Ppppppp.mmm>}} & 
\multicolumn{1}{|m{0.45\newtblsparewidth}|}{Aaaaaaaaaaaaaa iiiiiii -- Iiiiiiii a ppppppp on the nnnnnnn} \\ \cline{2-3}

\multicolumn{1}{|l}{} & 
\multicolumn{1}{|m{0.4\newtblsparewidth}}{\textbf{/j<u|m> <Ppppppp.mmm> [/t <Ttttttttt Liii>] [/g <Llllllle Ii>]}} & 
\multicolumn{1}{|m{0.45\newtblsparewidth}|}{Aaaaaaaaaa a apppppt -- m to all uuuuu, u to cuuuuuu usss} \\ \cline{2-3}

\multicolumn{1}{|l}{} & 
\multicolumn{1}{|m{0.4\newtblsparewidth}}{\textbf{</Uuuuuuuu | /x> <Ppppppp.mss | PrrrrrrCorr>}} & 
\multicolumn{1}{|m{0.45\newtblsparewidth}|}{Uuuuuuuuuu ttt ppppppp} \\ \hline

\multicolumn{1}{|m{0.15\newtblsparewidth}}{\multirow{4}{0.15\newtblsparewidth}{Ddddddd Ooooooo}} & 
\multicolumn{1}{|m{0.4\newtblsparewidth}}{\textbf{/qqqqq}} & 
\multicolumn{1}{|m{0.45\newtblsparewidth}|}{Qqqqq mmmm, no ussss n   dddddd} \\* \nobreakcline{2-3}

\multicolumn{1}{|l}{} & 
\multicolumn{1}{|m{0.4\newtblsparewidth}}{\textbf{/passive}} & 
\multicolumn{1}{|m{0.45\newtblsparewidth}|}{Uuuuuuuuuu oodo -- pppppppp bbb oooo} \\* \nobreakcline{2-3}

\multicolumn{1}{|l}{} & 
\multicolumn{1}{|m{0.4\newtblsparewidth}}{\textbf{/q[n|b|r|f]}} & 
\multicolumn{1}{|m{0.45\newtblsparewidth}|}{Sssssu uuui uuuuuce lllll: %} \\ \cline{2-3}
\newline
\textbf{n} -- Nn UI \newline
\textbf{b} -- Bbbbb UI \newline
\textbf{r} -- Rrrrrrr UI \newline
\textbf{f} -- Fuuu UI (ddddddd) \newline
}\\ \cline{2-3}

\multicolumn{1}{|l}{} & 
\multicolumn{1}{|m{0.4\newtblsparewidth}}{\textbf{/help}} & 
\multicolumn{1}{|m{0.45\newtblsparewidth}|}{Hhhh innnnnnnnnn} \\ \hline

\multicolumn{1}{|m{0.15\newtblsparewidth}}{\multirow{3}{0.15\newtblsparewidth}{Rrrrrrr Ooooooo}} & 
\multicolumn{1}{|m{0.4\newtblsparewidth}}{\textbf{/norestart}} & 
\multicolumn{1}{|m{0.45\newtblsparewidth}|}{Dd nnn reeeeee aaaaa trr irrrttrytyty iy ctytytyt} \\ \cline{2-3}

\multicolumn{1}{|l}{} & 
\multicolumn{1}{|m{0.4\newtblsparewidth}}{\textbf{/ytytututututut}} & 
\multicolumn{1}{|m{0.45\newtblsparewidth}|}{Phfjdjhjd djhfj djhfljlkj kdjhfsd djfskjdh} \\ \cline{2-3}

\multicolumn{1}{|l}{} & 
\multicolumn{1}{|m{0.4\newtblsparewidth}}{\textbf{/fjhkjhkdhkjh}} & 
\multicolumn{1}{|m{0.45\newtblsparewidth}|}{Asjdjjh dkshkjdhfks sjdhfkjdh the jhghgdfhghjf} \\ \hline
\end{tabularx}

\end{document}

Best Answer

You don't give many places where the table can break, perhaps longtable could do better, but....

If you give it a bit of help it can do better:

line 155

\multicolumn{1}{|m{0.45\newtblsparewidth}|}{Uuuuuuuuuu ttt ppppppp} \\ \hline
\noalign{\break}
\multicolumn{1}{|m{0.15\newtblsparewidth}}{\multirow{4}{0.15\newtblsparewidth}{Ddddddd Ooooooo}} & 

If it had been a longtable you could have used \newpage rather than \noalign{\break} but unfortunately the ltablex package you are using doesn't enable longtables redefinitions at the right time, so you have to drop down to the primitive \noalign.