Text FormattingLost formatting in algorithm2e

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
gregsa
Posts: 6
Joined: Wed Sep 01, 2010 1:12 pm

Lost formatting in algorithm2e

Post by gregsa »

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.
Last edited by gregsa on Wed Jan 12, 2011 9:02 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Lost formatting in algorithm2e

Post by frabjous »

You need to provide a minimal working example which shows the problem. If I simply do:

Code: Select all

\documentclass{article}
\usepackage{algorithm2e}
\begin{document}

\begin{algorithm}
\If{$r^\texttt{b}>0$}{}
\If{$r^b>0$}{}
\end{algorithm}

\end{document}

Then I get this:
algo.png
algo.png (2.14 KiB) Viewed 3953 times
And those are clearly not the same. (Perhaps you wanted an upright typewriter font; then you could use \texttt{\textup{b}}.)
gregsa
Posts: 6
Joined: Wed Sep 01, 2010 1:12 pm

Re: Lost formatting in algorithm2e

Post by gregsa »

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.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Lost formatting in algorithm2e

Post by localghost »

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
Post Reply