I would like the algorithm (in ruled style) appear below the rules, in the center and without a rule below itself.
with the following code:
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{algorithmic}
\usepackage[linesnumbered,ruled]{algorithm2e}
\makeatletter
\newenvironment{Ualgorithm}[1][htpb]{\def\@algocf@post@ruled{\kern\interspacealgoruled\hrule height\algoheightrule\kern3pt\relax}%
\def\@algocf@capt@ruled{under}
\begin{algorithm}[#1]}
{\end{algorithm}}
\makeatother
\begin{document}
\begin{Ualgorithm}[H]
\SetAlgoLined
\KwData{this text}
\KwResult{Write here the result }
initialization\;
\While{While condition}{
instructions\;
\eIf{condition}{
instructions1\;
instructions2\;
}{
instructions3\;
}
}
\caption{How to write algorithms}
\end{Ualgorithm}
\end{document}
and this is about what I would like to have
plus I would like to have the whole space between the rules colored (with the same color every time).
Is there a way to do these changes to the code? Thanks for your suggestions.