1

As the attached picture describe, this is what I am trying to replicate. Now the text does not need to be the same, since I am going to write different content inside but I really like the way this Figure is presented, with a title in between two lines.

enter image description here

Are they using a package I am missing or a strategy I am not aware of ?

  • It can be done with algorithm and algorithmicx packages. See this answer of mine: http://tex.stackexchange.com/a/163779/27635 – karlkoeller Mar 17 '15 at 12:09

2 Answers2

3

If you want to write an algorithm, see Write pseudo code in latex.

Here's an excerpt

\documentclass{article}
\usepackage{algorithm}
\usepackage{algpseudocode}

\begin{document}

\begin{algorithm}
\caption{An algorithm}\label{alg:myalgo}
\begin{algorithmic}
\State Hello!
\end{algorithmic}
\end{algorithm}

\end{document} 

enter image description here

If you want your figures to have that style, load the float package and issue:

\floatstyle{ruled}
\restylefloat{figure}

MWE:

\documentclass{article}
\usepackage{graphicx}
\usepackage{float}

\floatstyle{ruled}
\restylefloat{figure}

\begin{document}

\begin{figure}
  \centering
  \includegraphics[width=2cm]{example-image}
  \caption{A figure}\label{fig:myfig}
\end{figure}

\end{document} 

enter image description here

karlkoeller
  • 124,410
1

A main strategy is: first define all what you want and second, use it.

For example:

% definition

\def\algtitle#1\par{\removelastskip\bigskip\hrule
   \noindent\vrule height12pt depth5pt width0pt #1\par
   \hrule\nobreak\medskip
}
\def\begalg{\removelastskip\medskip
  \bgroup \parindent=0pt \tt \obeylines \obeyspaces  
          \everymath{\catcode`\ =10 \catcode`\^^M=5 }
}
\def\endalg{\egroup\medskip} 
{\obeyspaces\global\def {\ }}

% usage

\algtitle Algorithm 1 Sliding Window

\begalg
for $i$=1 to 4 do
   $S$ = $A_i \cup Q$
   $sw_i$ = $\displaystyle \max_{j=1\ldots|P|} \sum_{w=1\ldots|S|}
            \cases{IC(P_{j+w} & if $P_{j+w}\in S$ \cr
                   0          & otherwise}$
end for
return $sw_{1\ldots4}$
\endalg

\bye

The example uses plain TeX. Your question didn't specify the TeX format.

The result:

code

wipet
  • 74,238