I'm writing about programming language Haskell and I need to describe operators named >>= and >>. I wrap all references to names from the programming language in \texttt{ ... }, for example:

We use operator \texttt{+} to add two numbers.

But when I write \texttt{>>}:

We use operator \texttt{>>} to sequence two actions.

I got the "much greater than" sign, which is not what I want (see the image).

I found some questions asking similar problem (“<<” sign in Latex), but the solutions proposed there don't work for me:

Various approaches and how are they rendered

The only solution I found is to break \texttt{>>} to \texttt{>}\texttt{>}, but it gets painful when I use longer expressions; for example:

To sequence many actions, use \texttt{a1 >> a2 >> a3 >> ... >> a4}

must be broken to

To sequence many actions, use \texttt{a1 >}\texttt{> a2 >}\texttt{> a3 >}\texttt{> ... >}\texttt{> a4}

I'd rather avoid using \verb, because:

  1. I want to be consistent with the rest of the text using \texttt
  2. I sometimes need to use formatting in the code snippets to emphasize a variable or something

P.S.: I do use

  • 1
    use package listings for the code sequences – user2478 Feb 5 '13 at 13:16
  • 1
    Consider the listings package for automatic formatting of source code, or if you are on *nix, the minted package based on Python/Pygments for even superior syntax coloring. – marczellm Feb 5 '13 at 13:17
  • I use listings for multi-line code listings, but didn't know about \lstinline. I'll have a closer look at \lstMakeShortInline, but it doesn't seem to work in \item[...]. – Jan Špaček Feb 5 '13 at 13:43

These are ligatures. You can either avoid them locally by putting braces between the input. Or globally with microtype:

\DisableLigatures[>,<]{encoding = T1,family=tt*} %
\texttt{>>}   %need the microtype command.
\texttt{>{}>} %works always
  • Yes, thank you, this seems to work! I had to \usepackage{lmodern} because I was getting pdfTeX error (font expansion): auto expansion is only possible with scalable (answer on tex.SE). – Jan Špaček Feb 5 '13 at 13:38
  • 1
    @honzasp: An alternative to lmodern is to install the cm-super-package. – Ulrike Fischer Feb 5 '13 at 13:40

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.