1

I tried to make one table in LaTeX however my code doesn't work, do have any idea to solve this?

\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage{colortbl}
\usepackage{arydshln}

\begin{table}
\centering
\begin{tabular}{|l|ll:ll:ll:ll|} 
\hline
\rowcolor[rgb]{0.753,0.753,0.753} \multicolumn{1}{|c|}{{\cellcolor[rgb]{0.753,0.753,0.753}}} & \multicolumn{8}{c|}{\textbf{Meses}} \\ 
\cline{2-9}
\rowcolor[rgb]{0.753,0.753,0.753} \multicolumn{1}{|c|}{\multirow{-2}{*}{{\cellcolor[rgb]{0.753,0.753,0.753}}\textbf{Actividad}}} & \multicolumn{2}{c|}{\textbf{1}} & \multicolumn{2}{c|}{\textbf{2}} & \multicolumn{2}{c|}{\textbf{3}} & \multicolumn{2}{c|}{4} \\ 
\cline{1-8}
Revisión del Marco Teórico y Estudios Previos & \multicolumn{2}{l:}{{\cellcolor[rgb]{0.753,0.753,0.753}}} &  &  &  &  &  &  \\ 
\cline{1-1}
Estudio de la Metodología &  & \multicolumn{2}{l}{{\cellcolor[rgb]{0.753,0.753,0.753}}} &  &  &  &  &  \\ 
\cline{1-1}
Elaboración y Análisis de datos &  &  &  & \multicolumn{2}{l}{{\cellcolor[rgb]{0.753,0.753,0.753}}} &  &  &  \\ 
\cline{1-1}
Estimación de los Modelos &  &  &  &  & \multicolumn{2}{l:}{{\cellcolor[rgb]{0.753,0.753,0.753}}} &  &  \\ 
\cline{1-1}
Análisis de los Resultados &  &  &  &  &  & \multicolumn{2}{l}{{\cellcolor[rgb]{0.753,0.753,0.753}}} &  \\ 
\cline{1-1}
Versión Final del Estudio &  &  &  &  &  &  & \multicolumn{2}{l|}{{\cellcolor[rgb]{0.753,0.753,0.753}}} \\
\hline
\end{tabular}
\end{table}

My objective is replicate this:

enter image description here

3
  • Welcome to TeX.SE! Please extend/complete your code fragment to complete compilable document beginning with \documentclass and ending with \end{document}, which reproduce your problem.
    – Zarko
    Oct 19, 2020 at 0:02
  • would it be better to use gantt chart for this
    – js bibra
    Oct 19, 2020 at 0:55
  • @NaldoChavez please have a look at the answer below if it meets the requirement
    – js bibra
    Oct 19, 2020 at 7:00

1 Answer 1

1

With the excellent nicematrix package and the tikz overlap -- completed in about 4 hours -- the coloring may not be as desired in the columns but I think the code is fairly easy to understand

the red!15 can be varied to a darker shade by increasing the percentage of opacity to 30% by writing red!30

the width of the column colors can be varied by the column and row numbers--

(row-3-|col-2) -- (row-3-|col-4)

means draw a line(invisible) starting from the intersection of row3 with column2 -- the line is drawn upto the intersection of row3 with column4

--(row-4-|col-4)--(row-4-|col-2)-- cycle

thereafter the same line(invisible) moves down to the intersection of row4 with column4 and then to intersection of row4 with column2

enter image description here

\documentclass{article}
\usepackage{nicematrix}
\usepackage{tikz}
\usepackage{booktabs}
\usepackage{xcolor,colortbl}


\begin{document}

    \begin{NiceTabular}{*{9}l}[
    code-before=
    \rowcolor{blue!30}{1,2}
    {
        \tikz \draw [draw=none, fill = red!15]
        (row-3-|col-2) -- (row-3-|col-4)--(row-4-|col-4)--(row-4-|col-2)-- cycle ;
        \tikz \draw [draw=none, fill = green!15]
        (row-4-|col-3) -- (row-4-|col-5)--(row-5-|col-5)--(row-5-|col-3)-- cycle ;
        \tikz \draw [draw=none, fill = yellow!15]
        (row-5-|col-4) -- (row-5-|col-6)--(row-6-|col-6)--(row-6-|col-4)-- cycle ;
        \tikz \draw [draw=none, fill = black!15]
        (row-6-|col-6) -- (row-6-|col-7)--(row-7-|col-7)--(row-7-|col-6)-- cycle ;
        \tikz \draw [draw=none, fill = red!15]
        (row-7-|col-7) -- (row-7-|col-8)--(row-8-|col-8)--(row-8-|col-7)-- cycle ;
        \tikz \draw [draw=none, fill = blue!15]
        (row-8-|col-8) -- (row-8-|col-9)--(row-9-|col-9)--(row-9-|col-8)-- cycle ;
        \tikz \draw [dashed]
        (row-3-|col-4) -- (row-9-|col-4);
        \tikz \draw [dashed]
        (row-3-|col-6) -- (row-9-|col-6);
        \tikz \draw [dashed]
        (row-3-|col-8) -- (row-9-|col-8);
        \tikz \draw [dashed]
        (row-3-|col-10) -- (row-9-|col-10);
        \tikz \draw [dashed]
        (row-3-|col-2) -- (row-9-|col-2);
    }
    ]
    \toprule[2pt]
    \Block{2-1}{\textbf{Actividad}}  & \Block{1-8}{\textbf{Meses}}  &&&&&&& \\  \cmidrule{2-9}
                         & \Block{1-2}{\textbf{1}} && \Block{1-2}{\textbf{2}} & &\Block{1-2}{\textbf{3}} && \Block{1-2}{\textbf{4}}& \\     \midrule
    Revisión del Marco Teórico y Estudios Previos &&&&&&&&\\ 
    \cmidrule(){1-1}
    Estudio de la Metodología &&&&&&&&\\
    \cmidrule(){1-1}
    Elaboración y Análisis de datos &&&&&&&&\\
    \cmidrule(){1-1}
    Estimación de los Modelos &&&&&&&&\\
    \cmidrule(){1-1}
    Análisis de los Resultados &&&&&&&&\\
    \cmidrule(){1-1}
    Versión Final del Estudio &&&&&&&&\\
    \bottomrule[2pt]
\end{NiceTabular}\\    
\end{document}
3
  • Hello js bibra, First of all thank you for your answer. I copied your code literally but it is extrange because it doesn't work. I'm working in Overleaf Latex Oct 24, 2020 at 23:45
  • @Naldo Chavez. If you use Overleaf, you have to upload in your Overleaf project the latest version of the file nicematrix.sty available here : https:www.tug.org/svn/texlive/trunk/Master/texmf-list/tex/latex/nicematrix/nicematrix.sty. Nov 18, 2020 at 12:22
  • May I suggest that you accept the answer if it meets the requirements set forth in your question The compatibility with overleaf can be taken up as a separate question Please note that compatibility with overleaf was not stated in the original question
    – js bibra
    Nov 18, 2020 at 12:23

You must log in to answer this question.

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