表格中的颜色

表格中的颜色

由于一张表格,我无法继续我的论文。我想给它上色,但如果没有任何帮助,我就会遇到一些麻烦。有人可以帮忙吗?

\usepackage{graphicx}
\usepackage{colortbl}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{ltablex}
\usepackage{ragged2e}
\usepackage{changepage}
\newlength{\offsetpage}
\setlength{\offsetpage}{1.0cm}
\newenvironment{widepage}{\begin{adjustwidth}{-\offsetpage}{-\offsetpage}%
\addtolength{\textwidth}{2\offsetpage}}%
{\end{adjustwidth}}
\usepackage{colortbl}
\newcommand{\undepth}[1]{%
\smash[b]{%
\begin{varwidth}[t]{\linewidth}#1\end{varwidth}
}%
}
\documentclass[12pt,a4paper,oneside,openright]{book}
\begin{document}
\begin{table}[htbp]
\centering
\caption{Fattori che influenzano i recovery rate}
\label{tab:componenticr+}
\begin{widepage}


\begin{tabular} 
{p{0.15\textwidth}|p{0.15\textwidth}|p{0.3\textwidth}|p{0.3\textwidth}} 
\toprule
\rowcolor[rgb]{ .188,  .329,  .588} \multicolumn{4}{|c|}{\textcolor[rgb]{ 1,  1,  1}{\textbf{CreditRisk+}}} \\
        \midrule
        \multicolumn{2}{c|}{\vspace{0.05cm} Misure per il Rischio di Credito \vspace{0.05cm}}&Capitale Economico&Applicazioni\\
        \midrule
        \rowcolor[rgb]{ .867,  .922,  .969}  Esposizione&\undepth{Tasso di\\ Default}&\multirow{2}{*}{\undepth{Default\vspace{0.3cm}\\  Distribuzione di perdita}}&Approvvigionamento\\  \cline{1-2}\cline{4-4}
        \rowcolor[rgb]{ .867,  .922,  .969} \vspace{0.03cm} \undepth{Tassi di\\ recupero}& \vspace{0.03cm} Volatilità PD&& \vspace{0.03cm} Limiti\\
        \midrule
        \rowcolor[rgb]{ .867,  .922,  .969}     \multicolumn{2}{c|}{\vspace{0.05cm} CreditRisk+ Model}&Analisi di scenario&Gestione di portafoglio\\
        \bottomrule
    \end{tabular}
\end{widepage}
\end{table}
\end{document}

答案1

像这样?

在此处输入图片描述

在对您的代码进行大量清理之后……

\documentclass[12pt,a4paper,oneside,openright]{book}
\usepackage{graphicx}
%\usepackage{colortbl}
\usepackage[table]{xcolor}          % rather use instead of "colortbl"
\usepackage{booktabs,
            cellspace,              % added
            ltablex,                % it load "longtable" and "tabularx"
            multirow}
\setlength\cellspacetoplimit{5pt}   % added
\setlength\cellspacebottomlimit{5pt}% added
\usepackage{ragged2e}
\usepackage{changepage}
\newlength{\offsetpage}
\setlength{\offsetpage}{1.0cm}
\newenvironment{widepage}{\begin{adjustwidth}{-\offsetpage}{-\offsetpage}%
\addtolength{\textwidth}{2\offsetpage}}%
{\end{adjustwidth}}
%\usepackage{colortbl} % loaded second time ...
%\newcommand{\undepth}[1]{% doesn't work, in this mwe is not useded
%\smash[b]{%
%\begin{varwidth}[t]{\linewidth}#1\end{varwidth}
%}%
%}
\begin{document}
    \begin{table}[htbp]
\caption{Fattori che influenzano i recovery rate}
\label{tab:componenticr+}
    \centering
    \setlength{\arrayrulewidth}{0.8pt} % increase \hline thickness
    \setlength{\tabcolsep}{4pt}
\begin{widepage}
\begin{tabularx}{\linewidth}{Sl l X X}
    %\toprule  % looks ugly
    \hline
    \rowcolor[rgb]{.188, .329, .588}
    \multicolumn{4}{Sc}{\textcolor{white}{\textbf{CreditRisk+}}} \\
%    \midrule  % looks ugly
    \hline
\multicolumn{2}{Sc}{Misure per il Rischio di Credito}
        &   Capitale Economico
            &   Applicazioni            \\
%    \midrule  % looks ugly
    \hline
\rowcolor[rgb]{.867, .922, .969}
Esposizione
    &   Tasso di Default
        &   &   Approvvigionamento      \\
    \cline{1-2}\cline{4-4}
\rowcolor[rgb]{ .867,  .922,  .969}
Tassi di recupero
    &   Volatilità PD
        &   \multirow{-2}{=}{Default  Distribuzione di perdita}
            &   Limiti                  \\
    \hline
\rowcolor[rgb]{.867, .922, .969}
\multicolumn{2}{Sc}{CreditRisk + Model}
    &   Analisi di scenario
        &   Gestione di portafoglio     \\
%    \bottomrule
    \hline
    \end{tabularx}
\end{widepage}
\end{table}
\end{document}

相关内容