如何让算法栏变短?
\begin{algorithm}[H]
\caption{Exact Invariant Simulator}
\begin{algorithmic}[H] \label{alg:eisim}
\FOR{$r \in \{1,2,...,R\}$}
\STATE Sample $\theta_i^{(1,r)}$ from $\theta_i\sim p(\theta_i)$
\STATE Sample $Y^{(1,r)}\sim p(\cdot|\theta_i^{(1,r)})$
\FOR{$s \in \{2,3,..,S\}$}
\STATE Sample $\theta_i^{(s,r)}$ from $\theta_i\sim K_i(\cdot|\theta_{-i}^{(s-1,r)})$
\ENDFOR
\STATE Calculate test statistic $T(\theta^{(S,r)}, Y^{(S,r)})$ \footnotemark
\ENDFOR
\end{algorithmic}
\end{algorithm}
这给出
但是黑线太长了。如何让它变短?
答案1
我承认错误。你可以将 [H] 浮动元素放入迷你页面中。
\documentclass{article}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{showframe}
\begin{document}
\noindent\hfil\begin{minipage}{0.6\textwidth}
\begin{algorithm}[H]
\caption{Exact Invariant Simulator} \label{alg:eisim}
\begin{algorithmic}
\FOR{$r \in \{1,2,...,R\}$}
\STATE Sample $\theta_i^{(1,r)}$ from $\theta_i\sim p(\theta_i)$
\STATE Sample $Y^{(1,r)}\sim p(\cdot|\theta_i^{(1,r)})$
\FOR{$s \in \{2,3,..,S\}$}
\STATE Sample $\theta_i^{(s,r)}$ from $\theta_i\sim K_i(\cdot|\theta_{-i}^{(s-1,r)})$
\ENDFOR
\STATE Calculate test statistic $T(\theta^{(S,r)}, Y^{(S,r)})$ \footnotemark
\ENDFOR
\end{algorithmic}
\end{algorithm}
\end{minipage}
\end{document}