10

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

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
  • 1
    use package listings for the code sequences –  Feb 05 '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 05 '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 05 '13 at 13:43

1 Answers1

9

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

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{microtype}
\DisableLigatures[>,<]{encoding = T1,family=tt*} %
\begin{document}
\texttt{>>}   %need the microtype command.
\texttt{>{}>} %works always
\end{document}
Ulrike Fischer
  • 327,261