# Problem with >> inside of \tt

I have an inline code example with a nested Java generic declaration, using the typewriter typeface. However, the closing >> is rendering as a black box. A cursory Google search suggested $>>$, but this removes the typewriter font. Using \textgreater in place of the actual > also encounters the same problem. Here is the offending snippet:

...declaration {\tt List<Map<Integer, String>>} is...


Any ideas?

-
This does not happen in a minimal example with you code snippet. Please provide more details about your document preamble in the form of a minimal working example (MWE) that illustrates your problem. You would probably get away with using ...>{}>.... Also, rather use \ttfamily than the depricated \tt. –  Werner Apr 12 '12 at 3:21
@Werner: I was able to fix the problem by adding a \hspace{1pt}, which is less than ideal, but seems to work. I will look into \ttfamily as well. Thanks. –  Joe Einertson Apr 12 '12 at 3:27
So you are unable to reproduce the problem in some minimal form that we can view? –  Werner Apr 12 '12 at 4:58

This can happen when >> becomes a ligature, a guillemet », so it would be differently rendered. If the typewriter font or the output viewer doesn't support this ligature, this can explain the black box. Ligatures can be prevented if you group one character such as {>}> or >{>} or group both {>}{>} or just insert an empty group inbetween, for separating the characters without causing space, >{}>.

A minimal example showing the difference:

\documentclass{article}
\usepackage[T1]{fontenc}
\begin{document}
...declaration {\ttfamily List<Map<Integer, String>>{>}>} is...
\end{document}


-

If you need this in only a few places, then Stefan's method is handy. If you need it several times it becomes heavy:

\documentclass{article}
\usepackage[T1]{fontenc}

\DeclareRobustCommand{\noligtt}[1]{
\begingroup\ttfamily
\activategreater\activateless
\scantokens{#1\noexpand}\endgroup}
\def\activategreater{\catcode>=\active
\begingroup\lccode~=>\lowercase{\endgroup\def~}{>\kern0pt }}
\def\activateless{\catcode<=\active
\begingroup\lccode~=<\lowercase{\endgroup\def~}{<\kern0pt }}

\begin{document}

...declaration \noligtt{<< List<Map<Integer, String>>} is.

\end{document}


-