30

I'd like to include the < and > symbols into my document. First I tried to just type it in. But after generating the document I saw only an inverted ? instead of the > symbol.

That's why I looked at this LaTeX Math Symbols document and I saw that it should work that way. Nevertheless I tried to solve the problem by using the verbatim command:

\begin{verbatim}>\end{verbatim}

Now it works, but the problem is that the verbatim command seems to include a linebreak and that's why the > symbol now is in the wrong line.

How can I solve that?

2
  • 3
    In General: for single verbatim character use \verb+>+. See also the package shortvrb. However for < and > the macros you mention in your answer are better. Commented Feb 5, 2011 at 0:57
  • 1
    So I guess we should close this as a duplicate of Less than symbol (<) appears as upside down? Commented Feb 13, 2011 at 20:46

4 Answers 4

48

To quote from the Comprehensive Symbols List (which has these symbols listed as ”frequently requested”):

The characters “<”, “>”, and “|” do work as expected in math mode, although they produce, respectively, “¡”, “¿”, and “—” in text mode when using the OT1 font encoding. The following are some alternatives for typesetting “<”, “>”, and “|”:

  • Specify a document font encoding other than OT1 (as described on page 8).
  • Use the appropriate symbol commands from Table 2 on page 9, viz. \textless, \textgreater, and \textbar.
  • Enter the symbols in math mode instead of text mode, i.e., $<$, $>$, and $|$.

Note that for typesetting metavariables many people prefer \textlangle and \textrangle to \textless and \textgreater; i.e., “〈filename〉” instead of “<filename>”.

From page 8 (with strong recommendations that you should use this):

One note that appears a few times in this document, particularly in Section 2, indicates that certain symbols do not exist in the OT1 font encoding (Donald Knuth’s original, 7-bit font encoding, which is the default font encoding for LaTeX) and that you should use fontenc to select a different encoding, such as T1 (a common 8-bit font encoding). That means that you should put “\usepackage[ encoding ]{fontenc}” in your document’s preamble, where encoding is, e.g., T1 or LY1. To limit the change in font encoding to the current group, use “\fontencoding{ encoding }\selectfont”.

As Will notes in the comments, a good solution to this is to put

\usepackage[T1]{fontenc}
\usepackage{lmodern}

into your preamble.

Alternatively, using XeLaTeX or LuaLaTeX with the fontspec package also makes these symbols (and many more) work correctly.

2
  • 3
    Strong suggestion to fix this problem once and for all based on that quote: \usepackage[T1]{fontenc} \usepackage{lmodern} (or other font package) Commented Feb 8, 2011 at 3:14
  • 1
    Be warned that if this is a submission for a scientific journal/conference and you change the font you might get into trouble.
    – levesque
    Commented Sep 8, 2015 at 18:15
14

With T1 encoding you could use both symbols directly within your text, without math mode or macros:

\usepackage[T1]{fontenc} 

These symbols are not available in standard encoding and font. For further information have a look at Less than symbol (<) appears as upside down.

0
10

Using Detexify I found the correct symbol:

\textgreater

\textless
1
8

If you don't want to get too verbose, using math mode is simple: $>$ $<$

Not the answer you're looking for? Browse other questions tagged .