[Tex/LaTex] Normal font in theorem when typesetting algorithms


I'm using amsthm and clrscode to typeset algorithms. I'd like to have my algorithms numbered, so I do this:


The folowing algorithm does something. This text should stay in italics.

\li \Return $0$ \Comment{here italics should be disabled}


The plain theorem style has theorem name and number in bold, which I like, and the theorem statement in italic, which I also like. Unfortunately, in the case of an algorithm, the whole algorithm is typeset in italics and that looks very bad. So, for algorithms I'd like to turn off italics.

How do I do that? Is there any environment that I could use to temporarily disable italics only in codebox? If possible, I'd like to not create any new theorem style.

Best Answer

The macro \code@init is run at the beginning of a codebox environment. You can add \normalfont to it, which disables also the italic mode set before:


\normalfont resp. \code@init works locally here, so after the codebox ended the italic shape will be restored.

algorithm example