TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use algorithm/algorithmic packages to write some pseudocode. The width of the box spans across the entire page and I was wondering if there is any way to constrain it (since the actual code doesn't exceed the mid of the page). Practically, I want to wrap text around my pseudocode.

ps: I tried wrapfig package, but I had some problems. Would be also helpful if anyone could verify whether this approach works.

Any ideas ?

share|improve this question

migrated from stackoverflow.com Dec 12 '11 at 10:15

This question came from our site for professional and enthusiast programmers.

Don't forget about TeX - LaTeX; LaTeX is odd enough that you'd be better served asking in a community dedicated to LaTeX and TeX. (I've flagged for moderator attention to migrate, but in case the mod doesn't migrate -- we do have LaTeX questions here, in any case -- just know it's available.) – sarnold Dec 12 '11 at 8:27
Welcome to TeX.sx! Your question was migrated here from another StackExchange site. Please register on this site, too, and make sure that both accounts are associated with each other, otherwise you won't be able to comment on or accept answers or edit your question. :) – Paulo Cereda Dec 12 '11 at 10:28

You can put the algorithm inside of a minipage, put that inside of the wrapfigure, and it should work like a charm.

        \caption{assignment algorithm}
          \STATE i $\leftarrow$ j

And the result:

Wrapped algorithm

You might want to tweak the alignment modifier on the minipage to get vertical alignment to work out a little better. Alternatively, you can play with the optionial lineheight of wrapfigure.

share|improve this answer
Could one modify this to work with Algorithm2e? – JeremyKun May 7 '15 at 17:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.