1

I have a single table over more pages and when I use \cline at the end of the last row in a page, the line appears only at the end of the page but not in the begin of the new page at the first row of the table.

With \hline I have the effect that I want but the line pass through all the columns.

I give an example:

enter image description here

Any suggestion?

\documentclass[11pt]{article}
    \usepackage[utf8]{inputenc}
    \usepackage{booktabs}
    \usepackage{ltablex}
    \usepackage[table]{xcolor}
    \newcolumntype{L}{>{\RaggedRight\arraybackslash}m{3cm}}
    \newcolumntype{K}{>{\RaggedRight\arraybackslash \columncolor{blue!10}}m{3cm}}
    \usepackage{ragged2e}
%\newcolumntype{L}{>{\RaggedRight\arraybackslash}X}
    \begin{document}

    \begin{tabularx}{\textwidth}{|>{\hsize=0.8333\hsize}K|
                              >{\hsize=0.4167\hsize}L|
                              >{\hsize=1.0000\hsize}L|
                              >{\hsize=0.8333\hsize}L|}

\hline
\rowcolor{gray!50}\textbf{a} & \textbf{b} & \textbf{c} & \textbf{d}\\
\rowcolor{lightgray}   &   &   &   \\
\rowcolor{lightgray}   &   &   &   \\
\hline
& & & \\
\textbf{Bla bla bla}\par 
\emph{jjjjj}
 & r & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse ut elit ac ipsum placerat scelerisque eget id justo. Ut cursus viverra neque, in porta justo facilisis sit amet. Donec vitae libero a diam lobortis ultrices. Vestibulum metus urna, pharetra et cursus quis, eleifend ut dui. Phasellus pellentesque, quam et hendrerit. & d \\
 &    &   & \\
\cline{2-4}
 & r& Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse ut elit ac ipsum placerat scelerisque eget id justo.  hendrerit. & k
\\
  &     &   &  
\\
\cline{2-4}


 & g & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse ut elit ac ipsum placerat scelerisque eget id justo. Ut cursus viverra neque, in porta justo facilisis sit amet. Donec vitae libero a diam lobortis ultrices. Vestibulum metus urna, pharetra et cursus quis, eleifend ut dui. Phasellus pellentesque, quam et hendrerit. & p
 \\
 \hline

\end{tabularx}
\end{document}
5
  • It's a documented feature:-) hard to do that automatically but \\\cline{...}\pagebreal\cline{..} probably works (you don't say but I assume this is longtable?) Commented Oct 17, 2016 at 17:14
  • How you defined table head and foot of table? Please, provide complete document, which we can copy to our computers and compile.
    – Zarko
    Commented Oct 17, 2016 at 17:15
  • @DavidCarlisle not longtable because there is some compatibility issue with tabularx.
    – NxA
    Commented Oct 17, 2016 at 18:28
  • Here the code: pastebin.com/jf1J9hHu
    – NxA
    Commented Oct 17, 2016 at 18:28
  • Please don't use external links, the question is archived forever and makes no sense if that pastebin goes. it is longtable just called indirectly via ltablex, I'll add to the question. Commented Oct 17, 2016 at 19:24

1 Answer 1

2

You can have what you want incorporating cline{2-4} to \endhead. I suppose you inserted some empty rows to give vertical padding to cell contents. I made padding it automatic. Also I used the (redefined) X column type to make the table full width.

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{ltablex}
\keepXColumns
\renewcommand\tabularxcolumn[1]{ >{\arraybackslash}m{#1}}
\usepackage[table]{xcolor}
\usepackage{ragged2e}

\begin{document}

\begin{tabularx}{\textwidth}%
  {| >{\hsize=1.1\hsize\columncolor{blue!10}}X|
  >{\hsize=0.55\hsize}X|
  >{\hsize=1.25\hsize\rule{0pt}{4ex}}X <{\mbox{}\rule[-2.5ex]{0pt}{0pt}}|
  >{\hsize=1.1\hsize}X|}
  \hline
  \rowcolor{gray!50}\textbf{a} & \textbf{b} & \textbf{c} & \textbf{d} \\%
  \hline
  \endfirsthead
  \hline
  \endhead
  \textbf{Bla bla bla}\par
  \emph{jjjjj}
                               & r & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse ut elit ac ipsum placerat scelerisque eget id justo. Ut cursus viverra neque, in porta justo facilisis sit amet. Donec vitae libero a diam lobortis ultrices. Vestibulum metus urna, pharetra et cursus quis, eleifend ut dui. Phasellus pellentesque, quam et hendrerit. & d \\
  \cline{2-4}
                               & r & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse ut elit ac ipsum placerat scelerisque eget id justo. hendrerit. & k
  \\
  \cline{2-4}
                               & g & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse ut elit ac ipsum placerat scelerisque eget id justo. Ut cursus viverra neque, in porta justo facilisis sit amet. Donec vitae libero a diam lobortis ultrices. Vestibulum metus urna, pharetra et cursus quis, eleifend ut dui. Phasellus pellentesque, quam et hendrerit. & p
  \\
  \hline
\end{tabularx}

\end{document} 

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .