Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
Does this post help? –  cmhughes Nov 4 '11 at 14:24
    
@cmhughes: Not with this particular issue, but it definitely may come in handy later! Thank you. –  Colin K Nov 4 '11 at 14:27
add comment

2 Answers

up vote 6 down vote accepted

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.

share|improve this answer
add comment

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.

share|improve this answer
    
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 4 '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 4 '11 at 14:44
    
@ColinK: Windows accepts /, too. Replace them all and you are done. –  Andrey Vihrov Nov 4 '11 at 14:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.