Text Formatting ⇒ Writing long file names with many underlines
-
- Posts: 2
- Joined: Fri Nov 06, 2020 1:43 pm
Writing long file names with many underlines
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?
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- Ijon Tichy
- Posts: 640
- Joined: Mon Dec 24, 2018 10:12 am
Writing long file names with many underlines
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.
-
- Posts: 2
- Joined: Fri Nov 06, 2020 1:43 pm
Writing long file names with many underlines
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
\verb
is special and please read an introduction to LaTeX. It should explain it.