You know what? You’re right. When you simply type a bare < or > outside of math mode, you get an upside-down exclamation point, not the comparison signs that we use so often.
When compiled with pdflatex, these characters are not mapped to the appropriate comparisons signs, even when they appear inside text mode. So, how do you produce a less-than symbol in LaTeX?
The answer lies in using the \textless directive from the package, or alternatively, the command for producing a greater-than symbol, which is \textgreater. Both directives must be called within text mode.
But what about within math mode? That’s another matter entirely.
Comparison symbols in math mode
In this article, I will explore the various symbols that can be produced via LaTeX, including the basic less than symbol (<) and its variants (such as ≤, ≪, etc.), each with their own commands and outputs.
Using LaTeX’s math mode, it’s quite easy to render a series of comparison symbols, like A < B, A > B, A ≤ B, A ≥ B, A ≪ B, and A ≫ B. For each of these, you need to place the appropriate command within a pair of $ delimiters.
Overleaf’s symbol palette
There is also a symbol palette provided by Overleaf to help users discover the wide variety of symbols available to them. The palette is accessible by clicking on the “Symbol” tab located in the top navigation bar of the editor window. Note that some symbols may require certain packages, such as amssymb. If you’re a premium account user, you’ll have access to more of these symbols than free account users. If you hover over any of the symbols, you’ll see whether the package amssymb is required to be included in your document.
So, while typing the less than symbol isn’t really problematic in terms of producing a valid document, it’s definitely something that you should know about if you’re using a text editor rather than an IDE or an editor with spell checking features.
As far as generating the actual less than symbol, however, it doesn’t get much easier than just entering it directly, but if you’d prefer to generate it using one of the other methods described above, there are several options available to you.
Code examples
Finally, here are the LaTeX code examples that show the difference between the two approaches:
A < B
A > B
A \leq B
A \geq B
A \ll B
A \gg B
Note that all six of these statements were generated inside math mode using the $ delimiter.