I have this piece of code:
\documentclass[11pt]{article}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{varwidth}
\begin{document}
\begin{algorithmic}
\Require \begin{varwidth}[t]{\linewidth}
A \par
AA
\end{varwidth}
\Ensure \begin{varwidth}[t]{\linewidth}
B \par
BB
\end{varwidth}
\end{algorithmic}
\end{document}
which yields
I would like the text which follows after \Ensure
to be indented in such a way that it is placed right under the text which follows after \Require
. How can this be done?
Best Answer
You can modify the definition of
\Ensure
to build a box as wide as Require:; you can do it globally or locally:Global
Local
Notice also the
\strut
at the end ofvarwidth
to get an even vertical spacing.