Hello everyone!
I'm new to the world of Latex and I need some help...
I need to write in my article a filename such as "pippo.txt"
but if I try to compile it Latex gives me this error "missing $ inserted"
I think he tries to find the file pippo.txt...how to avoid this and make latex just print the filename?
Text Formatting ⇒ filename as text
NEW: TikZ book now 40% off at Amazon.com for a short time.
- Stefan Kottwitz
- Site Admin
- Posts: 10321
- Joined: Mon Mar 10, 2008 9:44 pm
filename as text
Hi lowilly,
welcome to the forum!
This should not be a problem. Test this file, it works:
You can click "Open in WriteLaTeX" above to directly open it in the online editor.
So, I guess, your actual file name is not pippo.txt but contains special characters like an underscore, such as pippo_1.txt. In that case, you would get this error, because the underscore _ is for subscripts in math mode.
If you would load the
It also prints the path or file name in typewriter font, which is pretty popular, but this can be changed.
Stefan
welcome to the forum!
This should not be a problem. Test this file, it works:
Code: Select all
\documentclass{article}
\begin{document}
pippo.txt
\end{document}
So, I guess, your actual file name is not pippo.txt but contains special characters like an underscore, such as pippo_1.txt. In that case, you would get this error, because the underscore _ is for subscripts in math mode.
If you would load the
url
package or hyperref
, the path command is handy and fixes it:Code: Select all
\documentclass{article}
\usepackage{url}
\begin{document}
This is the file: \path{pippo_1.txt}
\end{document}
Stefan
LaTeX.org admin
Re: filename as text
Hi Stefan, thank you for the quick answer!
You got it! The filenames contains the underscore character!
The problem is that i don't have those file, so I don't need to insert the path, I just need to print the files name "arm256_start.elf, arm384_start.elf, arm496_start.elf"
I solved it putting an "\" before the "_" but i don't know if it's the right way to solve the problem
Now my problem is to correct this "( gpu_mem = xx) "
You got it! The filenames contains the underscore character!
The problem is that i don't have those file, so I don't need to insert the path, I just need to print the files name "arm256_start.elf, arm384_start.elf, arm496_start.elf"
I solved it putting an "\" before the "_" but i don't know if it's the right way to solve the problem
Now my problem is to correct this "( gpu_mem = xx) "
- Stefan Kottwitz
- Site Admin
- Posts: 10321
- Joined: Mon Mar 10, 2008 9:44 pm
filename as text
\path
can also be used for simple filenames. But \_
should work. It should also work in gnu_mem
. Btw. while the whole expression should be in math mode, gnu_mem
should be text, such as here:Code: Select all
\documentclass{article}
\usepackage{amsmath}
\begin{document}
$\text{gpu\_mem} = x$
\end{document}
LaTeX.org admin
Re: filename as text
ok!
Solved!
Thank you so much!
Solved!
Thank you so much!