323

When typing < or > in LaTeX and compiling with pdflatex, the less than and greater than symbols appear at upside down exclamation points. I'm not in math mode.

lockstep
  • 250,273

4 Answers4

293

Geoffs tip with \textless and \textgreater will work well for you. However, you could type these symbols < and > directly in your editor and they would be correctly printed if you use the recommended font encoding, Cork resp. T1:

\usepackage[T1]{fontenc}

Have a look at the T1 encoding table, search for the symbols < and >. Afterwards, open the OT1 encoding table, which is the default. At the two corresponding places you will find the upside down exclamation resp. quotation mark. That should explain it.

For further reasons, why you should use T1 encoding, have a look at this question: Why should I use \usepackage[T1]{fontenc}?

You should use a font supporting T1. For instance use the very good Latin Modern font, derived from the standard fonts:

\usepackage{lmodern}

Or install the cm-super package which provides the standard Computer Modern fonts with T1 support.

praseodym
  • 105
Stefan Kottwitz
  • 231,401
144

Use \textless and \textgreater.

Geoff
  • 3,801
  • 12
    unless they are part of a math expression, in which case they should be between dollar signs or \( ... \) along with the rest of the math expression. – barbara beeton Aug 26 '10 at 19:51
26

What I usually do is just enter mathmode to type them, e.g. This object is $<$ that object.

  • 23
    That is generally considered poor style. You should just write out "This object is less than that object." Occasionally, you'll see "foo is <0." This looks bad. – TH. Aug 27 '10 at 23:32
  • 13
    That's definitely true. However, if you're using LaTeX to organize your thoughts (as i often do), 'good style' equates to 'will I understand what I wrote if I come back and look at it in a week'! – Avi Steiner Sep 03 '10 at 03:30
  • @TH.: I agree with you. My experiency tells me too that text and math code should not be mixed up. Good style would be either writing "The variable $foo$ is less than zero." (as you mentioned) or "The variable $foo$ satisfies the relation/condition $foo<0$.", which would probably suit your application. Good style means also to define variables at the first use. – strpeter Dec 07 '13 at 08:07
  • 1
    @strpeter While mentioning style, it is worth noting that variable $foo$ is not good style either: it refers to the product of $f$, $o$, and $o$. You mean variable $\mathit{foo}$. – akim Dec 08 '14 at 09:19
  • OK, I was not typing it correct in the sense of the variable as I focused on the operator. You're right - use your preferred version $\mathit{foo}<0$, $\mathrm{foo}<0$, $\mathbf{foo}<0$, or whatever variable. ;) – strpeter Dec 08 '14 at 10:40
  • Ah no way. It's so much easier to read when there are symbols. Sure it might be bad style but I always put readability first. – Nicholas Pipitone Feb 21 '19 at 03:31
  • FWIW: I also use > to denote menu navigation - e.g., "File > Examples > Basics > blinkenlights.ino." – Iotatron Jun 17 '23 at 21:07
0

This very old question appeared when I searched for something else. Looking at the old answers, I see that T1 encoding is recommended, when compiling with pdflatex. But a many things have happened since then.

If at all possible, compile with a utf-8 aware engine such as lualatex instead of pdflatex. You do not need to know any Lua code (apparently, many potential users have the incorrect belief that Lua programming is needed). The required Lua code is built-in, and invisible to the end user. Of course, if you do know Lua, you can add more.

If compiling with lualatex, your input text must be utf-8 encoded. Nowadays, that is almost certainly true. You must use the fontspec package. After the document class, \usepackage{fontspec}. Then use its commands, such as \setmainfont, to manipulate fonts. Be sure to select OpenType (or TrueType) fonts. In some cases fontspec can handle the older Type1 fonts, but that is the wrong way to do it.

In text mode, using lualatex, when I type < or >, that is what I get. If I use a character map to insert an inverted exclamation or question mark, that is what I get. There are also some LaTeX macros for that, but copy/paste from a character map has the advantage that your source text will appear correct, without LaTeX code there.

rallg
  • 2,379
  • If somebody asks for help in flying a hot-air balloon, do you tell them to use an airplane? – egreg Mar 15 '24 at 08:24
  • @egreg No, but if someone in the year 1912 asked for help with a hot air baloon, I would mention that in the intervening time, the airplane was invented. The OP was 13 years ago. Unfortunately, SE retains old questions, with old solutions, and they are often highly ranked. So persons searching for something might be unaware of possibilities that were not often discussed, years ago. – rallg Mar 15 '24 at 14:50