1

In the table:

\begin{table}[h]
\hfill
\begin{tabular}[t]{l|c|l|c|c|}
\cline{2-5}
Zestawienie VAT: & \cellcolor[HTML]{C0C0C0}\textbf{\begin{tabular}[c]{@{}c@{}}Wartość\\ netto {[}zł{]}\end{tabular}} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}\textbf{\begin{tabular}[c]{@{}c@{}}Stawka\\ VAT\end{tabular}}} & \cellcolor[HTML]{C0C0C0}\textbf{\begin{tabular}[c]{@{}c@{}}Wartość\\ VAT {[}zł{]}\end{tabular}} & \cellcolor[HTML]{C0C0C0}\textbf{\begin{tabular}[c]{@{}c@{}}Wartość\\ brutto {[}zł{]}\end{tabular}} \\ \cline{2-5} 
                 & \multicolumn{1}{r|}{}                                                                             & zw                                                                                                         & \multicolumn{1}{r|}{0,00}                                                                       & \multicolumn{1}{r|}{}                                                                              \\ \cline{2-5} 
\end{tabular}
\end{table}

The top line is not drawed by the \cline{2-5}. What could be the issue? table

EDIT: The code with removed other user content is here. Unfortunately when I try to compile it, I get some error, which can't solve easily, but in the end the pdf is working and the table without top line is generated. I use the \usepakage[table]{xcolor} package mentioned by @daleif in the comment:

\documentclass[a4paper,pagenumber=no,9pt,DIV=10]{scrlttr2}

\usepackage[polish]{babel}
\usepackage[utf8]{luainputenc} 
\usepackage{invoice}
\usepackage[table,xcdraw]{xcolor}
\usepackage{graphicx}

\addtolength{\textwidth}{2.5cm}
\addtolength{\hoffset}{-1.25cm}
\addtolength{\voffset}{-1.25cm}

\usepackage{fontspec}
\setmainfont{Calibri}

\usepackage[parfill]{parskip}

\def\mydate{\leavevmode\hbox{\the\year-\twodigits\month-\twodigits\day}}
\def\twodigits#1{\ifnum#1<10 0\fi\the#1}

\usepackage{pgfkeys,pgfcalendar}

\usepackage{booktabs,caption,float}

\usepackage{newfloat}

\DeclareFloatingEnvironment[fileext=lot]{table}

\usepackage[export]{adjustbox}

\usepackage{amsmath}

\newcount\julianday
\newcount\daycount
\newcount\weekday

\newcommand*{\adddays}[2]{%
  \pgfcalendardatetojulian{#1}{\julianday}%
  \daycount=#2\relax
  \loop
    \advance\julianday by 1\relax
    \advance\daycount by -1\relax
  \ifnum\daycount > 0
  \repeat
  \pgfcalendarjuliantodate{\julianday}{\thisyear}{\thismonth}{\thisday}%
  \thisyear-\thismonth-\thisday
}


\begin{document}


\begin{table}[h]
\hfill
\begin{tabular}{lrlrr}
\cline{2-5}
\multicolumn{1}{r|}{Zestawienie VAT:} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}\textbf{\begin{tabular}[c]{@{}c@{}}Wartość\\ netto {[}zł{]}\end{tabular}}} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}\textbf{\begin{tabular}[c]{@{}c@{}}Stawka\\ VAT\end{tabular}}} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}\textbf{\begin{tabular}[c]{@{}c@{}}Wartość\\ VAT {[}zł{]}\end{tabular}}} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}\textbf{\begin{tabular}[c]{@{}c@{}}Wartość\\ brutto {[}zł{]}\end{tabular}}} \\ \cline{2-5} 
\multicolumn{1}{l|}{}                 & \multicolumn{1}{r|}{500}                                                                                                  & \multicolumn{1}{l|}{zw}                                                                                    & \multicolumn{1}{r|}{0,00}                                                                                            & \multicolumn{1}{r|}{500}                                                                                                   \\ \cline{2-5} 
                                      & \multicolumn{1}{l}{}                                                                                                   &                                                                                                            & \multicolumn{1}{l}{}                                                                                                 & \multicolumn{1}{l}{}                                                                                                    \\ \cline{2-5} 
\multicolumn{1}{r|}{Razem:}           & \multicolumn{1}{r|}{500}}                                                                                                  & \multicolumn{1}{l|}{-}                                                                                     & \multicolumn{1}{r|}{0,00}                                                                                            & \multicolumn{1}{r|}{500}                                                                                                   \\ \cline{2-5} 
\end{tabular}
\end{table}

\end{document}
9
  • As always on the site please provide a full (but minimal) example that others can copy and test as is. We for example does not know which packages your are loading. – daleif Aug 12 '20 at 14:00
  • Ok, sorry for that. I'm preparing minimal example... – bLAZ Aug 12 '20 at 14:01
  • 1
    I'm guessing that you are using either \usepakage[table]{xcolor} or use the colortbl package directly. The colortbl manual actually mentions this problem in section 10. – daleif Aug 12 '20 at 14:09
  • 1
  • 1
    Regarding "I get some error, which can't solve easily, but in the end the pdf is working": Please never ever ignore error messages! Even if you get something that on first glance resembles a pdf file, there can still be issues with it. After an error, TeX only tries to recover enough to syntax check more of the file, it does not try to make sensible output after an error. Thus, try to fix ther error message first, before even looking at the pf file. If you caon't fix the error, ask a qeustion specifically about this error message. – leandriis Aug 13 '20 at 14:27
1

I have edited this answer because, with the latest version of nicematrix (5.6), we don't need makecell any longer here.


The text Zestawienie VAT: has no semantic reason to be in the tabular. The OP has probably created a column for this text because if wants that text aligned with the first row of his tabular. But it's not possible to set the baseline of the tabular on the first row because of the first \hline (and the use \firsthline of array doesn't help because the first row has not a standard height).

That's why the OP has tried to put Zestawienie VAT: in a first column of the tabular. Doing so, he has to use \cline instead of hline. However, \cline is not compatible with \cellcolor (because the rule drawn by \cline protrudes in the following row and is covered by the colored panel drawn after the rule; remark that this is for only historical reasons: \hline has not that behaviour).

In order to solve that problem, I suggest to use {NiceTabular} of nicematrix. The rules are drawn with PGF/Tikz and there is no problem to have a baseline of the tabular on the first row (and there is no problem to put Zestawienie VAT: before the tabular).

\documentclass{article}
\usepackage{xcolor}
\usepackage{nicematrix}

\begin{document}

\begin{table}[h]
\hfill
Zestawienie VAT: 
\begin{NiceTabular}[t]{clcc}[hvlines,code-before = {\rowcolor[HTML]{C0C0C0}{1}}]
  \Block{}{Wartość\\ netto {[}zł{]}}
& \Block{}{Stawka\\ VAT}
& \Block{}{Wartość\\ VAT {[}zł{]}}
& \Block{}{Wartość\\ brutto {[}zł{]}} \\ 
25123,89 & zw & \multicolumn{1}{r}{0,00} & 25123,89 \\ 
\end{NiceTabular}
\end{table}

\end{document}

However, several compilations are required.

enter image description here

0

Works well -remove the tabulars inside and the \multicolumn -- its not required

enter image description here

\begin{table}[h]
    \hfill
    \begin{tabular}[t]{l|c|l|c|c|}
        \cline{2-5}
        Zestawienie VAT: & 
            \textbf{A} & 
                \textbf{B} & 
                    \textbf{C} & 
                        \textbf{D} \\ \cline{2-5} 
        & \multicolumn{1}{r|}{}                                                                             & zw                                                                                                         & \multicolumn{1}{r|}{0,00}                                                                       & \multicolumn{1}{r|}{}                                                                              \\ \cline{2-5} 
    \end{tabular}
\end{table}
1
  • 5
    erh, why did you remove the cell coloring? Which exactly is the problem – daleif Aug 12 '20 at 14:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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