2

I have a problem with the coloured tables that I want to include in my master thesis, so it is a very important issue for me. I generate the tables with tablesgenerator.com, and in the LaTeX viewer they look amazing, but then in the PDF some lines just don't appear. If I zoom in the PDF, they appear again, but obviously anybody is going to read my TFM with a 200% of zoom. I have been reading some posts in this web and they say that it is because of the background color of the cells, that overlaps the lines, but I don't know how to fix it. I have read that some people use the command \setlength\arrayrulewidth{2pt}, and this solved my problem partially. The problem is that, obviously, I have to send my work to the teachers, and I don't know if they are going to be able to see the lines using this 2pt, or they would need more. That's why I think this is not a really good solution. I have read also that another people uses \tikz, but after having read many posts about it, I still don't know how I could implement this command specifically in my table, to draw the lines after the background.

This is my code:

\begin{table}[H]
%\setlength\arrayrulewidth{2pt}
\resizebox{\textwidth}{!}{%
\begin{tabular}{|l|c|c|c|}
\hline
\rowcolor[HTML]{C0C0C0} 
\multicolumn{4}{|c|}{\cellcolor[HTML]{C0C0C0}\textbf{TFM TASKS}} \\ \hline
\rowcolor[HTML]{EFEFEF} 
\textbf{Task} & \textbf{Description} & \textbf{Starting date} & \textbf{End date} \\ \hline
\rowcolor[HTML]{FFCCC9} 
\cellcolor[HTML]{FD6864}\textbf{Project start} & \begin{tabular}[c]{@{}c@{}}First meeting at which the project was planned (its \\ structure and the objectives to be achieved at the \\ end of the project).\end{tabular} & 30/11/18 & 30/11/18 \\ 
\hline
\rowcolor[HTML]{FDF0AD} 
\cellcolor[HTML]{F6DB53}\textbf{Theoretical analysis} & \begin{tabular}[c]{@{}c@{}}Initial study of the system based on the \\ documentation\end{tabular} & 01/12/18 & 23/12/18 \\ \hline
\rowcolor[HTML]{77CA5C} 
\multicolumn{4}{|c|}{\cellcolor[HTML]{77CA5C}\textbf{Matlab simulations}} \\ \hline
\rowcolor[HTML]{CFEAC6} 
\textbf{\begin{tabular}[c]{@{}l@{}}Development of \\ equations\end{tabular}} & \begin{tabular}[c]{@{}c@{}}The first equations were developed in Matlab, \\ verifying that the results from the University of \\ Rochester {[}REF{]} were obtained for the cases of 3 \\ and 4 lenses.  Later, the system was generalized for \\ the case of 5 lenses, obtaining the first problems.\end{tabular} & 24/12/18 & 10/01/19 \\ \hline
\rowcolor[HTML]{CFEAC6} 
\textbf{Meeting} & \begin{tabular}[c]{@{}c@{}}To comment on the progress made and try to solve \\ problems in simulations with Matlab.\end{tabular} & 31/01/19 & 31/01/19 \\ \hline
\rowcolor[HTML]{CFEAC6} 
\textbf{Meeting} & \begin{tabular}[c]{@{}c@{}}To compare the Matlab equations and try to find \\ the solution.\end{tabular} & 06/03/19 & 06/03/19 \\ \hline
\rowcolor[HTML]{CFEAC6} 
\textbf{Meeting} & \begin{tabular}[c]{@{}c@{}}Finally, we fixed the problem with the Matlab \\ equations.\end{tabular} & 08/04/19 & 08/04/19 \\ \hline
\rowcolor[HTML]{CDA7F6} 
\multicolumn{4}{|c|}{\cellcolor[HTML]{CDA7F6}\textbf{Zemax simulations}} \\ \hline
\rowcolor[HTML]{F2E7FD} 
\textbf{Zemax Installation} & \begin{tabular}[c]{@{}c@{}}We had some problems during the installation of the \\ program due to the Windows version of the computer.\end{tabular} & 01/01/19 & 03/03/19 \\ \hline
\rowcolor[HTML]{F2E7FD} 
\textbf{First steps with Zemax} & First days learning to use the program. & 25/03/19 & 30/03/19 \\ \hline
\rowcolor[HTML]{F2E7FD} 
\textbf{Meeting} & \begin{tabular}[c]{@{}c@{}}Skype meeting to clarify some doubts regarding \\ Zemax simulations.\end{tabular} & 27/04/19 & 27/04/19 \\ \hline


\end{tabular}%
}
\end{table} 

With this, in LaTeX, I obtain:

enter image description here

Nevertheless, in the PDF I obtain: enter image description here

It is very important that all lines appear in the Tables, because I have several ones that can't be understood if this happens. Therefore, I would greatly appreciate your help. Thank you.

  • 6
    Welcome to TeX.SX! This is a viewer issue. In some levels of zoom a line become thinner than a pixel of the screen. In that case some viewers render the pixel with the line, and some without. Not much you can do other than changin the viewer, printing the PDF, or making the line thicker. – Phelype Oleinik Jun 13 at 11:27
  • The problem is that, even making thicker, I have some tables where I have to use the command \cline, and that lines still don't appear in the PDF. – Yalifre Jun 13 at 11:44
  • Thank you, but I had already seen that post. The problem is that I don't understand how that code works, and as I have complicated tables with merged cells I don't know how to implement it. – Yalifre Jun 13 at 12:04
3

I tried to use hhline instead of \hline in the tabular, but it did not help much. You had to sett Adobe Reader to 300 per cent zoom to see the lines. I tried to change \rowcolor to \cellcolor, to see if that gave a better result. However, because you have nested tabular, \cellcolor did not colourised the overhang (side bearings) of the nested tabular, as you will see from the cell with light red colour.

enter image description here

Instead, I composed the tabular using cals. This was an ease match, and all the rules are visible (they are painted last). I tested all ranges from 20% to 1000%. If you move the definition of the table to the preamble, it act as a style sheet and work for all calstables. In the tables preambles you can then fine tune the tabular for specific needs.

If you have several similar colourised tables, where it is important to have visible lines, I recommend to change to cals. It is easy to use when you first has learned it and perfect for your type of tabulars.

\documentclass{article}
\usepackage{cals, xcolor}
\usepackage[left=3cm, right=3cm]{geometry}

\let\nc=\nullcell                   % Shortcuts
\let\sc=\spancontent

\definecolor{darkgray}{HTML}{C0C0C0} 
\definecolor{lightgray}{HTML}{EFEFEF} 
\definecolor{darkred}{HTML}{FD6864} 
\definecolor{lightred}{HTML}{FFCCC9} 
\definecolor{darkyellow}{HTML}{F6DB53} 
\definecolor{lightyellow}{HTML}{FDF0AD} 
\definecolor{darkgreen}{HTML}{77CA5C} 
\definecolor{lightgreen}{HTML}{CFEAC6} 
\definecolor{darkviolet}{HTML}{CDA7F6} 
\definecolor{lightviolet}{HTML}{F2E7FD} 

\makeatletter
\def\cals@framers@width{0.4pt}      % Outside frame rules, reduce if the rule is too heavy
\def\cals@framecs@width{0.4pt}
\cals@setpadding{Ag}
\def\cals@cs@width{0.4pt}           % Inside rules, reduce if the rule is too heavy
\def\cals@rs@width{0.4pt}
\def\cals@bodyrs@width{0.4pt}       % The rule between title and body
\def\cals@bgcolor{}                 % Define cals@bgcolor to empty

\def\gray{\ifx\cals@bgcolor\empty   % Gray colour switch (on-off)
    \def\cals@bgcolor{darkgray}
\else \def\cals@bgcolor{} \fi}

\def\lgray{\ifx\cals@bgcolor\empty  % Light gray colour switch (on-off)
    \def\cals@bgcolor{lightgray}
\else \def\cals@bgcolor{} \fi}

\def\red{\ifx\cals@bgcolor\empty    % Red colour switch (on-off)
    \def\cals@bgcolor{darkred}
\else \def\cals@bgcolor{} \fi}

\def\lred{\ifx\cals@bgcolor\empty   % Light red colour switch (on-off)
    \def\cals@bgcolor{lightred}
\else \def\cals@bgcolor{} \fi}

\def\yellow{\ifx\cals@bgcolor\empty   % Yellow colour switch (on-off)
    \def\cals@bgcolor{darkyellow}
\else \def\cals@bgcolor{} \fi}

\def\lyellow{\ifx\cals@bgcolor\empty  % Light yellow colour switch (on-off)
    \def\cals@bgcolor{lightyellow}
\else \def\cals@bgcolor{} \fi}

\def\green{\ifx\cals@bgcolor\empty    % Green colour switch (on-off)
    \def\cals@bgcolor{darkgreen}
\else \def\cals@bgcolor{} \fi}

\def\lgreen{\ifx\cals@bgcolor\empty   % Light green colour switch (on-off)
    \def\cals@bgcolor{lightgreen}
\else \def\cals@bgcolor{} \fi}

\def\violet{\ifx\cals@bgcolor\empty   % Violet colour switch (on-off)
    \def\cals@bgcolor{darkviolet}
\else \def\cals@bgcolor{} \fi}

\def\lviolet{\ifx\cals@bgcolor\empty  % Light violet colour switch (on-off)
    \def\cals@bgcolor{lightviolet}
\else \def\cals@bgcolor{} \fi}

\def\bb{\ifx\cals@borderB\relax     % Botton border switch (off-on)
    \def\cals@borderB{0pt}
\else \let\cals@borderB\relax\fi}

\def\lb{\ifx\cals@borderL\relax     % Left border switch (off-on)
    \def\cals@borderL{0pt}
\else \let\cals@borderL\relax\fi}

\def\rb{\ifx\cals@borderR\relax     % Right border switch (off-on)
    \def\cals@borderR{0pt}
\else \let\cals@borderR\relax\fi}

\def\lp{\ifdim\cals@paddingL=0.0pt\relax    % Left padding switch (off-on)
    \cals@setpadding{Ag}
\else \setlength{\cals@paddingL}{0pt}\fi}

\makeatother                        % Reset meaning of \@

\begin{document}

\begin{table}        % remove if the calstable is multipage
\footnotesize
\begin{calstable}[c] % Centred between the margin, not necessary 
                     % when the tabular spans the whole \columnwidth

% Defining 4 columns relative to each other and relative to the margins
\colwidths{{\dimexpr(\columnwidth/40*8)\relax}
            {\dimexpr(\columnwidth/40*20)\relax}
            {\dimexpr(\columnwidth/40*6)\relax}
            {\dimexpr(\columnwidth/40*6)\relax}
            }
% The total sum has to be 40 for the tabular to use available space between the margins

% Set up the tabular
% In case you need specific tweeks
% \makeatletter


% R1 Heading
\thead{\bfseries
\brow
    \gray\nc{ltb}
    \nc{tb}
    \nc{tb}
    \nc{rtb}\alignC\sc{\vfil TFM TASKS\strut}\gray
\erow
% R2 Head
\brow
    \lgray\alignL\cell{\vfil Task\strut}
    \alignC\cell{\vfil Description\strut}
    \cell{\vfil Starting date\strut}
    \cell{\vfil End date\strut}\lgray
\erow
\mdseries
}        % Heading spans two rows

% Footer, if the tabular will span more than one page
\tfoot{\lastrule\nointerlineskip
      \textit{\strut The table continues on the next page%
       }\par%
 }

% R3 Body
\brow
    \red\alignL\cell{\vfil\bfseries Project start}\red
    \lred\alignC\cell{\vfil First meeting at which the project was planned (its structure and the objectives to be achieved at the end of the project)}
    \cell{\vfil 30/11/18}
    \cell{\vfil 30/11/18}\lred
\erow
% R4 Body
\brow
    \yellow\alignL\cell{\vfil\bfseries Theoretical analysis}\yellow
    \lyellow\alignC\cell{\vfil Initial study of the system based on the documentation}
    \cell{\vfil 01/12/18}
    \cell{\vfil 23/12/18}\lyellow
\erow
% R5 Body
\brow
    \green\nc{ltb}
    \nc{tb}
    \nc{tb}
    \nc{rtb}\alignC\sc{\vfil\bfseries Mathlab simulations}\green
\erow
% R6 Body
\brow
    \lgreen\alignL\cell{\vfil\bfseries Development of\\equations}
    \alignC\cell{\vfil The first equations were developed in Matlab, verifying that the results from the University of Rochester {[}REF{]} were obtained for the cases of 3 and 4 lenses.  Later, the system was generalized for the case of 5 lenses, obtaining the first problems.}
    \cell{\vfil 24/12/18}
    \cell{\vfil 10/01/19}
\erow
% R7 Body
\brow
    \alignL\cell{\vfil\bfseries Meeting}
    \alignC\cell{\vfil To comment on the progress made and try to solve \\ problems in simulations with Matlab.}
    \cell{\vfil 31/01/19}
    \cell{\vfil 31/01/19}
\erow
% R8 Body
\brow
    \alignL\cell{\vfil\bfseries Meeting}
    \alignC\cell{\vfil To compare the Matlab equations and try to find \\ the solution.}
    \cell{\vfil 06/03/19}
    \cell{\vfil 06/03/19}
\erow
% R9 Body
\brow
    \alignL\cell{\vfil\bfseries Meeting}
    \alignC\cell{\vfil Finally, we fixed the problem with the Matlab \\ equations.}
    \cell{\vfil 08/04/19}
    \cell{\vfil 08/04/19}\lgreen
\erow
% R10 Body
\brow
    \violet\nc{ltb}
    \nc{tb}
    \nc{tb}
    \nc{rtb}\alignC\sc{\vfil\bfseries Zemax simulations}\violet
\erow
% R11 Body
\brow
    \lviolet\alignL\cell{\vfil\bfseries Zemax Installation}
    \alignC\cell{\vfil We had some problems during the installation of the \\ program due to the Windows version of the computer.}
    \cell{\vfil 01/01/19}
    \cell{\vfil 03/03/19}
\erow
% R12 Body
\brow
    \alignL\cell{\vfil\bfseries First steps with Zemax}
    \alignC\cell{\vfil First days learning to use the program.}
    \cell{\vfil 25/03/19}
    \cell{\vfil 30/03/19 }
\erow
% R13 Body
\brow
    \alignL\cell{\vfil\bfseries Meeting}
    \alignC\cell{\vfil Skype meeting to clarify some doubts regarding \\ Zemax simulations.}
    \cell{\vfil 27/04/19}
    \cell{\vfil 27/04/19}\lviolet
\erow
\makeatletter
\end{calstable}\par % \par needed to align the tabular
\end{table} 
\end{document}

enter image description here

0

Here is a alternative using a tikz matrix. (Please note that the alignment of some of the cells is different from the image in the question. I was also not able to get the \multicolumn-like "sub-headers")

enter image description here

\documentclass{article}
\usepackage{geometry}

\usepackage{tikz}
\usetikzlibrary{matrix}

\usepackage{xcolor}
\definecolor{mygray}{HTML}{C0C0C0}
\definecolor{mylightgray}{HTML}{EFEFEF}
\definecolor{myred}{HTML}{FD6864}
\definecolor{mylightred}{HTML}{FFCCC9}
\definecolor{myyellow}{HTML}{F6DB53}
\definecolor{mylightyellow}{HTML}{FDF0AD}
\definecolor{mygreen}{HTML}{77CA5C}
\definecolor{mylightgreen}{HTML}{CFEAC6}
\definecolor{mypurple}{HTML}{CDA7F6}
\definecolor{mylightpurple}{HTML}{F2E7FD}



\begin{document}

\begin{center}
\small
\begin{tikzpicture}[cell/.style={rectangle,draw=black}, nodes in empty cells]
  \matrix(table)[
  matrix of nodes,
  row sep =-\pgflinewidth,
  column sep = -\pgflinewidth,
  nodes={anchor=base,text height=2ex,text depth=0.5ex},
  column 1/.style = {nodes={cell, align=left,      text width=0.15\textwidth, font=\bfseries}},
  column 2/.style = {nodes={cell, align=left,      text width=0.57\textwidth                 }},
  column 3/.style = {nodes={cell, align=center,    text width=0.1\textwidth                  }},
  column 4/.style = {nodes={cell, align=center,    text width=0.1\textwidth                  }},
     row 1/.style = {nodes={cell,                                     fill=mygray                     }},
     row 2/.style = {nodes={cell, text height=1em, text depth=1.25em, fill=mylightgray, font=\bfseries}},
     row 3/.style = {nodes={cell, text height=1em, text depth=2.5em,  fill=mylightred                 }},
     row 4/.style = {nodes={cell, text height=1em, text depth=1.25em, fill=mylightyellow              }},
     row 5/.style = {nodes={cell, text height=1em, text depth=1.25em, fill=mygreen                    }},
     row 6/.style = {nodes={cell, text height=1em, text depth=5em,    fill=mylightgreen               }},
     row 7/.style = {nodes={cell, text height=1em, text depth=1.25em, fill=mylightgreen               }},
     row 8/.style = {nodes={cell, text height=1em, text depth=1.25em, fill=mylightgreen               }},
     row 9/.style = {nodes={cell,                                     fill=mylightgreen               }},
     row 10/.style= {nodes={cell, text height=1em, text depth=1.25em, fill=mypurple                   }},
     row 11/.style= {nodes={cell, text height=1em, text depth=1.25em, fill=mylightpurple              }},
     row 12/.style= {nodes={cell, text height=1em, text depth=1.25em, fill=mylightpurple              }},
     row 13/.style= {nodes={cell, text height=1em, text depth=1.25em, fill=mylightpurple              }},
  ] 
  {
  TMF Tasks &  &  &  \\
  Task & Description & Starting Date & End Date \\
  |[fill=myred]| Project Start 
      & First meeting at which the project was planned (its structure and the objectives to be achieved at the end of the project). 
      & 30/11/18 & 30/11/18 \\
  |[fill=myyellow]| Theoretical Analysis 
      & Initial study of the system based on the  documentation 
      & 01/12/18 & 23/12/18 \\
  Matlab Simulations &  &  &  \\
  Development of equations 
      & The first equations were developed in Matlab, verifying that the results from the University of Rochester {[}REF{]} were obtained for the cases of 3 and 4 lenses.  Later, the system was generalized for  the case of 5 lenses, obtaining the first problems. 
      & 24/12/18 & 10/01/19 \\
  Meeting 
      & To comment on the progress made and try to solve  problems in simulations with Matlab. 
      & 31/01/19 & 31/01/19 \\ 
  Meeting 
      & To compare the Matlab equations and try to find  the solution. 
      & 06/03/19 & 06/03/19 \\ 
  Meeting 
      & Finally, we fixed the problem with the Matlab  equations. 
      & 08/04/19 & 08/04/19 \\
  Zemax simulations &  &  &   \\ 
  Zemax Installation 
      & We had some problems during the installation of the program due to the Windows version of the computer. 
      & 01/01/19 & 03/03/19 \\ 
  First steps with Zemax 
      & First days learning to use the program. 
      & 25/03/19 & 30/03/19 \\ 
  Meeting 
      & Skype meeting to clarify some doubts regarding  Zemax simulations. 
      & 27/04/19 & 27/04/19 \\
  };
\end{tikzpicture}
\end{center}
\end{document}

Personally, I'd prefer a less colorful look using no vertical lines and teh horizonta lines from the booktabs package. I'd also reommend using tabularx in order to get automated linebreaks in cells.

enter image description here

\documentclass{article}
\usepackage{geometry}

\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{ragged2e}


\begin{document}

\noindent
\begin{tabularx}{\textwidth}{@{\quad\quad}>{\RaggedRight}p{2cm}>{\RaggedRight}Xcc}
\toprule
  TMF Tasks &  &  &  \\ 
  Task & Description & Starting Date & End Date \\
\midrule
   \multicolumn{1}{@{}l}{\textit{Project Start}} 
      & First meeting at which the project was planned (its structure and the objectives to be achieved at the end of the project). 
      & 30/11/18 & 30/11/18 \\
\midrule
   \multicolumn{1}{@{}l}{\textit{Theoretical Analysis}} 
      & Initial study of the system based on the  documentation 
      & 01/12/18 & 23/12/18 \\
\midrule
  \multicolumn{4}{@{}l}{\textit{Matlab Simulations}}   \\
  Development of equations 
      & The first equations were developed in Matlab, verifying that the results from the University of Rochester {[}REF{]} were obtained for the cases of 3 and 4 lenses.  Later, the system was generalized for  the case of 5 lenses, obtaining the first problems. 
      & 24/12/18 & 10/01/19 \\
\addlinespace
  Meeting 
      & To comment on the progress made and try to solve  problems in simulations with Matlab. 
      & 31/01/19 & 31/01/19 \\
\addlinespace 
  Meeting 
      & To compare the Matlab equations and try to find  the solution. 
      & 06/03/19 & 06/03/19 \\ 
\addlinespace
  Meeting 
      & Finally, we fixed the problem with the Matlab  equations. 
      & 08/04/19 & 08/04/19 \\
\midrule
  \multicolumn{4}{@{}l}{\textit{Zemax simulations}}    \\ 
  Zemax Installation 
      & We had some problems during the installation of the program due to the Windows version of the computer. 
      & 01/01/19 & 03/03/19 \\
\addlinespace
  First steps with Zemax 
      & First days learning to use the program. 
      & 25/03/19 & 30/03/19 \\ 
\addlinespace
  Meeting 
      & Skype meeting to clarify some doubts regarding  Zemax simulations. 
      & 27/04/19 & 27/04/19 \\
\bottomrule
\end{tabularx}
\end{document}

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.