2

Following this question, I used the solution in my document as follows but as you can see in the output, the algorithms do not start and end at the same levels. Is there a way I can make the algorithms start and end at the same level?

EDIT - It is OK if the algorithms don't end at the same level, I would just like them to start at the same level. If solutions exist for both scenarios, it would be great if you post them.

\documentclass{article}
\usepackage{algorithm}
\usepackage{algorithmic}

\begin{document}

\begin{minipage}{0.45\textwidth}
\begin{algorithm}[H]
\caption{BLAH}
\begin{algorithmic}[1]
\REQUIRE $Input$
\ENSURE $A$.
\STATE
\STATE 
\STATE Set $AA$
\STATE 
\STATE
\STATE
\STATE
\STATE
\STATE
\end{algorithmic}
\end{algorithm}
\end{minipage}
\hfill
\begin{minipage}{0.45\textwidth}
\begin{algorithm}[H]
\caption{BLAH}
\begin{algorithmic}[1]
\REQUIRE $Input$
\STATE Compute $B$
\end{algorithmic}
\end{algorithm}
\end{minipage}

\end{document}

Output

  • 'H is not a float specifier out of the box. Why do you even have a float inside of a minipage? what is the purpose of this? – daleif Nov 19 '18 at 15:45
  • The algorithms were being used in a document without minipage initially. Now, I decided to use minipage to reduce document length. Following your comment, if I remove H from the code above, I receive errors. Also, are you just wondering my usage of H or did you just suggest a possible solution? Either way, not using H didn't help. – Rudra Nov 19 '18 at 15:50
3

The minipages have a t (top) option, so in both minipages

\begin{minipage}[t]{0.45\textwidth} 

produce this:

mwe

  • Is there an option to end them at the same level as well? – Rudra Nov 19 '18 at 16:02
  • With respect to the minipages, yes: chage [t] by [t][8cm][t] and put the minipages in a \fbox{} to check it. – Fran Nov 19 '18 at 16:09
0

If I want to end the algorithms at the same level I can use the solution posted here to add blank lines in the smaller algorithm i.e adding \item[] to the smaller algorithm will do

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.