[Tex/LaTex] How to create a table that looks like an algorithm

algorithm2ealgorithmslongtabletables

Does anyone know how to create a table that looks like

enter image description here

The reason for doing this is that I am including a meta-procedure/pseudo-code that looks like algorithm, but not an actual algorithm i.e. no well defined for loops etc. and instead of referencing it as an algorithm using \autoref, I want to reference it as a table instead and preferably call it Table 1, instead of Algorithm 1.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{thmtools}       
\setlength\parindent{0pt}
\usepackage[linesnumbered,ruled]{algorithm2e}
\usepackage{hyperref}

\begin{document}


\section{Introduction}

{\LinesNumberedHidden
    \begin{algorithm}
        \SetKwInOut{Input}{Input}
        \SetKwInOut{Output}{Output}
        \SetAlgorithmName{Algorithm}{} 

        Initialize: $x^0$ = 0;
        \begin{enumerate}   
            \item Pour hot coal on $f(x)$
            \item Minimize $f(x)$
            \item Sketch $f(x)$ in Paint
        \end{enumerate}
        \caption{Meta-Coal Algorithm}
        \label{table:Coal Meta-Heuristic}
\end{algorithm}}


\bibliographystyle{plain}
\bibliography{references}
\end{document}

Best Answer

For not too sophisticated algorithms this is pretty straightforward with a normal table.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{thmtools}       
\usepackage{enumitem}
\usepackage[linesnumbered,ruled]{algorithm2e}
\usepackage{hyperref}

\usepackage{array}

\usepackage{booktabs}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}

\setlength\parindent{0em}

\begin{document}


\section{Introduction}

\begin{table}
  \stepcounter{table}
  \renewcommand{\arraystretch}{1.2}
  \begin{tabular}{*{1}{@{}L{10cm}}}
    \toprule
    \multicolumn{1}{@{}l}{\bfseries Algorithm \thetable\quad Meta - Coal Algorithm} \tabularnewline
    \bottomrule
    Initialize: $x^0$ = 0; \tabularnewline
    \begin{enumerate}[topsep=0pt]   
    \item Pour hot coal on $f(x)$
    \item Minimize $f(x)$
    \item Sketch $f(x)$ in Paint
    \end{enumerate}  
    \bottomrule
    \end{tabular}
    \addtocounter{table}{-1}
    \caption{Meta-Coal Algorithm}
    \label{table:Coal Meta-Heuristic}
\end{table}

See \autoref{table:Coal Meta-Heuristic}


\end{document}

enter image description here

Related Question