Hi,
I have to write many file names with many underlines; this can be done in many ways, but all seem quite clumsy.
1. The obvious way is to replace every _ with \_
2. The another one is to use \begin{verbatim} and \end{verbatim}
3. I also tried
\newcommand{\bv}{\begin{vertabim}}
\newcommand{\ev}{\end{verbatim}}
Now, however, \ev gives an error.
Is there a neat solution?
Text Formatting ⇒ Writing long file names with many underlines
-
- Posts: 2
- Joined: Fri Nov 06, 2020 1:43 pm
NEW: TikZ book now 40% off at Amazon.com for a short time.

- Ijon Tichy
- Posts: 640
- Joined: Mon Dec 24, 2018 10:12 am
Writing long file names with many underlines
The
However, you can use
Or you can use package url to use, e.g.,
There are many more packages like listings, moreverb, fancyvrb, underscore …
BTW: Shortcut commands like
verbatim
environment is somehow special, so you cannot use \begin{verbatim}
or \end{verbatim}
inside the definition of other environments or marcos like you've tried. See the manual of package verbatim for more information about defining you own verbatim environment.However, you can use
\verb|filename___with_many___underscores|
. But this usually cannot be done inside the argument of another command. See an introduction to LaTeX for more information about (very special command) \verb
.Or you can use package url to use, e.g.,
\url{filename___with_many___underscores}
. Again there are restrictions (and solutions for them). See the manual.There are many more packages like listings, moreverb, fancyvrb, underscore …
BTW: Shortcut commands like
\bv
, \ev
are usually not recommended, because they can break syntax highlight of several editors and make the code harder to read. You should instead of such two-character-macros use an editor that supports command auto completion.Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. 

-
- Posts: 2
- Joined: Fri Nov 06, 2020 1:43 pm
Writing long file names with many underlines
\verb|filename___with_many___underscores| works perfectly for my purposes. Thanks!
Out of curiousity, what is this | instead of { ?
I have never seen LaTeX commands used in this way.
Out of curiousity, what is this | instead of { ?
I have never seen LaTeX commands used in this way.
- Ijon Tichy
- Posts: 640
- Joined: Mon Dec 24, 2018 10:12 am
Writing long file names with many underlines
You can also use another character as delimiter. As I said:
\verb
is special and please read an introduction to LaTeX. It should explain it.Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. 
