[Tex/LaTex] How to add the algorithm block in textblock

algorithmserrorsfloats

I'm creating a poster and I have a problem to adjust the algorithm block inside of textblock.

My code is in below with the packages and the code.

\documentclass[a0,portrait]{a0poster}

\pagestyle{empty}
\setcounter{secnumdepth}{0}

\usepackage[absolute]{textpos}

\usepackage{ae}                         %% Font Encoding T1 (PDF)
\usepackage{lscape}                     %% Utilizar página em landscape
\usepackage{url}                        %% Trata URLs, e-mails e paths
\usepackage{float}
%\usepackage[num]{abntcite}
\usepackage[pdftex]{graphicx,color}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}
\usepackage[position=top]{subfig}
\usepackage{url}
\usepackage[T1]{fontenc}
\usepackage{amsmath,amssymb,amsfonts,textcomp}
\usepackage{color}
\usepackage{fancyhdr}
\usepackage[font={normal,it}]{caption}
\usepackage{fancyvrb}
\usepackage{algorithm}
\usepackage{algorithmic}    
\usepackage{multirow}
\usepackage{textfit}
\usepackage{rotating}
\usepackage{boxedminipage}
\usepackage{setspace}
\usepackage{multicol}
\usepackage{subfig}
\usepackage{tikz}
\usepackage[a0paper,left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
%=========- Color -===========================================%
\usepackage{color}
\definecolor{DarkBlue}{rgb}{0.1,0.1,0.5}
\definecolor{Red}{rgb}{0.9,0.0,0.1}
\definecolor{DarkGreen}{rgb}{0.10,0.50,0.10}

%=========- Command -======================================%
\let\Textsize\normalsize
\def\Head#1{\noindent\hbox to \hsize{\hfil{\LARGE\color{DarkBlue} #1}}\bigskip}
\def\LHead#1{\noindent{\LARGE\color{DarkBlue} #1}\smallskip}
\def\Subhead#1{\noindent{\large\color{DarkBlue} #1}}
\newcommand{\quiteHuge}{\fontsize{70.3}{93}\selectfont}

\def\Title#1{\begin{center}\noindent{\quiteHuge\color{DarkBlue}\textbf{#1}}\end{center}}

\TPGrid[40mm,40mm]{14}{25}  % 4 - 1 - 4 - 1 - 4 Columns
\parindent=0pt
\parskip=0.5\baselineskip
%================Begin===================================%
\begin{document}
\begin{textblock}{4.2}(0,3.6)
  \begin{algorithm}[H]
    \caption{Calculate $Q_{ij}$}\label{alg:calcqij}
    \begin{algorithmic}[1]
      \REQUIRE $\tau>0,A\ne\emptyset,N=|A|$
      \ENSURE $Q_{ij}(\Delta t)\sum_{t\in A} e^{-\frac{|t-\delta t|}{\tau}}, \forall t\in A$
      \STATE $\mathbf{A}\Leftarrow\mathrm{sort}(A)\;\{O(N\log N)\}$
      \STATE $Q^-(1)\Leftarrow 1$
      \STATE $Q^+(N)\Leftarrow 0$
      \FOR{$k=1$ \TO $N-1$}
      \STATE  $ed(k)\Leftarrow e^{-\frac{\mathbf{A}(k+1)-\mathbf{A}(k)}{\tau}}$
      \ENDFOR
      \FOR{$k=1$ \TO $N-1$}
      \STATE $Q^-(k+1)\Leftarrow 1+Q^-(k)\cdot ed(k)$
      \STATE $Q^+(N-k)\Leftarrow (Q^+(N-k+1)+1)\cdot ed(N-k)$
      \ENDFOR
      \FOR{$k=1$ \TO $N$}
      \STATE $Q_{ij}(A(k))\Leftarrow Q^+(k)+Q^-(k)$
      \ENDFOR
    \end{algorithmic}
    \end{algorithm}  %====ERROR LINE====%
\end{textblock} 
\end{document}

Always I have the message error about the float column width.

Undefined control sequence. \endalgorithm …oatbox \global \setbox
\@currbox
\float@makebox \columnwidt… l.82 \end{algorithm}
The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled
it (e.g., \hobx'), typeI' and the correct spelling (e.g.,
`I\hbox'). Otherwise just continue, and I'll forget about whatever was
undefined.

Anyone have some idea how can I fix this problem?

If you have some question let me know.

Thank you.

Best Answer

textpos's \textblock is meant to place content in a fixed location on the current page. As such, you shouldn't store content that can float inside of it, even if the float package offers a non-floating, stay right [H]ere float specifier. Instead, you can fool TeX to think it's working with a float by using

\captionof{algorithm}{<your caption here>}

which is provided by caption. Alternatively, the minute capt-of package provides similar functionality. So, your document structure should rather resemble:

\begin{textblock}{4.2}(0,3.6)
  \captionof{algorithm}{Calculate $Q_{ij}$\label{alg:calcqij}}
  \begin{algorithmic}[1]
    %...
  \end{algorithmic}
\end{textblock}
Related Question