When using algorithm2e package in some cases latex does not preserve a font type.
E.g.:
\If{$r^\texttt{b}>0$}{}
is printed exactly the same as
\If{$r^b>0$}{}
Can anyone help how to solve this?
BR,
Greg.
Text Formatting ⇒ Lost formatting in algorithm2e
Lost formatting in algorithm2e
Last edited by gregsa on Wed Jan 12, 2011 9:02 pm, edited 1 time in total.
NEW: TikZ book now 40% off at Amazon.com for a short time.

Lost formatting in algorithm2e
You need to provide a minimal working example which shows the problem. If I simply do:
Then I get this:
And those are clearly not the same. (Perhaps you wanted an upright typewriter font; then you could use \texttt{\textup{b}}.)
Code: Select all
\documentclass{article}
\usepackage{algorithm2e}
\begin{document}
\begin{algorithm}
\If{$r^\texttt{b}>0$}{}
\If{$r^b>0$}{}
\end{algorithm}
\end{document}
And those are clearly not the same. (Perhaps you wanted an upright typewriter font; then you could use \texttt{\textup{b}}.)
Re: Lost formatting in algorithm2e
1. Many thanks for your help. It solved my problem!
2. Sorry for not providing a min. working example, as I should.
3. I was not aware that a typewriter font can be other than upright, so I did not see the difference you show in my document. Really. Maybe a small font size had something to do with it
4. Thanks again.
2. Sorry for not providing a min. working example, as I should.
3. I was not aware that a typewriter font can be other than upright, so I did not see the difference you show in my document. Really. Maybe a small font size had something to do with it

4. Thanks again.
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Lost formatting in algorithm2e
Now that the problem is solved, please be so kind and mark the topic (not the last post) accordingly as clearly written in the Board Rules (to be read before posting). Please keep that in mind for the future so that further reminders will not be necessary.
Thorsten
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10