Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

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

Writer Matthew Martinez

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.)

2

2 Answers

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

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"
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy