Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

\theoremstyle{plain}
\newtheorem{algorithm}[equation]{Algorithm}

\begin{algorithm}
The folowing algorithm does something. This text should stay in italics.

\begin{codebox}
\Procname{$\proc{Do-Something}(x,y)$}
\li \Return $0$ \Comment{here italics should be disabled}
\end{codebox}

\end{algorithm}

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.

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

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:

\makeatletter
\g@addto@macro\code@init\normalfont
\makeatother

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

algorithm example

share|improve this answer
    
Wow, great, thank's for a super-quick response! Could you explain where exactly I should put the code snippet you wrote? –  Jasiu Jun 24 '11 at 19:48
    
@Jasiu: in the preamble of your document, after loading clrscode. –  Gonzalo Medina Jun 24 '11 at 19:52
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.