0

I would like to hide the Algorithm environment as shown in the attached pic below. That is please remove "Algorithm 8.1" which is highlighted in blude.

enter image description here

The code is provided below:

 \begin{algorithm}\label{al:8.1}\end{algorithm}
\begin{center}
    \begin{tabular}{| l ||l| }
        \hline
        \multicolumn{2}{|l|}{\textbf{ Algorithm \ref{al:8.1}: Obtaining weights (Off-line)}} \\
        \hline
        \textbf{INPUT } &  $\omega_{k}^{j}, (k<m)$, $\phi(l,k)$, $H_l^j$, $R_l^j$ \\
        \hline
        \textbf{OUTPUT} & $\omega_{k}^{j} (k\geq m)$ \\
        \hline
        1 & \textbf{INITIALIZE } $\omega_{k}^{j}, (k<m)$ \\
        \hline
        2 & \textbf{FOR} each $k\geq m$ \textbf{DO} OP \ref{op:8.1} \\
        \hline
        3 & \textbf{STORE} $\omega_{k}^{j}$ \\
        \hline
        4 & $k$ $\gets$ $k+1$ \\
        \hline
        5 & \textbf{GOTO} 2\\
        \hline
        6 & \textbf{END}\\
        \hline
    \end{tabular} 
\end{center}

Please help!

1 Answer 1

1

You do not need the tabular environment to specify an algorithm in LaTex. Use some packages like and . Here is an example of the algorithm in your picture, where the definition of the for each loop comes from here https://tex.stackexchange.com/a/149166.

\documentclass{article}

\usepackage{algpseudocode}
\usepackage{algorithm}
\usepackage{hyperref}

\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}

\algnewcommand{\Initialize}[1]{%
  \State \textbf{Initialize} #1
}

\algnewcommand{\Store}[1]{%
  \State \textbf{Store} #1
}

\algnewcommand{\Goto}[1]{%
  \State \textbf{Goto} #1
}

% for each loop
% based on: https://tex.stackexchange.com/a/149166
\algnewcommand\algorithmicforeach{\textbf{for each}}
\algdef{S}[FOR]{ForEach}[1]{\algorithmicforeach\ #1\ \algorithmicdo}

% algorithm number based on section
\counterwithin{algorithm}{section}

\begin{document}
% set section number to 8
\setcounter{section}{8}

\begin{algorithm}
    \caption{Obtaining weights (Off-line)}
    \label{alg:8.1}
    \begin{algorithmic}[1]
        \Require{$\omega_{k}^{j}, (k<m)$, $\phi(l,k)$, $H_l^j$, $R_l^j$}
        \Ensure{$\omega_{k}^{j} (k\geq m)$}
        \Initialize{$\omega_{k}^{j}, (k<m)$}
        \ForEach{$k \geq m$}\label{alg:8.1_line2}
            \State{OP~\ref{op:8.1}}
        \EndFor
        \Store{$\omega_{k}^{j}$}
        \State{$k$ $\gets$ $k+1$}
        \Goto{Line~\ref{alg:8.1_line2}}
    \end{algorithmic}
\end{algorithm}

% to have a reference for op:8.1
\begin{algorithm}
    \caption{\dots}
    \label{op:8.1}
\end{algorithm}
\end{document}

Output result

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .