Now that I converted all my theorems to mdframed, I'd like a consistent layout for my algorithms as well? What ways are there to typeset pseudocode algorithms in mdframed?

So far I've been using algorithm.sty from the algorithms bundle, together with algpseudocode.sty from the algorithmicx. But since that looks completely different, and has problems with cleveref as well, I'm looking for alternatives.

algorithm2e on its own looks nice enough, but since that comes with its own float environment, I get an error Not in outer par mode when I try to plug that into an mdframed theorem environment.

does not insist on outer par mode, but so far I haven't managed to get that working directly inside a frame either. For some reason, I get a lot of error messages I didn't get before, like label names having an extra }, or like destination with the same identifier (name{ALG@line.2}) has been already used, duplicate ignored.

In an ideal world, a suitable solution would offer

  • References for the whole algorithm as well as individual lines
  • Flexible line numbering
  • Flexible syntax formatting
  • Allow page breaks withing algorithms
  • Other bells and whistles to make things look nice
  • 1
    I do think algorithmic bundle w/wo the algorithmicx can do the job, filling all your requirements. – cacamailg May 11 '13 at 15:29
  • @cacamailg: You are right, things look good now. I've been looking for the wrong package to blame: having algorithm and cleveref both loaded as well will break things, without mdframed being in any way involved. – MvG May 11 '13 at 15:51
  • Not a duplicate, I'd say: the main conflict was between algorithms and cleveref, without regard for hyperref, since I already had cleveref after hyperref, thanks to an answer by egreg. And just because the currently accepted answer uses the packages I already mentioned, I'd still love to hear about other alternatives, like perhaps some way to put an algorithm2e-style layout with lines and all those bells and whistles into an mdframed environment. – MvG May 14 '13 at 13:54

I haven't managed to get [] working directly inside a frame either.

I was wrong in assuming that was to blame: it was interfering. When that detects a package called algorithm, it will try to modify its code, apparently breaking things for . By not including that package, things worked a lot better.

At some point, I had the impression that I needed the algorithm package in order to get some of my symbols defined. I can't reproduce this any more, but if anyone should really need that package, here is a package loading order which seems to work as well, since it prevents from interfering with :

  1. hyperref
  2. cleveref
  3. algorithm
  4. algpseudocode
| improve this answer | |

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.