TeXblog

 Typography with TeX and LaTeX

Special LaTeX characters

Juni 15th, 2008 by Stefan Kottwitz

Besides the common upper- and lowercase letters, digits and punctuation characters, that can simply by typed with the editor, some characters are reserved for LaTeX commands. They cannot be used directly in the source. Usually they can be printed if preceded by a backslash:

\documentclass{article}
\usepackage{array}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{ll}
\toprule
\multicolumn{2}{c}{\textbf{Special \LaTeX\ characters}}\\
\midrule
Number sign:  & \# \\
Dollar sign:  & \$ \\
Percent sign: & \% \\
Underscore:   & \_ \\
Ampersand:    & \& \\
Braces:       & \{ \} \\
Circumflex:   & \^{}  \\
\bottomrule
\end{tabular}
\end{document}

Output:

LaTeX symbols

Some characters might not appear as expected. Try:

\documentclass{article}
\begin{document}
Pipe sign: |
 
Less than: <
 
Greater than: >
\end{document}

Output:

OT1 encoding

Just adding one line to the preamble specifying T1 fontencoding helps:

\documentclass{article}
\usepackage[T1]{fontenc}
\begin{document}
Pipe sign: |
 
Less than: <
 
Greater than: >
\end{document}

Output:

T1 encoding

This entry was posted on Sonntag, Juni 15th, 2008 at 09:10 and is filed under Fonts and Symbols. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

6 responses about “Special LaTeX characters”

  1. Ruquay K Calloway said:

    Ah, yes, but what if you are already using UTF-8 encoding?

  2. Stefan Kottwitz said:

    Hi Ruquay,

    UTF-8 encoding means input (character) encoding, not font encoding. Also if you add

    \usepackage[utf8]{inputenc}

    the output of the pipe sign | and of the < and > symbols would still be wrong, without T1 font encoding.

    Stefan

  3. Ash said:

    Stafan,

    so what is your suggestion? If I \usepackage[utf8]{inputenc} to be able process utf-8 encoded sources, what should I do to be able to write and | easily in utf-8 encoded sources?

    Thank you,
    Ash

  4. Ash said:

    I mean \usepackage[T1]{fontenc} and
    \usepackage[utf8]{inputenc}
    does not work together.

  5. Stefan Kottwitz said:

    They work together. Perhaps show what doesn’t work for you. | works \usepackage[T1]{fontenc}, and still does if you use \usepackage[utf8]{inputenc} in addition.

  6. Peter Grill said:

    Perhaps the tilde (~) and backslash (\) should be listed as special LaTeX characters?

Leave a Reply