# How to change the rule color in cals table

I make a table using cals package, I want to modify the width of the table using colwidths , when I rewrite the value in this code:\colwidths{{\dimexpr(\columnwidth)/34*4\relax}, the table widen to the right ,how could I make it widen to the left and right? And if I want to change the rule color to the RGB:221, 216, 195, how could I modify the code? Here is my code

\documentclass[a4paper, 11pt, UTF8]{ctexrep}
\usepackage[T1]{fontenc}
\usepackage{ctex}
\usepackage{etoolbox}
\usepackage{cals, caption}
\usepackage[svgnames]{xcolor}
\definecolor{st_table_blue}{RGB}{87, 142, 210}
\definecolor{gridcolor}{RGB}{221, 216, 195}

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

\begin{document}

\begin{table}
\caption{A table\label{tabelTable}}

\begin{calstable}[c]
%\arrayrulecolor{gridcolor}

% Defining columns relative to each other and relative to the margins
\colwidths{{\dimexpr(\columnwidth)/34*4\relax}
{\dimexpr(\columnwidth)/34*12\relax}
{\dimexpr(\columnwidth)/34*6\relax}
{\dimexpr(\columnwidth)/34*6\relax}
%{\dimexpr(\columnwidth)/34*6\relax}
{\dimexpr(\columnwidth)/25*6\relax}
}
% The tabular fills the text area if sum of all columns is 6

% Set up the tabular
\makeatletter
%\def\cals@framers@width{0.2pt}
\def\cals@framers@width{0.2pt}    % Outside frame rules, reduce if the rule is too heavy
\def\cals@framecs@width{0.2pt}
\def\cals@framers@color{gridcolor}
\def\cals@bgcolor{}
\def\cals@AtBeginCell{\vfil}             % Ensure that all cells is vertically centred

\def\lblue{\ifx\cals@bgcolor\empty     % "Switch" to turn on and off colour
%\def\cals@bgcolor{LightSteelBlue}
\def\cals@bgcolor{st_table_blue}
\else \def\cals@bgcolor{} \fi}

% R1H1
\brow
\lblue\nc{lrt}
\nc{ltb}
\nc{tb}
\nc{lrt}
\erow
%R2H2
\brow
\nc{lrb}\alignC\sc{Text}
%\cell{\bfseries\textcolor{white}{Subheading is long and that wraps}}
\cell{\bfseries\textcolor{white}{FDA/NMPA\\批准于本癌种}}
\cell{Short}
\nc{lrb}\alignC\sc{Text}\lblue
\erow
\mdseries}
\tfoot{\lastrule\strut}
%R3B1
\brow
\alignC\cell{Wrapping text}

%\cell{Horiz. and vertic. centred}
\alignC\cell{阿法替尼*，达克替尼*， 奥西替尼*，吉非替尼*，埃克替尼*，厄洛替尼*，阿美替尼*}
\cell{2}
\cell{3}
\cell{1}
\erow
%R3B1
\brow
\alignC\cell{1}
\cell{2}
\cell{2}
\cell{3}
\cell{1}
\erow
\makeatletter
\end{calstable}
\end{table}

\end{document}


and the result is as picture I want the picture like this

• The xcolor package provides the necessary commands to produce tables with alternate row colors, when loaded with the table option. The command \rowcolors{<''starting row''>}{<''odd color''>}{<''even color''>} has to be specified right before the tabular environment starts.
– user108724
Apr 15, 2020 at 6:23
• tex.stackexchange.com/a/50377/108724
– user108724
Apr 15, 2020 at 6:26
• @C.F.G I want to change the border color not the cell color Apr 15, 2020 at 6:47
• \usepackage{xcolor,colortbl}  then \arrayrulecolor{red}.
– user108724
Apr 15, 2020 at 8:38

Hope the below modified MWE meets your requirement:

\documentclass[a4paper, 11pt, UTF8]{ctexrep}
\usepackage[T1]{fontenc}
\usepackage{ctex}
\usepackage{etoolbox}
\usepackage{cals, caption}
\usepackage[svgnames]{xcolor}
\definecolor{st_table_blue}{RGB}{87, 142, 210}
\definecolor{gridcolor}{RGB}{221, 216, 195}

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

\begin{document}
\makeatletter
\renewcommand\cals@cs@outOne[3]{%
\ifx \relax#1%
\else
\cals@withColorII\cals@bgcolor{#3}\iftrue
\textcolor{\cals@color}{\vrule depth0pt width#1 }%
\hskip -#1\relax
\fi
\fi
\cals@withWidthII\cals@cs@width{#2}\iftrue
\cals@halfWidthToDimen0 \cals@width %
\hskip -\dimen0 %
\color{white}\vrule depth0pt width\cals@width\relax
\hskip -\dimen0 %
\fi
\let\cals@lastLeftWidth=\cals@width
\ifx \relax#1\else \hskip#1 \fi
}

\renewcommand\cals@rs@sofar@out{%
\ifdim 0pt=\cals@rs@sofar@width\relax
\hskip\cals@rs@sofar@length\relax
\else
\cals@halfWidthToDimen0\cals@rs@sofar@borderl
\hskip-\dimen0\relax
\cals@halfWidthToDimen2\cals@rs@sofar@borderr
\dimen4=\cals@rs@sofar@length\relax
\cals@halfWidthToDimen6\cals@rs@sofar@width
\color{white}\vrule height\dimen6 depth\dimen6 width\dimen4\relax
\hskip-\dimen2\relax
\fi}
\makeatother

\begin{table}
\caption{A table\label{tabelTable}}

\begin{calstable}[c]

% Defining columns relative to each other and relative to the margins
\colwidths{{\dimexpr(\columnwidth)/34*4\relax}
{\dimexpr(\columnwidth)/34*12\relax}
{\dimexpr(\columnwidth)/34*6\relax}
{\dimexpr(\columnwidth)/34*6\relax}
%{\dimexpr(\columnwidth)/34*6\relax}
{\dimexpr(\columnwidth)/25*6\relax}
}
% The tabular fills the text area if sum of all columns is 6

% Set up the tabular
\makeatletter
%\def\cals@framers@width{0.2pt}
\def\cals@framers@width{0.2pt}    % Outside frame rules, reduce if the rule is too heavy
\def\cals@framecs@width{0.2pt}
\def\cals@framers@color{gridcolor}
\def\cals@bgcolor{}
\def\cals@AtBeginCell{\vfil}             % Ensure that all cells is vertically centred

\def\lblue{\ifx\cals@bgcolor\empty     % "Switch" to turn on and off colour
%\def\cals@bgcolor{LightSteelBlue}
\def\cals@bgcolor{st_table_blue}
\else \def\cals@bgcolor{} \fi}

% R1H1
\brow
\lblue\nc{lrt}
\nc{ltb}
\nc{tb}
\nc{lrt}
\erow
%R2H2
\brow
\nc{lrb}\alignC\sc{Text}
%\cell{\bfseries\textcolor{white}{Subheading is long and that wraps}}
\cell{\bfseries\textcolor{white}{FDA/NMPA\\??????}}
\cell{Short}
\nc{lrb}\alignC\sc{Text}\lblue
\erow
\mdseries}
\tfoot{\lastrule\strut}
%R3B1
\brow
\alignC\cell{Wrapping text}

%\cell{Horiz. and vertic. centred}
\alignC\cell{????*,????*, ????*,????*,????*,????*,????*}
\cell{2}
\cell{3}
\cell{1}
\erow
%R3B1
\brow
\alignC\cell{1}
\cell{2}
\cell{2}
\cell{3}
\cell{1}
\erow
\makeatletter
\end{calstable}
\end{table}

\end{document}


Output

• Thanks. it works for me.But I have another trouble, if I want to modify the width of the table, I modify colwidths , when I rewrite the value in this code, the table widen to the right ,how could I make it widen to the left and right？@MadyYuvi Apr 15, 2020 at 16:00
• @GuoFengWang How you increase the width? Can you post a revised MWE? Apr 16, 2020 at 14:39
• @GuoFengWang Also may I know why you use this table format particularly? As it can be done easily by using normal tabular Apr 16, 2020 at 14:40
• I modify the value in this code \colwidths{{\dimexpr(\columnwidth)/34*4\relax} {\dimexpr(\columnwidth)/34*12\relax} {\dimexpr(\columnwidth)/34*6\relax} {\dimexpr(\columnwidth)/34*6\relax} %{\dimexpr(\columnwidth)/34*6\relax} {\dimexpr(\columnwidth)/25*6\relax} }, I use this format cause when I use tabular, the text in the table can not be centered vertically and horizontally @MadyYuvi Apr 16, 2020 at 15:11