Generalescape backslash character

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
moinmoin
Posts: 8
Joined: Wed Oct 01, 2008 4:54 pm

escape backslash character

Post by moinmoin »

Hello,

minimal LaTeX source:

Code: Select all

\documentclass[a4paper,12pt]{article}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\begin{document}
Some text before table. \par 
\begin{center}
    \begin{tabular}{l|rrr}
        \hline \textbf{\LaTeX-command}   &   \multicolumn{3}{c}{\textbf{size}}      \\ \cline{2-4}
                                        &   \textbf{10\,pt}   & \textbf{11\,pt} & \textbf{12\,pt}     \\ \hline \hline
        \texttt{tiny}                   &   5\,pt             &   6\,pt         &   6\,pt       \\  
        \texttt{scriptsize}             &   7\,pt             &   8\,pt         &   8\,pt       \\  
        \texttt{footnotesize}           &   8\,pt             &   9\,pt         &   10\,pt      \\  
        \texttt{small}                  &   9\,pt             &   10\,pt        &   11\,pt      \\  
        \hline
        \texttt{normalsize}             &   10\,pt            &   11\,pt        &   12\,pt      \\  
        \hline
        \texttt{large}                  &   12\,pt            &   12\,pt        &   14\,pt      \\  
        \texttt{Large}                  &   14\,pt            &   14\,pt        &   17\,pt      \\  
        \texttt{LARGE}                  &   17\,pt            &   17\,pt        &   20\,pt      \\  
        \texttt{huge}                   &   20\,pt            &   20\,pt        &   25\,pt      \\  
        \texttt{Huge}                   &   25\,pt            &   25\,pt        &   25\,pt      \\  
        \hline
    \end{tabular}
\end{center}
Some text after table
\end{document}
Now, I want to set the LaTeX-commands in typewriter face. The problem is: when I insert a backslash, e.g. \tiny, then LaTeX reads it as a command. I want to escape the backslash character, so that the command-string is passed literally, not as an actual command.

Thanks in advance!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Re: escape backslash character

Post by Stefan Kottwitz »

Hi,

you could use \textbackslash.

Stefan
LaTeX.org admin
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

escape backslash character

Post by phi »

You can also use \verb or \lstinline from the listings package. The latter can even do syntax highlighting. Or, as quick and dirty solution:

Code: Select all

\texttt{\detokenize{\tiny}}
moinmoin
Posts: 8
Joined: Wed Oct 01, 2008 4:54 pm

Re: escape backslash character

Post by moinmoin »

Thanks to you Stefan and phi!

\detokenize and \textbackslash both work as expected...

cheers!
Post Reply