Text Formatting ⇒ filename as text
filename as text
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?
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
- Stefan Kottwitz
- Site Admin
- Posts: 10324
- Joined: Mon Mar 10, 2008 9:44 pm
filename as text
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
Re: filename as text
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: 10324
- 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}
Re: filename as text
Solved!
Thank you so much!