如何正确放置平板电脑格式

如何正确放置平板电脑格式

我尝试用 LaTeX 制作一个表格,但是我的代码不起作用,有什么办法可以解决这个问题吗?

\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}

我的目标是复制这个:

在此处输入图片描述

答案1

凭借出色的nicematrix包装和tikz重叠——大约 4 个小时就完成了——列中的颜色可能不如人意,但我认为代码相当容易理解

可以red!15通过将不透明度百分比增加到 30% 来改变为更深的色调,方法是:red!30

列颜色的宽度可以根据列数和行数变化——

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

表示从第 3 行与第 2 列的交叉点开始画一条线(不可见),该线一直画到第 3 行与第 4 列的交叉点

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

此后,同一线(不可见)向下移动到第 4 行与第 4 列的交叉点,然后移动到第 4 行与第 2 列的交叉点

在此处输入图片描述

\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}

相关内容