我想隐藏算法环境,如下图所示。也就是说,请删除以蓝色突出显示的“算法 8.1”。
代码如下:
\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}
请帮忙!
答案1
你不需要tabular
环境来指定算法LaTex
。使用一些包,如算法和算法伪代码。这是图片中算法的一个例子,其中的定义对于每个循环来自这里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}