[Tex/LaTex] How to typeset a file path

best practices

I would like to properly typeset a file path, e.g.

C:\Program Files\Some program\bin\executable.exe

The first problem I encountered was that LaTeX tries to treat \Program as a command. I tried escaping it with another backslash which created a linebreak.

Then I found this package menukeys but I am not really happy because it typesets system-specific delimiters (i.e. \ for Windows and / for Unix-like) as some weird arrows.

Which leads to my question: what is the preferred way of typesetting a file path in LaTeX?

Best Answer

You could load the package url with the option obeyspaces and encase the fully qualified file name in a \url instruction:

enter image description here

\documentclass{article}
\usepackage[obeyspaces]{url}
\begin{document}
\path{C:\Program Files\Some program\bin\executable.exe} % equivalent to \url{...}, but more semantic
\end{document}

Addendum: If you need or wish to allow line breaks at the spaces, choose the spaces option as well:

\usepackage[obeyspaces,spaces]{url}