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 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}
share|improve this question
1  
use package listings for the code sequences –  Herbert 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[...]. –  honzasp Feb 5 '13 at 13:43

1 Answer 1

up vote 7 down vote accepted

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}
share|improve this answer
    
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). –  honzasp 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

 
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.