I am trying to color the background of the caption in algorithm (using algorithm2e
).
I have modified the original command as follow directly in the .sty file.
However, as you can see on the image, the result is not convenient. I would like the whole "row" to be in gray (I put row into brackets as it is not a tabular).
\newcommand{\algocf@makecaption@ruled}[2]{%
\global\sbox\algocf@capbox{\hskip\AlCapHSkip![enter image description here][2]
\parbox[t]{\hsize}{\colorbox{gray!50}{\algocf@captiontext{#1}{#2}}}}
}%
The original :
\newcommand{\algocf@makecaption@ruled}[2]{%
\global\sbox\algocf@capbox{\hskip\AlCapHSkip% .5\algomargin%
\parbox[t]{\hsize}{\algocf@captiontext{#1}{#2}}}
}%
The complete code :
\documentclass{article}
\usepackage{etex}
\usepackage{easybmat}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{xcolor}
\usepackage{algorithm2e}
\RestyleAlgo{algoruled}
\begin{document}
\SetKw{KwFrom}{from}
\newenvironment{algo}{
\begin{algorithm}[H]
\DontPrintSemicolon \SetAlgoVlined}
{\end{algorithm}}
\begin{algo}\label{algotrigsup}
\caption{Caption of the algo}
\For{$k$ \KwFrom $n-1$ \KwTo $1$}{
$x_k=b_k$\;
\For{$j$ \KwFrom $k+1$ \KwTo $n$}{
$x_k=x_k -a_{kj} x_j$\;
}
$x_k=\displaystyle \frac{x_k}{a_{kk}}$
}
\end{algo}
\end{document}
.sty
files..sty
file, save it with a different name and make the changes in the renamed file; of course, now you load the renamed package, not the original.