1

I have some Latex (below) which renders the algorithm environment with centered text:

enter image description here

This doesn't match the wikibooks Latex documentation, which shows a left-aligned block.

enter image description here

I'd rather not post all my Latex, since it's a big document, but I've tried to include relevant info below. Any help is appreciated!

My Latex

\documentclass[preprint]{imsart}

\RequirePackage[OT1]{fontenc}
\RequirePackage{amsthm,amsmath,amssymb}
\RequirePackage[round]{natbib}
\RequirePackage[colorlinks,citecolor=blue,urlcolor=blue]{hyperref}
\RequirePackage{fullpage}
\RequirePackage{todonotes}
\RequirePackage{bm}
\RequirePackage{booktabs}
\RequirePackage{comment}
\RequirePackage{subcaption}
\RequirePackage{algorithm}
\RequirePackage[noend]{algpseudocode}
\RequirePackage{tcolorbox}
\RequirePackage{enumitem}

\usepackage{macros}
\usepackage[]{algorithm2e}

...

\begin{document}

...

\subsection{This is a title}

This is some text.

\begin{algorithm}[H]
 \KwData{this text}
 \KwResult{how to write algorithm with \LaTeX2e }
 initialization\;
 \While{not at end of this document}{
  read current\;
  \eIf{understand}{
   go to next section\;
   current section becomes this one\;
   }{
   go back to the beginning of current section\;
  }
 }
 \caption{How to write algorithms}
\end{algorithm}

...

\end{document}

1 Answer 1

1

Looked like the algorithm and algpseudocode packages were messing with the algorithm2e package. The fix is to use just algorithm2e.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .