I would like to color the horizontal lines of the
algorithm
environment from the algorithms package. Is there a way I can do this?Thanks so much!
Carlos
algorithm
environment from the algorithms package. Is there a way I can do this?NEW: TikZ book now 40% off at Amazon.com for a short time.
algorithm
environment. So it would be necessary to do modifications to those mechanisms. At the moment I have no idea how.algorithm
float:Code: Select all
\documentclass{article}
\usepackage{algorithmic,algorithm}
\usepackage{xcolor}
\makeatletter
% this is a copy of the original \fs@ruled but with {\color{blue} ... } added:
\newcommand\fs@coloruled{\def\@fs@cfont{\bfseries}\let\@fs@capt\floatc@ruled
\def\@fs@pre{{\color{blue}\hrule height.8pt depth0pt }\kern2pt}%
\def\@fs@post{\kern2pt{\color{blue}\hrule}\relax}%
\def\@fs@mid{\kern2pt{\color{blue}\hrule}\kern2pt}%
\let\@fs@iftopcapt\iftrue}
\makeatother
% now use the new style:
\floatstyle{coloruled}
\restylefloat{algorithm}
\begin{document}
% let's see if it works:
\begin{algorithm}
\caption{Calculate $y = x^n$}
\label{alg1}
\begin{algorithmic}
\REQUIRE $n \geq 0 \vee x \neq 0$
\ENSURE $y = x^n$
...
\end{algorithmic}
\end{algorithm}
\end{document}
NEW: TikZ book now 40% off at Amazon.com for a short time.