Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
1  
If I run your (not very minimal) MWE I get Runaway definition? ->\ifx \@let@token \hline \global \let \@gtempa \@gobble \gdef \LT@sep \ETC. ! File ended while scanning definition of \LT@@nobreakhline. <inserted text> –  David Carlisle Mar 21 '12 at 16:23
    
I am sorry, David, I edited question. Try again, please. –  Andrew Mar 21 '12 at 16:39
    
I am sorry again, but this is minimal example, where I can reproduce the problem. It have been taken from large (215 pages) book –  Andrew Mar 21 '12 at 16:41
    
A minimal example would have replaced all the initial text with a single \vspace{whatever length is needed} to push the start of the table to a bad position and would have used text like 1 2 3 in the cells to make it easy to switch back and forth between source and output. Try adding \tracingall to your document and you'll see the log is not as minimal as one would like:-) –  David Carlisle Mar 21 '12 at 17:26

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer
    
But with such help, when amount of text before table will increase, table may become on the begining of the next page, page will break and I may receive page with just snippet of table and empty space to the end of page. Or I am wrong? –  Andrew Mar 21 '12 at 17:36
    
Not wrong, but when you have so many large unbreakable boxes in the table that may be the way it is. You could use something less aggressive than \break eg \penalty-500 or whatever encourages a break in this case but will not force it (-10000 is a forced break). As I say it may be possible to make longtable smarter but as releases seem to last for a decade or more, some hand tuning of individual tables may be required in the interim. Or perhaps @percusse spotted a fix, I don't see exactly what changed in the other answer –  David Carlisle Mar 21 '12 at 17:45
    
Thank you, David! –  Andrew Mar 21 '12 at 17:54

Following code seemingly works: (I just removed your meaningless text with lipsum package commands. However, I have no idea what was the problem or how I fixed it. Looks like the consecutive itemize environments are doing something. Your way of posing the question makes it impossible to actually debug. You can fill the page with nonsensible text using \lipsum[1-x] where x is the paragraph number of the classic lipsum text. Even better we have the kantlipsum package from egreg which types out English paragraphs.

\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{lipsum}
%\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}
\chapter{First}
\section{first}
\lipsum[2]
\subsection{Here some text. Here some text. h}
\begin{itemize}
\item \lipsum[3] 

\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 }

\item am dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi. Morbi auctor lorem non justo. 
Nam lacus libero, pretium at, lobortis vitae, ultricies et, tellus. Donec aliquet, tortor sed accumsan
Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatibus et magnis dis parturient montes, 
nascetur ridiculus mus. Aliquam tincidunt urna. Nulla ullamcorper vestibulum turpis. Pellentesque cursus 
luctus mauris bibendum, erat ligula aliquet


\end{itemize}


\section{Section section section section section}


fringilla a, euismod sodales, sollicitudin vel, wisi. Morbi auctor lorem non justo. Nam 

\texttt{fringilla a, euismod sodales, sollicitujusto. Nam }

\textbf{fringilla a, euismod sodales, sollicitudin vel, wisi. Morbi auctor lorem non justo. Nam }

\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}

enter image description here

share|improve this answer
    
Thanks, I dont heared about lipsum package. I will use it further. The problem reproducing depends on amount of text before table. pagebreak does not insert properly just for particular location of table begining on the page. Because such happens sometimes, I want do something for making sure that table would no overdraw footer in any case. –  Andrew Mar 21 '12 at 17:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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