"Escaping" Linux kernel version in latex

The problem is the underscore. TeX uses that as a special character to denote subscripts, as in x_1,x_2. TeX assumes that wherever it encounters an underscore the author means it to be a subscript.

Fortunately, this behaviour can be overridden. Even more fortunately, you don't need to know how this is done since it is already solved for you! LaTeX provides the \verb (short for "verbatim") command which typesets its contents in the \texttt family and sorts out all the "special" characters so that they appear as is. A way to use it for you would be:

\verb+2.6.40.4-5.fc15.x86_64+

The + is a delimiter that you yourself can choose, so if the string has + in it then you can choose something else, such as *. Just make sure that the delimiter is not something that appears in the string that you want to typeset.


To complete other answers, I should mention that if the text is entered manually (not programmatically generated), \_ or \textunderscore can be used to easily obtain the underscore:

\texttt{2.6.40.4-5.fc15.x86\_64}
\texttt{2.6.40.4-5.fc15.x86\textunderscore 64}

I suppose \_ is as close to escaping as you can get :-)


It's also possible to run the shell command from inside LaTeX; for example, here is how to get the output of uname -a:

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}

\def\uname{{\ttfamily\def\do##1{\catcode`##1=12 }\dospecials
  \catcode` =10 \pdfprimitive\input|"uname -a" }\unskip}

\begin{document}
\uname
\end{document}

For this it's necessary to run pdflatex with the -shell-escape option.

A more general version might be:

\def\syscommand#1{{\ttfamily\def\do##1{\catcode`##1=12 }\dospecials
  \catcode` =10 \pdfprimitive\input|"#1" }\unskip}

and \syscommand{uname -a} would give the same result as before. Use with great care.