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.

I use the longtable package. Its allow command \\*, for page breaking prohibition on row. Here the code, where \\* does not prohibit page breaking. (on line 44) Generaed pdf here: http://web-engineering.com.ua/mtest.pdf Can it be because of using multirow package? Please help.

    \documentclass[a4paper,oneside]{book}
    \usepackage{ltablex}
    \usepackage{calc}
    \usepackage{multirow}

    \newdimen{\newtblsparewidth}
    \newdimen{\newtblstarfactor}

    \begin{document}
    \vbox to 450pt{}
    \setlength{\newtblsparewidth}{\linewidth-2\tabcolsep-2\tabcolsep-2\tabcolsep-2\tabcolsep-2\tabcolsep}
    \setlength{\newtblstarfactor}{\newtblsparewidth / \real{4}}
    \begin{tabularx}{\linewidth}{l|l|l|X|}

\hline\noalign{\vskip-\arrayrulewidth}\endhead
\noalign{\vskip-\arrayrulewidth}\hline\endfoot

\multicolumn{1}{|m{0.13\newtblsparewidth}}{\multirow{3}{0.13\newtblsparewidth}{\textbf{/imp1}}} & 
\multicolumn{3}
  {|m{0.35\newtblsparewidth+2\tabcolsep+\arrayrulewidth+0.15\newtblsparewidth+2\tabcolsep+\arrayrulewidth+0.37\newtblsparewidth}|}
    {This  command imports viewer’s settings from the file specified by  setting\_file\_name parameter. Please note, all your current settings will  be overridden and lost.} \\ \cline{2-4}

\multicolumn{1}{|l}{} & \multicolumn{1}{|m{0.35\newtblsparewidth}}{pagemode} & 
\multicolumn{1}{|m{0.15\newtblsparewidth}}{} & 
\multicolumn{1}{|m{0.37\newtblsparewidth}|}{} \\ \cline{2-4}

\multicolumn{1}{|l}{} & \multicolumn{1}{|m{0.35\newtblsparewidth}}{pagemode} & 
\multicolumn{1}{|m{0.15\newtblsparewidth}}{} & 
\multicolumn{1}{|m{0.37\newtblsparewidth}|}{} \\ \hline

% ----

\multicolumn{1}{|m{0.13\newtblsparewidth}}{\multirow{3}{0.13\newtblsparewidth}{\textbf{/imp2}}} & 
\multicolumn{3}
  {|m{0.35\newtblsparewidth+2\tabcolsep+\arrayrulewidth+0.15\newtblsparewidth+2\tabcolsep+\arrayrulewidth+0.37\newtblsparewidth}|}
    {This  command imports viewer’s settings from the file specified by  setting\_file\_name parameter. Please note, all your current settings will  be overridden and lost.} \\ \cline{2-4}

\multicolumn{1}{|l}{} & \multicolumn{1}{|m{0.35\newtblsparewidth}}{pagemode} & 
\multicolumn{1}{|m{0.15\newtblsparewidth}}{} & 
\multicolumn{1}{|m{0.37\newtblsparewidth}|}{} \\ \cline{2-4}

\multicolumn{1}{|l}{} & \multicolumn{1}{|m{0.35\newtblsparewidth}}{pagemode} & 
\multicolumn{1}{|m{0.15\newtblsparewidth}}{} & 
\multicolumn{1}{|m{0.37\newtblsparewidth}|}{} \\* \hline

% ---

\multicolumn{1}{|m{0.13\newtblsparewidth}}{\multirow{3}{0.13\newtblsparewidth}{\textbf{/imp3}}} & 
\multicolumn{3}
  {|m{0.35\newtblsparewidth+2\tabcolsep+\arrayrulewidth+0.15\newtblsparewidth+2\tabcolsep+\arrayrulewidth+0.37\newtblsparewidth}|}
    {This  command imports viewer’s settings from the file specified by  setting\_file\_name parameter. Please note, all your current settings will  be overridden and lost.} \\ \cline{2-4}

\multicolumn{1}{|l}{} & \multicolumn{1}{|m{0.35\newtblsparewidth}}{pagemode} & 
\multicolumn{1}{|m{0.15\newtblsparewidth}}{} & 
\multicolumn{1}{|m{0.37\newtblsparewidth}|}{} \\ \cline{2-4}

\multicolumn{1}{|l}{} & \multicolumn{1}{|m{0.35\newtblsparewidth}}{pagemode} & 
\multicolumn{1}{|m{0.15\newtblsparewidth}}{} & 
\multicolumn{1}{|m{0.37\newtblsparewidth}|}{} \\ \cline{2-4}

\end{tabularx}
\end{document}
share|improve this question
    
please create a minimal example and do not use packages which are only available for you. –  Herbert Feb 21 '12 at 9:27
    
Thanks, Herbert. I have minified example as well as I can. On edited answer, you can see \* after second row (line 44) But page still breaks on this row. –  Andrew Feb 21 '12 at 10:02
    
\\* works the same way in longtable as it does outside, it doesn't actually prevent line breaking (as would a minipage box for example) it just tells TeX that breaking a line there is infinitely bad, trouble is, if you have big thick rows and it's trying to set the page "flushbottom" then not breaking the line and leaving the page very short or over long might be infinitely bad as well. If all its choices are infinitely bad, it picks one of them.... raggedbottom may be your friend here. –  David Carlisle Feb 21 '12 at 11:01
    
Thanks David. I tried insert \raggedbottom in preample before \begin{document}, before and after table definition (\begin{tabularx}) but that doesn't have effect. Where \raggedbottom command should be? –  Andrew Feb 21 '12 at 11:43

1 Answer 1

up vote 7 down vote accepted

write into your preamble:

\makeatletter
\newcommand\nobreakhline{%
\multispan\LT@cols
\unskip\leaders\hrule\@height\arrayrulewidth\hfill\\*}
\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}}
\makeatother

and then use

[...]
\multicolumn{1}{|m{0.37\newtblsparewidth}|}{} \\*\nobreakhline
[...]

or

[...]
\multicolumn{1}{|m{0.37\newtblsparewidth}|}{} \\*\nobreakcline
[...]

The problem is the \hline. A \\* without it works.

share|improve this answer
    
Thanks, Herbert Can you please modify your answer for nobreakcline? Because, when I try set \nobreakhline where cells are rowspanned, I receive line over merged cell, which does not look good. web-engineering.com.ua/mtest1.pdf –  Andrew Feb 21 '12 at 13:25
    
see edited answer –  Herbert Feb 21 '12 at 13:48
    
It works. Thanks. –  Andrew Feb 21 '12 at 14:07

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.