Hspace* does vertical space instead of horizontal space in algorithm block

algorithmicxhorizontal alignment

I tried to use the algorithmic package to write down a pseudo code.

\begin{algorithm}
   \caption{caption}
   \Require $n\in \N$, fixed time $T>0$
   \begin{algorithmic}[1]
        \State T        
   \end{algorithmic}
\end{algorithm}

Then I get the following output:enter image description here

So I tried adding the indent at Require so that it starts on a line with the rest and therefore I used the solution of this post (How to add input and output before algorithm procedure) and added \hspace*{\algorithmicindent}, i.e.

\begin{algorithm}
    \caption{caption}
    \hspace*{\algorithmicindent} \Require $n\in \N$, fixed time $T>0$
    \begin{algorithmic}[1]
        \State T
    \end{algorithmic}
\end{algorithm}

But instead of horizontal indent i get vertical indent: enter image description here

Since I don't get any error message either, I'm a bit lost as to why it misinterprets the command like that. Does anyone know what is going wrong here? Thanks in advance!

Best Answer

Presumably Require is starting a new paragraph so your \hspace* is not making vertical space it is making a single line paragraph with just a horizontal space

You would see the same if you used \hspace* before \section or \begin{quote}

Related Question