5

I'm using the \endfirsthead and \endhead but the first row is not repeated for some reason. Here's a piece of my code, I'll appreciate any help.

\documentclass[12pt]{article}
\linespread{1.2}
\usepackage{longtable}
\usepackage[table]{xcolor}
\usepackage{tcolorbox}
\tcbuselibrary{breakable,skins}
\cellcolor[gray]{0.95}

\begin{document}

\begin{tcolorbox}[%%
  breakable, 
  ]
\begin{longtable}{b{0.35cm}|b{2cm}||c|c|}
C. & HEADER    & {CSF1} & {CSF2}      \\\hline\hline\endfirsthead
C. & HEADER    & {CSF1} & {CSF2}      \\\hline\hline\endhead
P1 & Vyroba    & OK     & OK          \\\hline
P2 & Nakup     &        & OK          \\\hline
P3 & Prodej    & OK     & OK          \\\hline
P4 & Logistika &        &             \\\hline
P5 & Sklad     & OK     & OK          \\\hline
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
P6 & Inventura & OK     & OK          \\
% the table continues
\end{longtable}
\end{tcolorbox}
\end{document}
A.Ellett
  • 50,533
  • I correct your MWE that now works and show your problem. As I see, you use tcolorbox just to have table head in shape with rounded upper corners. If you sacrifice this, you can obtain desired shadowing with \rowcolor{<desired color>} .... – Zarko May 24 '15 at 22:53
  • Could this be related to this question? – nickie May 24 '15 at 22:59
  • @nickie That doesn't solve this particular problem. – A.Ellett May 24 '15 at 23:10
  • I've been digging through the code for longtable. The header is stored in a box \LT@head. But the boxing and unboxing of this relies upon register \z@. I suppose that something might be happening between tcolorbox managing the page break and longtable trying to do the same that's interrupting each other. – A.Ellett May 25 '15 at 01:31
  • @Zarko Thanks, I guess I have no choice but to abandon the pretty tcolorbox table (I don't really need rounded corners, but I used \caption in the title as a part of the table which was handy) - do you think I can still use the \definecolor{tablerow1}{}{} to define alternating colours of rows in a simple longtable? – Eliska Vlckova May 25 '15 at 11:33
  • @A.Ellett Thanks, do you think it could be fixed using frame code definitions for each section of the broken tcolorbox? I found these in the manual for tcolorbox on p.201 but I haven't tried them. Or is it easier to use Zarko's solution? – Eliska Vlckova May 25 '15 at 11:39
  • @EliskaVlckova The content of a breakable tcolorbox is a huge \vbox which is broken using \vsplit. Therefore, the embedded longtable is set like on a huge single page and cannot repeat the header. So, unfortunately, there is no easy solution. – Thomas F. Sturm May 26 '15 at 09:36
  • Could longtable be made aware of the \vsplit or is it too late at this point of the typesetting procedure? – MaxNoe May 26 '15 at 11:22

1 Answers1

5

I haven't solution with tcolorbox, but as I mentioned in my comment similar look you can obtain (without rounded table top corners) with following MWE:

\documentclass[12pt]{article}
    \usepackage[utf8]{inputenc}
    \usepackage[left=3.5cm,right=2.5cm,top=2.5cm,bottom=15cm]{geometry}

    \usepackage[table]{xcolor}
    \usepackage{longtable}
    \usepackage{makecell}
\renewcommand\theadfont{\large\bfseries}

    \usepackage{rotating}
\newcommand*\rot{\rotatebox{90}}
    \usepackage{amssymb}
\newcommand*\OK{$\checkmark$}

\newcolumntype{R}{>{\raggedright\arraybackslash}b}
\newcolumntype{C}{>{\centering\arraybackslash}b}

    \begin{document}
    \rowcolors{1}{gray!10}{gray!5}
\begin{longtable}{|R{\dimexpr 0.055\linewidth-2\tabcolsep}|
                   R{\dimexpr 0.521\linewidth-2\tabcolsep}||
                  *{10}{C{\dimexpr 0.04\linewidth-2\tabcolsep}|}}
    \hline
\rowcolor{gray!30}
\multicolumn{12}{|c|}{\large\textbf{Tabulka procesů}}  \\
    \hline
\rowcolor{gray!10}
Č. & Proces & \rot{CSF1} & \rot{CSF2} & \rot{CSF3} & \rot{CSF4} & \rot{CSF5} & \rot{CSF6} & \rot{Suma} & \rot{Kvalita} & \rot{Význam IT} & \rot{Technická kvalita~}\\
\hline\hline
\endfirsthead
    \hline
Č. & Proces & \rot{CSF1} & \rot{CSF2} & \rot{CSF3} & \rot{CSF4} & \rot{CSF5} & \rot{CSF6} & \rot{Suma} & \rot{Kvalita} & \rot{Význam IT} & \rot{Technická kvalita~}  \\
\hline\hline
\endhead
% telo tabele
P1 & Výroba                     & \OK   & \OK   &       &       & \OK   &       & 3 & B & A & B  \\ \hline
P2 & Nákup                      &       & \OK   &       &       & \OK   & \OK   & 3 & B & B & B  \\ \hline
P3 & Prodej                     & \OK   & \OK   & \OK   & \OK   & \OK   &       & 5 & B & B & B  \\ \hline
P4 & Logistika                  &       &       & \OK   & \OK   &       &       & 2 & B & B & C  \\ \hline
P5 & Sklad                      & \OK   & \OK   &       &       & \OK   & \OK   & 4 & B & B & B  \\ \hline
P6 & Inventura                  & \OK   & \OK   &       &       &       & \OK   & 3 & B & B & B  \\  \hline

P1 & Výroba                     & \OK   & \OK   &       &       & \OK   &       & 3 & B & A & B  \\ \hline
P2 & Nákup                      &       & \OK   &       &       & \OK   & \OK   & 3 & B & B & B  \\ \hline
P3 & Prodej                     & \OK   & \OK   & \OK   & \OK   & \OK   &       & 5 & B & B & B  \\ \hline
P4 & Logistika                  &       &       & \OK   & \OK   &       &       & 2 & B & B & C  \\ \hline
P5 & Sklad                      & \OK   & \OK   &       &       & \OK   & \OK   & 4 & B & B & B  \\ \hline
P6 & Inventura                  & \OK   & \OK   &       &       &       & \OK   & 3 & B & B & B  \\  \hline

% the table continuing on the next page

P1 & Výroba                     & \OK   & \OK   &       &       & \OK   &       & 3 & B & A & B  \\ \hline
P2 & Nákup                      &       & \OK   &       &       & \OK   & \OK   & 3 & B & B & B  \\ \hline
P3 & Prodej                     & \OK   & \OK   & \OK   & \OK   & \OK   &       & 5 & B & B & B  \\ \hline
P4 & Logistika                  &       &       & \OK   & \OK   &       &       & 2 & B & B & C  \\ \hline
P5 & Sklad                      & \OK   & \OK   &       &       & \OK   & \OK   & 4 & B & B & B  \\ \hline
P6 & Inventura                  & \OK   & \OK   &       &       &       & \OK   & 3 & B & B & B  \\  \hline
\end{longtable}
    \end{document}

It is based on your first MWE. I omit all not necessary packages and shortcuts, which disturb table lookout and was necessary at use of tcolorbox, and add new one which help me to design a table (rotating, makecel and amssymb)Well, it is not so fancy as with tcolorbox ... but it have different colors for odd and even rows (if you not liked, just put the same color in \rowcolors{1}{gray!10}{gray!5} :-) )

the first page: enter image description here

and second page: enter image description here

Update: After while I see that the first row, used for caption is not colored properly. I suspect, that cause is not full compatibilita between packages makecell and [table]{xcolor} (whiich actualy activate colortab). This confirm @egre in his answer on my question http://tex.stackexchange.com/questions/246889/how-to-color-column-heads-determined-width-makecell and give a solution for this missmatch. You just replace rows in ma MWE

    \usepackage{makecell}
\renewcommand\theadfont{\large\bfseries}
...
    \rowcolors{1}{gray!10}{gray!5}
\begin{longtable}{|R{\dimexpr 0.055\linewidth-2\tabcolsep}|
                   R{\dimexpr 0.521\linewidth-2\tabcolsep}||
                  *{10}{C{\dimexpr 0.04\linewidth-2\tabcolsep}|}}
    \hline
\rowcolor{gray!30}
\multicolumn{12}{|c|}{\large\textbf{Tabulka procesů}}  \\

width:

\newcommand{\thead}[1]{%
  \bfseries
  \begin{tabular}{@{}c@{}}
  \vrule height 1.2\ht\strutbox width 0pt\ignorespaces
  #1
  \unskip\vrule depth 1.2\dp\strutbox width 0pt
  \end{tabular}%
}
...
    \begin{longtable}{|R{\dimexpr 0.055\linewidth-2\tabcolsep}|
                   R{\dimexpr 0.521\linewidth-2\tabcolsep}||
                  *{10}{C{\dimexpr 0.04\linewidth-2\tabcolsep}|}}
    \hline
\multicolumn{12}{|c|}{\thead{Tabulka procesů}}  \\
    \hline

and the first row of table will look as should on the first place. I replace first image with new one.

Zarko
  • 296,517
  • @Eliska Vlckova, see thread of my question mentioned in update. There is now new, better solution for coloring first row in your table. – Zarko May 26 '15 at 09:05
  • Thanks, it's working great now. Only - do you think there's a way I could input \caption{} in the multicolumn? It's throwing Misplaced \noalign. exception, and I'm having trouble with finding any solution. I tried not using the multicolumn but then I'm missing the side lines and \tabcolsep can't be used there. @Zarko – Eliska Vlckova May 30 '15 at 10:56
  • 1
    No. Normally \caption following \bagin{longtable}, but this will screw-up your temporary table formatting. Solution is seems to be mimic of captions something like this\textbf{Table \thetable}: ...caption text ...`` Beside this you need to increment caption counter before and after this (not yet tested). Probbaly is good idea to ask new question here, maybe some one know better solution. – Zarko May 30 '15 at 14:55
  • I must correct myself. You do not need manually increment table counter before and after mimic of table caption (tested). Even referencing works as should do. – Zarko May 30 '15 at 15:12
  • Ok I'm using the \thetable solution for now, thanks. But I did ask another question for it here (http://tex.stackexchange.com/questions/247807/is-there-a-way-to-insert-caption-inside-a-multicolumn-on-top-of-a-longtable). – Eliska Vlckova May 30 '15 at 19:53
  • Meanwhile you got solution from David Carlise. I tested it in my answer. It works, but I'm not satisfied with coloring of the row with caption. The color is a bit shorter then row. – Zarko May 30 '15 at 20:17