GennSev
GennSev

Reputation: 1646

How do I use '_' and other characters on LaTeX?

I need to put samples of some command lines in a LaTeX file, but every time I try to use some characters (such as _) I get the " !Missing $ inserted" error.

How can I write strings such as:

./configure FC=gfortran  --with-cuda --without-mpi FLAGS_CHECK="-g -O2" FLAGS_NO_CHECK="-g -O2 -ffree-line-length-none -I../shared/ -L/usr/local/cuda/lib64  -fopenmp"

Without having to use $...$? (I don't want it to look like a math expression.)

Upvotes: 3

Views: 40816

Answers (3)

The proper way to set this is a verbatim or listings environment, as the answer by @Matthias already mentioned.

Just for completeness, in case underscores occur in a non-programming context, one could also use the underscore package:

\documentclass{article}
\usepackage{underscore}

\begin{document}

a_b

\end{document}

Upvotes: 2

Matthias
Matthias

Reputation: 8180

Use the backslash to escape, i.e., \_. Alternatively, use verbatim environment or a code package (e.g., listings).

Upvotes: 8

dasdom
dasdom

Reputation: 14073

Try this \_. So your example should look like:

./configure FC=gfortran  --with-cuda --without-mpi FLAGS\_CHECK="-g -O2" FLAGS\_NO\_CHECK="-g -O2 -ffree-line-length-none -I../shared/ -L/usr/local/cuda/lib64  -fopenmp"

Upvotes: 2

Related Questions