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}
8
  • 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
    Commented May 24, 2015 at 22:53
  • Could this be related to this question?
    – nickie
    Commented May 24, 2015 at 22:59
  • @nickie That doesn't solve this particular problem.
    – A.Ellett
    Commented May 24, 2015 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
    Commented May 25, 2015 at 1: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? Commented May 25, 2015 at 11:33

1 Answer 1

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.

6
  • @Eliska Vlckova, see thread of my question mentioned in update. There is now new, better solution for coloring first row in your table.
    – Zarko
    Commented May 26, 2015 at 9: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 Commented May 30, 2015 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
    Commented May 30, 2015 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
    Commented May 30, 2015 at 15:12
  • Ok I'm using the \thetable solution for now, thanks. But I did ask another question for it here (tex.stackexchange.com/questions/247807/…). Commented May 30, 2015 at 19:53

You must log in to answer this question.

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