1

My problem comes whenever I create a longtable using this page: https://www.tablesgenerator.com/ and paste it into Overleaf. Most of it comes out well but in this case, a thin white/uncolored stripe seems to appear in the merged cell.

% Please add the following required packages to your document preamble:
% \usepackage{multirow}
% \usepackage[table,xcdraw]{xcolor}
% Beamer presentation requires \usepackage{colortbl} instead of \usepackage[table,xcdraw]{xcolor}
% \usepackage{longtable}
% Note: It may be necessary to compile the document several times to get a multi-page table to line up properly
\begin{longtable}[c]{|
>{\columncolor[HTML]{C4BD97}}l |
>{\columncolor[HTML]{E6B8B7}}c 
>{\columncolor[HTML]{E6B8B7}}c 
>{\columncolor[HTML]{E6B8B7}}c 
>{\columncolor[HTML]{E6B8B7}}l |}
\caption{}
\label{tab:my-table}\\
\hline
\multicolumn{1}{|c|}{\cellcolor[HTML]{FABF8F}} &
  \multicolumn{4}{c|}{\cellcolor[HTML]{FABF8F}Distribución de horas} \\ \cline{2-5} 
\multicolumn{1}{|c|}{\multirow{-2}{*}{\cellcolor[HTML]{FABF8F}Modulos}} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{FABF8F}\begin{tabular}[c]{@{}c@{}}Horas \\ totales\end{tabular}} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{FABF8F}\begin{tabular}[c]{@{}c@{}}Horas \\ Semanales\\ 1º Curso\end{tabular}} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{FABF8F}\begin{tabular}[c]{@{}c@{}}Horas\\ Semanales\\ 2º Curso\end{tabular}} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{FABF8F}\begin{tabular}[c]{@{}c@{}}Horas \\ Semanales\\ 3º Curso\end{tabular}} \\ \hline
\endfirsthead
%
\endhead
%
\begin{tabular}[c]{@{}l@{}}0959. Sistemas eléctricos, neumáticos\\  e hidráulicos.\end{tabular} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}140} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}4} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}} &
   \\ \hline
0960. Sistemas secuenciales programables. &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}160} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}5} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}} &
   \\ \hline
0961. Sistemas de medida y regulación. &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}140} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}4} &
   \\ \hline
0962. Sistemas de potencia. &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}190} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}6} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}} &
   \\ \hline
0963. Documentación técnica. &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}96} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}3} &
   \\ \hline
0964. Informática industrial. &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}88} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}3} &
   \\ \hline
0965. Sistemas programables avanzados. &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}114} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}} &
  6 \\ \hline
0966. Robótica industrial. &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}90} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}3} &
   \\ \hline
0967. Comunicaciones industriales. &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}165} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}5} &
   \\ \hline
\begin{tabular}[c]{@{}l@{}}0968. Integración de sistemas \\ de automatización industrial.\end{tabular} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}165} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}} &
  9 \\ \hline
\begin{tabular}[c]{@{}l@{}}CLM0027. Inglés técnico para los ciclos \\ formativos de grado superior de la familia\\  profesional de electricidad y electrónica.\end{tabular} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}64} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}2} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}} &
   \\ \hline
0970. Formación y orientación laboral. &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}82} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}3} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}} &
   \\ \hline
\begin{tabular}[c]{@{}l@{}}0969. Proyecto de automatización \\ y robótica industrial.\end{tabular} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}40} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}} &
   \\ \hline
0971. Empresa e iniciativa emprendedora. &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}66} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}2} &
   \\ \hline
0972. Formación en centros de trabajo. &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}400} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{E6B8B7}} &
   \\ \hline
\multicolumn{1}{|c|}{\cellcolor[HTML]{95B3D7}Total} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{FF7C80}2000} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{FF7C80}20} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{FF7C80}20} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{FF7C80}15} \\ \hline
\end{longtable}

Which results in the following table when compiled and turned into a pdf by Overleaf enter image description here

I was hoping if someone here could tell me what's wrong and if possible a solution to this problem. As I am quite novice when it comes to coding and formatting, including working with TeX files, I'm afraid I might be doing something wrong.

1
  • Welcome to TeX.SE!
    – Mensch
    Commented Apr 7 at 20:00

2 Answers 2

1

These thin white lines appear in some PDF viewers. More precisely, they appear in the PDF viewers which use the PDF renderers PDF.js (eg: Firefox, DropBox, Papeeria) or MuPDF (eg; SumatraPDF). They don't appear in Adobe Reader but, with that PDF reader, the rules seem to vanish under the colored panels at some levels of zoom.

The package nicematrix provides an environment {NiceTabular} with tools to avoid such problems.

\documentclass{article}
\usepackage{geometry}
\usepackage[spanish]{babel}
\usepackage{xcolor}
\usepackage{nicematrix}

\begin{document}

\sffamily

\begin{NiceTabular}{X[l,m]*4{c}}[hvlines,color-inside]
\CodeBefore
  \rowcolor[HTML]{FABF8F}{1,2}
  \rectanglecolor[HTML]{E6B8B7}{3-1}{*-1}
  \rectanglecolor[HTML]{C4BD97}{3-2}{*-*}
\Body
  \Block[c]{2-1}{Modulos} & \Block{1-4}{Distribución de horas} \\
  & \Block{}{Horas \\ totales} &  
    \Block{}{Horas \\ Semanales\\ 1º Curso} & 
    \Block{}{Horas \\ Semanales\\ 2º Curso} & 
    \Block{}{Horas \\ Semanales\\ 3º Curso} \\
  0959. Sistemas eléctricos, neumáticos e hidráulicos. &
    140 &  4 &   & \\ 
  0960. Sistemas secuenciales programables. &
    160 & 5 & &\\ 
  0961. Sistemas de medida y regulación. &
    140 & & 4 & \\
  0962. Sistemas de potencia. & 190 & 6 && \\  
  0963. Documentación técnica. & 96 & & 3 & \\
  0964. Informática industrial. & 88 & &3 & \\ 
  0965. Sistemas programables avanzados. & 114 \\
  0966. Robótica industrial. & 90 & & 3 & \\ 
  0967. Comunicaciones industriales. & 165 & & 5 & \\ 
  0968. Integración de sistemas de automatización industrial. & 165 & & & 9 \\ 
  CLM0027. Inglés técnico para los ciclos formativos de grado superior de la familia profesional de electricidad y
  electrónica. & 
    64 & 2 & & \\ 
  0970. Formación y orientación laboral. &  82 & 3 \\
  0969. Proyecto de automatización y robótica industrial. & 40 \\
  0971. Empresa e iniciativa emprendedora. & 66 & & 2 \\
  0972. Formación en centros de trabajo. & 400 \\
 \Block[c,fill=[HTML]{95B3D7}]{}{Total} & \rowcolor[HTML]{FF7C80} 2000 & 20 & 20 & 15 \\ 
 \end{NiceTabular}

\end{document}

You need several compilations (because nicematrix uses PGF/TikZ nodes under the hood).

Output of the above code

1
  • Thanks for the quick answer! I've tried this method and it certainly removes the white lines of the table. But I'm not sure if the compilation time of Overleaf will hold before asking for a paid subscription. Nonetheless a very nice solution. Thanks a a lot!
    – Alquídreo
    Commented Apr 12 at 11:55
1

You code could be simplified a lot with tabularray:

\documentclass{article}
\usepackage{geometry}
\usepackage[spanish]{babel}
\usepackage{xcolor}
\definecolor{myorange}{HTML}{FABF8F}
\definecolor{mygreen}{HTML}{C4BD97}
\definecolor{mypink}{HTML}{E6B8B7}
\definecolor{myblue}{HTML}{95B3D7}
\definecolor{myred}{HTML}{FF7C80}
\usepackage{tabularray}

\begin{document}
\begin{longtblr}[
  caption={My table},
  label={tab:my-table}
  ]{
  colspec={Q[l,m]*4{Q[c,m]}},
  hlines, vlines,
  row{1,2}={myorange},
  row{3-Y}={1}{mygreen},
  row{3-Y}={2-Z}{mypink},
  cell{Z}{1}={myblue},
  cell{Z}{2-Z}={myred},
  rowhead=2,
  stretch=0,
  rowsep=4pt,
  }
  \SetCell[r=2]{m,c} Modulos& \SetCell[c=4]{m,c} Distribución de horas &&&\\ 
  &{Horas \\ totales} &  
    {Horas \\ Semanales\\ 1º Curso} & 
    {Horas\\ Semanales\\ 2º Curso} & 
    {Horas \\ Semanales\\ 3º Curso} \\
  {0959. Sistemas eléctricos, neumáticos\\  e hidráulicos.} &
    140 &  4 &   & \\ 
  0960. Sistemas secuenciales programables. &
    160 & 5 & &\\ 
  0961. Sistemas de medida y regulación. &
    140 & & 4 & \\
  0962. Sistemas de potencia. & 190 & 6 && \\  
  0963. Documentación técnica. & 96 & & 3 & \\
  0964. Informática industrial. & 88 & &3 & \\ 
  0965. Sistemas programables avanzados. & 114 & & & \\
  0966. Robótica industrial. & 90 & & 3 & \\ 
  0967. Comunicaciones industriales. & 165 & & 5 & \\ 
  {0968. Integración de sistemas \\ de automatización industrial.} & 165 & & & 9 \\ 
  {CLM0027. Inglés técnico para los ciclos \\ formativos de grado superior de la familia\\  profesional de electricidad y electrónica.} &
    64 & 2 & & \\ 
  0970. Formación y orientación laboral. &  82 & 3 & & \\ 
  {0969. Proyecto de automatización \\ y robótica industrial.} & 40 & & & \\ 
  0971. Empresa e iniciativa emprendedora. & 66 & & 2 & \\ 
  0972. Formación en centros de trabajo. & 400 & & & \\   
  0999. Just to show the multiple page. & 900 & & & \\ 
  0999. Just to show the multiple page. & 900 & & & \\ 
  0999. Just to show the multiple page. & 900 & & & \\ 
  0999. Just to show the multiple page. & 900 & & & \\ 
  0999. Just to show the multiple page. & 900 & & & \\ 
  0999. Just to show the multiple page. & 900 & & & \\ 
  0999. Just to show the multiple page. & 900 & & & \\ 
  0999. Just to show the multiple page. & 900 & & & \\ 
  0999. Just to show the multiple page. & 900 & & & \\ 
  0999. Just to show the multiple page. & 900 & & & \\ 
  0999. Just to show the multiple page. & 900 & & & \\ 
  0999. Just to show the multiple page. & 900 & & & \\ 
  0999. Just to show the multiple page. & 900 & & & \\ 
  0999. Just to show the multiple page. & 900 & & & \\ 
  0999. Just to show the multiple page. & 900 & & & \\ 
  0999. Just to show the multiple page. & 900 & & & \\ 
  0999. Just to show the multiple page. & 900 & & & \\ 
  0999. Just to show the multiple page. & 900 & & & \\ 
 \SetCell[c=1]{c}Total & 2000 & 20 & 20 & 15 \\ 
\end{longtblr}
\end{document}

enter image description here

8
  • Can tabularray allow the table to continue in different pages? I should've specified the fact of the position of this table in the page requires it to continue on the next one too. Still, for ones where I can fit them in one page, it also looks like a really great option. Thanks a lot too!
    – Alquídreo
    Commented Apr 12 at 11:57
  • @Alquídreo The environment longtblr that I used can continue on different pages.
    – CarLaTeX
    Commented Apr 12 at 12:09
  • Oh, that is nice to know then, thanks for the help, will keep it in mind if the compilation time from Overleaf doesn't screw with me!
    – Alquídreo
    Commented Apr 12 at 15:03
  • @Alquídreo I modified my MWE to show the multiple pages. The "continued" messages are highly customizable. It works on Overleaf: overleaf.com/read/njvbqwnjsygs#d57d6f. Maybe you'll reach the max compilation time if you have more tables like this in your document.
    – CarLaTeX
    Commented Apr 13 at 5:16
  • Oh, that is great! Didn't know the "Continued/Continues on next page" could be changed too! But yes, being part of a master's thesis, there are some amount of tables, some of them quite long unfortunately.
    – Alquídreo
    Commented Apr 13 at 12:24

You must log in to answer this question.

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