再次表格化。给单元格或表格着色的最佳方法是什么?问题是什么?

再次表格化。给单元格或表格着色的最佳方法是什么?问题是什么?

大家好(我很抱歉犯了英文错误)。

我在这里学到了很多东西。本周我学习了几种创建表格的方法,包括合并单元格,以及如何在其中添加颜色。然而,出于某种原因,生成相同表格的两种不同模型在单元格颜色、消失的单词或线条方面没有提供令人满意的结果。有没有办法使用这些相同的模板来解决这个问题?错误发生在什么时候?如何先为背景单元格着色?

在此处输入图片描述

谢谢大家。

这是我的 MWE

\documentclass[a4paper,brazil, 12pt]{report}
\usepackage[top=1.5cm,left=1.5cm,bottom=1.5cm,right=1.5cm ]{geometry}
\usepackage{mathpazo, amsmath,amsfonts,amscd,bezier, amssymb}
\usepackage{multirow}
\usepackage[table, x11names]{xcolor}
\usepackage{tabularx}
\usepackage{ragged2e}
\usepackage{hhline}
\usepackage{siunitx}
\usepackage{multicol}
\usepackage{booktabs}
\usepackage{float}
\usepackage{adjustbox}
\usepackage{graphicx}
\usepackage[portuguese]{babel}
\usepackage[utf8]{inputenc}
\usepackage{fourier}
\usepackage{tikz, tkz-euclide}
\usetkzobj{all}
\usetikzlibrary{quotes,angles}
\usepackage[american]{circuitikz}
\usetikzlibrary{arrows}
\usepackage{babel}
\usepackage{color}
\usepackage{hyperref}
\usepackage{enumerate}
\usepackage[shortlabels]{enumitem}
\usepackage{tasks}
\usepackage{float}
\usepackage{makecell}

\pgfdeclarelayer{background}
\pgfdeclarelayer{main}

\pgfsetlayers{background,main}

\newcolumntype{C}{>{\Centering}X}

\colorlet{slightgray}{LightSteelBlue3!25}%https://tex.stackexchange.com/questions/290912/horizontal-line-hline-inconsistent-behaviour
\begin{document}

\begin{table}[H]
    {\renewcommand\arraystretch{1.5}
        \setlength\arrayrulewidth{1.1pt}
        {\centering{
                \begin{tabular}{|c|c|c|c|c|c|c|}
                    \Xhline{1.2pt}%\hline
                    \multirow{ 2.1}{*} { \parbox[c][0.7cm]{2.0cm} {\centering \textbf{Question}}} & \multirow{ 2.1}{*} {\parbox[c][0.7cm]{1.95cm} {\centering $a)$}} & \multirow{2.1}{*} { \parbox[c][0.7cm]{1.95cm} {\centering  $b)$}}  & \multirow{2.1}{*} {\parbox[c][0.7cm]{1.95cm} {\centering  $c)$}} & \multirow{2.1}{*} {\parbox[c][0.7cm]{1.95cm} {\centering  $d)$}} & \multicolumn{2}{c|} {\parbox[c][0.7cm]{4.55cm}  {\centering \textbf{Score}}} \\ \cline{6-7}
                     & &  &  &  &  {\parbox[c][0.7cm]{2.3cm}  {\centering \textbf{Individual}}} & {\parbox[c][0.7cm]{2.25cm} {\centering \textbf{Team}}} \\ \hline
                 1. & & & & & &  \\ \hline
                     2. & & & & & &  \\ \hline
                    \multicolumn{5}{|c|}{\textbf{TOTAL}} & & \\ \hline
                \end{tabular}
    }}}
\end{table}

\begin{table}[H]
    {\renewcommand\arraystretch{1.5}
        \setlength\arrayrulewidth{1.1pt}
        {\centering{
                \begin{tabular}{|>{\columncolor{slightgray}}c|c|c|c|c|c|c|}
                    \Xhline{1.2pt}%\hline
                    \multirow{ 2.1}{*} { \parbox[c][0.7cm]{2.0cm} {\centering \textbf{Question}}} & \multirow{ 2.1}{*} {\parbox[c][0.7cm]{1.95cm} {\centering $a)$}} & \multirow{2.1}{*} { \parbox[c][0.7cm]{1.95cm} {\centering  $b)$}}  & \multirow{2.1}{*} {\parbox[c][0.7cm]{1.95cm} {\centering  $c)$}} & \multirow{2.1}{*} {\parbox[c][0.7cm]{1.95cm} {\centering  $d)$}} & \multicolumn{2}{c|} {\parbox[c][0.7cm]{4.55cm}  {\centering \textbf{Score}}} \\ \cline{6-7}
                    & &  &  &  &  {\parbox[c][0.7cm]{2.3cm}  {\centering \textbf{Individual}}} & {\parbox[c][0.7cm]{2.25cm} {\centering \textbf{Team}}} \\ \hline
                    1. & & & & & &  \\ \hline
                    2. & & & & & &  \\ \hline
                    \multicolumn{5}{|c|}{\textbf{TOTAL}} & & \\ \hline
                \end{tabular}
    }}}
\end{table}

\begin{table}[H]
    {\renewcommand\arraystretch{1.5}
        \setlength\arrayrulewidth{1.1pt}
        {\centering{
                \begin{tabular}{|>{\columncolor{slightgray}}c|c|c|c|c|c|c|}
                    \Xhline{1.2pt}%\hline
                    \rowcolor{slightgray}
                    \multirow{ 2.1}{*} { \parbox[c][0.7cm]{2.0cm} {\centering \textbf{Question}}} & \multirow{ 2.1}{*} {\parbox[c][0.7cm]{1.95cm} {\centering $a)$}} & \multirow{2.1}{*} { \parbox[c][0.7cm]{1.95cm} {\centering  $b)$}}  & \multirow{2.1}{*} {\parbox[c][0.7cm]{1.95cm} {\centering  $c)$}} & \multirow{2.1}{*} {\parbox[c][0.7cm]{1.95cm} {\centering  $d)$}} & \multicolumn{2}{c|} {\parbox[c][0.7cm]{4.55cm}  {\centering \textbf{Score}}} \\ \cline{6-7}
                    \rowcolor{slightgray} & &  &  &  &  {\parbox[c][0.7cm]{2.3cm}  {\centering \textbf{Individual}}} & {\parbox[c][0.7cm]{2.25cm} {\centering \textbf{Team}}} \\ \hline
                    1. & & & & & &  \\ \hline
                    2. & & & & & &  \\ \hline
                    \multicolumn{5}{|c|}{\cellcolor{slightgray} \textbf{TOTAL}} & & \\ \hline
                \end{tabular}
    }}}
\end{table}



\begin{table}[H]
    {\renewcommand\arraystretch{1.5}
        \setlength\arrayrulewidth{1.1pt}
        {\centering{
                \begin{tabular}{|c|c|c|c|c|c|c|}
                    \Xhline{1.2pt}%\hline
                    \multirow{ 2.1}{*} {\cellcolor{slightgray}} & \multirow{ 2.1}{*} {{\cellcolor{slightgray}}} & \multirow{2.1}{*} {{\cellcolor{slightgray}}} & \multirow{2.1}{*} {{\cellcolor{slightgray}}} & \multirow{2.1}{*} {{\cellcolor{slightgray}}} & \multicolumn{2}{c|} {\parbox[c][0.7cm]{4.55cm}  {\cellcolor{slightgray}\centering \textbf{Score}}} \\ \cline{6-7}
                    \multirow{ -1.9}{*} {\cellcolor{slightgray} \parbox[c][0.7cm]{2.0cm} {\centering \textbf{Question}}} &
                    \multirow{ -1.9}{*} {\cellcolor{slightgray}\parbox[c][0.7cm]{1.95cm} {\centering $a)$}} & \multirow{-1.9}{*} {{\cellcolor{slightgray}} \parbox[c][0.7cm]{1.95cm} {\centering  $b)$}} &\multirow{-1.9}{*} {{\cellcolor{slightgray}} \parbox[c][0.7cm]{1.95cm} {\centering  $c)$}} & \multirow{-1.9}{*} {{\cellcolor{slightgray}} \parbox[c][0.7cm]{1.95cm} {\centering  $d)$}} &  {\parbox[c][0.7cm]{2.3cm}  {\cellcolor{slightgray} \centering \textbf{Individual}}} & {\parbox[c][0.7cm]{2.25cm} {\cellcolor{slightgray} \centering \textbf{Team}}} \\ \hline
                    \cellcolor{slightgray} 1. & & & & & &  \\ \hline
                    \cellcolor{slightgray} 2. & & & & & &  \\ \hline
                    \multicolumn{5}{|c|}{\cellcolor{slightgray}\textbf{TOTAL}} & & \\ \hline
                \end{tabular}
    }}}
\end{table}

{\centering{
        {\renewcommand\arraystretch{1.5}
            \setlength\arrayrulewidth{1.1pt}
            \begin{tabularx}{\textwidth}{|>{\columncolor{slightgray}}c
                    |>{\hsize=1\hsize}C
                    |>{\hsize=1\hsize}C
                    |>{\hsize=1\hsize}C
                    |>{\hsize=1\hsize}C
                    |c|c|}
                \hline
                \rowcolor{slightgray}
                & & & & & \multicolumn{2}{c|}{Scores}\\ \hhline{*5{>{\arrayrulecolor{slightgray}}-}*{2}{>{\arrayrulecolor{black}}-}}
                \rowcolor{slightgray}
                \multirow{-2.2}{*}{\textbf{Question}} & \multirow{-2.2}{*}{$a)$} & \multirow{-2.2}{*}{$b)$} & \multirow{-2.2}{*}{$c)$} & \multirow{-2.2}{*}{$d)$} & \textbf{Individual} & \textbf{Team} \\
                \hline
                1. & & & & & & \\
                \hline
                2. & & & & & & \\
                \hline
                %\rowcolor{slightgray}
                \multicolumn{5}{|c|}{\cellcolor{slightgray} \textbf{TOTAL}} & & \\
                \hline
            \end{tabularx}
    }}%https://tex.stackexchange.com/questions/492140/help-to-tabular-how-to-set-different-sizes-of-cell-in-tabular-enviroment/492296#492296

\end{document}

答案1

这是一种可能性。请注意,对于交换图,最好使用tikz-cd代替amscd。此外,hyperref应作为最后一个包加载,只有极少数例外,并且您不应同时加载enumerateenumitem,以避免任何冲突。

\documentclass[a4paper, brazil, 12pt]{report}
\usepackage[margin=1.5cm ]{geometry}
\usepackage{mathpazo, amsmath,amsfonts,amscd,bezier, amssymb}
\usepackage{multirow}
\usepackage[table, x11names]{xcolor}
\usepackage{tabularx}
\usepackage{ragged2e}
\usepackage{hhline}
\usepackage{siunitx}
\usepackage{multicol}
\usepackage{booktabs}
\usepackage{float}
\usepackage{adjustbox}
\usepackage{graphicx}
\usepackage[portuguese]{babel}
\usepackage[utf8]{inputenc}
\usepackage{fourier}
\usepackage{tikz, tkz-euclide}
\usetkzobj{all}
\usetikzlibrary{quotes,angles}
\usepackage[american]{circuitikz}
\usetikzlibrary{arrows}
\usepackage{babel}
%\usepackage{color}
%\usepackage{enumerate}
\usepackage[shortlabels]{enumitem}
\usepackage{tasks}
\usepackage{float}
\usepackage{makecell}
\usepackage{hyperref}

\pgfdeclarelayer{background}
\pgfdeclarelayer{main}

\pgfsetlayers{background,main}

\newcolumntype{C}{>{\Centering\arraybackslash}X}

\colorlet{slightgray}{LightSteelBlue3!25}%https://tex.stackexchange.com/questions/290912/horizontal-line-hline-inconsistent-behaviour

\begin{document}

{\centering
\renewcommand\arraystretch{1.5}
 \setlength\arrayrulewidth{1.1pt}
 \begin{tabularx}{\textwidth}{|>{\columncolor{slightgray}}c|*{6}{C|}}
 \hline
 \rowcolor{slightgray}
 & & & & & \multicolumn{2}{c|}{Scores}\\%
\hhline{*5{>{\arrayrulecolor{black}}|>{\arrayrulecolor{slightgray}}-}>{\arrayrulecolor{black}}|-|-|}
  \rowcolor{slightgray}
 \multirow{-2.2}{*}{\textbf{Question}} & \multirow{-2.2}{*}{$a)$} & \multirow{-2.2}{*}{$b)$} & \multirow{-2.2}{*}{$c)$} & \multirow{-2.2}{*}{$d)$} & \textbf{Individual} & \textbf{Team} \\
 \hline
 1. & & & & & & \\
 \hline
 2. & & & & & & \\
 \hline
 \multicolumn{5}{|c|}{\cellcolor{slightgray} \textbf{TOTAL}} & & \\
 \hline
 \end{tabularx}
 }

 \end{document}

在此处输入图片描述

答案2

这样的图表/表格/彩色网格非常容易构建卡路里

\documentclass[a4paper, 12pt]{report}
\usepackage[margin=1.5cm ]{geometry}
\usepackage{mathpazo, cals}
\usepackage[table, x11names]{xcolor}

\colorlet{slightgray}{LightSteelBlue3!25}

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

\begin{document}

\begin{calstable}[c]
% Defining column relativ to each other and relativ to the margins
\colwidths{{\dimexpr(\columnwidth)/7\relax}
            {\dimexpr(\columnwidth)/7\relax}
            {\dimexpr(\columnwidth)/7\relax}
            {\dimexpr(\columnwidth)/7\relax}
            {\dimexpr(\columnwidth)/7\relax}
            }
% The tabular fills the text area if sum of all columns is 7

% Set up the tabular
\makeatletter
\def\cals@framers@width{0.4pt}   % Outside frame rules, reduce if the rule is too heavy
\def\cals@framecs@width{0.4pt}
\def\cals@bodyrs@width{1pt}
\cals@setpadding{Ag}
\cals@setcellprevdepth{Al}
\def\cals@cs@width{0.4pt}             % Inside rules, reduce if the rule is too heavy
\def\cals@rs@width{0.4pt}
\def\cals@bgcolor{}

\def\sgray{\ifx\cals@bgcolor\empty
    \def\cals@bgcolor{slightgray}
\else \def\cals@bgcolor{} \fi}

% R1H1
\thead{%
\brow
    \sgray\nc{lrt}
    \nc{lrt}
    \nc{lrt}
    \nc{lrt}
    \nc{lrt}
    \nc{ltb}
    \nc{rtb}\alignC\sc{Scores}\sgray
\erow
%R2H2
\brow
    \sgray\nc{lrb}\sc{\bfseries\vfil Questions}
    \nc{lrb}\alignC\sc{\vfil\itshape a)}
    \nc{lrb}\alignC\sc{\vfil\itshape b)}
    \nc{lrb}\alignC\sc{\vfil\itshape c)}
    \nc{lrb}\alignC\sc{\vfil\itshape d)}
    \alignC\cell{\bfseries Individual}
    \alignC\cell{\bfseries Team}\sgray
\erow
\mdseries
}
\tfoot{\lastrule\strut}
%R3B1
\brow
    \sgray\cell{1.}\sgray
    \cell{}
    \cell{}
    \cell{}
    \cell{}
    \cell{}
    \cell{}
\erow
% R4B2
\brow
    \sgray\cell{2.}\sgray
    \cell{}
    \cell{}
    \cell{}
    \cell{}
    \cell{}
    \cell{}
\erow
%R5B3
\brow
    \sgray\nc{ltb}
    \nc{tb}
    \nc{tb}
    \nc{tb}
    \nc{tb}
    \nc{rtb}\sc{\bfseries TOTAL}\sgray
    \cell{}
\erow
\makeatletter
\end{calstable}\par
\end{document}

在此处输入图片描述

相关内容