0

I can't go on with my thesis because of a table. Id like to colour this but without any help I'm facing some trouble. Anyone could help?

\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}
Jordan_b
  • 283
  • 2
    Can you please make a compilable minimal working example (MWE) that includes all packages necessary for your code? – samcarter_is_at_topanswers.xyz May 08 '18 at 17:05
  • Possible duplicate of https://tex.stackexchange.com/questions/112671/define-and-use-new-colors-for-rowcolor-colortbl?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa or at least some good hints. – albert May 08 '18 at 17:06
  • 3
    While you wait for an answer to this question, can you go back to your previous ones and look if the answers solve your problems and accept them, if they do? – samcarter_is_at_topanswers.xyz May 08 '18 at 17:12
  • 2
    ..."Id like to colour this" -- please be a bit more specific as to what you're trying to achieve. – Mico May 08 '18 at 17:18
  • 1
    (i) welcome to tex.se! (ii) \documetclass{...} had to be first in your document example; (iii) remove all to your problem irrelevant packages; (iv) booktabs and vertical lines doesn't work well together (also coloring table rows not); (v) your example has errors. please correct them. – Zarko May 08 '18 at 17:23

1 Answers1

1

like this?

enter image description here

after the heavy cleaning of your code ...

\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}
Zarko
  • 296,517
  • 1
    @A_Bed, you should consider my comment below your question and correct all what i suggest you. if you like answer, you can accept it (by clicking on check mark at top left side of answer). so far you not accept any received answer ... – Zarko May 08 '18 at 18:51