Graphics, Figures & Tablesfilling header cells with color

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
greg76
Posts: 1
Joined: Tue Oct 29, 2024 8:17 am

filling header cells with color

Post by greg76 »

Using the markup below, after rendering the PDF in different PDF viewers, the table header is displayed with artifacts: in Adobe Reader, when changing the zoom, the lines of the table header disappear. Sumatra PDF displays everything normally. How can I ensure there are no artifacts when viewing the PDF in Adobe Reader?

Code: Select all

\begin{longtable}
    {|>{\centering\arraybackslash}m{13cm}|>{\centering\arraybackslash}m{4cm}|}
    \caption{Основные номинальные параметры устройства\hfill\vspace{-0.5\baselineskip}}\label{desc:chars}\\ 
    \hhline{|-|-|}
    \rowcolor{gray!30}
    
    Параметр & Значение \\
    \hhline{|-|-|}
    \endfirsthead
    \caption{\emph{Продолжение\hfill\vspace{-0.5\baselineskip}}} \\ % Отступ обозначения таблицы от таблицы и выравнивание надписи слева

    \rowcolor{gray!30}
    Параметр & Значение \\ \hhline{|-|-|}

    \endhead

    \endfoot

    \endlastfoot

    \flushleft Номинальный переменный ток, А  & \flushleft\arraybackslash 1; 5 \\  \hhline{|-|-|}
    \flushleft Номинальная частота, Гц  & \flushleft\arraybackslash 50 \\  \hhline{|-|-|}
    \flushleft Номинальное напряжение оперативного постоянного тока, В  & \flushleft\arraybackslash 110; 220 \\  \hhline{|-|-|}
    \flushleft Номинальное напряжение оперативного переменного тока, В  & \flushleft\arraybackslash \textcolor{red}{110; 220} \\  \hhline{|-|-|}

\end{longtable}
1.png
1.png (11.62 KiB) Viewed 2625 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics
FPantigny
Posts: 5
Joined: Wed Jul 26, 2023 10:37 pm

Re: filling header cells with color

Post by FPantigny »

The package nicematrix has tools designed to address that kind of problem.

More precisely, you may encounter two problems with colortbl :

Some rules seem to disappear. This is because many PDF viewers give priority to graphical element drawn posteriorly (which is in the spirit of the "painting model" of PostScript and PDF). Concerning this problem, MuPDF (which is used, for instance, by SumatraPDF) gives better results than Adobe Reader.

A thin white line may appear between two cells of the same color. This phenomenon occurs when each cell is colored with its own instruction fill (the PostScript operator fill noted f in PDF). This is the case with colortbl: each cell is colored on its own, even when \columncolor or \rowcolor is used. As for this phenomenon, Adobe Reader gives better results than MuPDF.

With nicematrix, both artefacts won't occur, whatever PDF viewer you use.
Post Reply