4

I'm writing a document for some data analysis code that I produced, and I need to state where the resulting data is stored. The data is written to a directory with a particular name (reducedData) which is itself contained in a "root directory" where my code looks for all sorts of other things. The path to the root directory is a configurable variable, so in my document I refer to the path as <rootDir> which the user should interpret to mean whatever path they have set in their configuration.

In my document I want to have a format like this:

...blah blah blah. The data is stored to:

<rootDir>\reducedData\ <fileName> .hdf

...blah blah blah.

What I need help with is choosing a good way to do this. I could simply force it too look the way I want using explicit line feeds and \verb||, but I'm sure there is a better, more LaTeX-ish way to do this right. In particular, beyond setting the path apart on its own indented line, I'd like to have the font changed so that it stands out, and possibly have yet another font change for the tokens in angle brackets, to imply that they are not to be taken by the user as literal stings. Is there a package or environment that exists to format this sort of thing in a standard way?

Colin K
  • 487

2 Answers2

6

An answer similar to egreg's, but with additional emphasis in placeholder text:

\documentclass{article}

\let\path=\texttt
\newcommand{\V}[1]{$\langle$\textit{#1}$\rangle$}

\begin{document}

\path{\V{rootdir}/reduced-data/\V{filename}.hdf}

\end{document}

enter image description here

The \meta command of the doc package might also be of interest.

Andrey Vihrov
  • 22,325
3

A common way to denote "metavariables" is to enclose them between angle brackets, so it might look as

$\langle$rootDir$\rangle$\texttt{\symbol{`\\}reducedData\symbol{`\\}}%
  $\langle$fileName$\rangle$\texttt{.hdf}

of course buried into a macro defined in the preamble.

Of course these are not Unix paths, but rather Windows.

egreg
  • 1,121,712
  • So basically the answer amounts to "use a macro in your preamble, there is no standard, pre-packaged way of doing this." Which is fine. Now I can stop spending time looking around for a more slick way to do this:) – Colin K Nov 04 '11 at 14:44
  • ...and trust me I'm quite sad that these are not unix paths. My whole lab is standardized on Windows. How sad :( – Colin K Nov 04 '11 at 14:44
  • @ColinK: Windows accepts /, too. Replace them all and you are done. – Andrey Vihrov Nov 04 '11 at 14:47