I'm writing to a file from within my document. At a certain location, I would like to actually write out the character #. I tried something like this:

\immediate\write\tempo{\# This is a generated file, DO NOT EDIT directly.}

However, this writes out '\#' to that file, which is not what I want. The idea is that the file which is written out by the documentation in latex is automatically used from within a test-suite, and # denotes a comment in that file, so there should be no \ in front.

Leaving out the \ obviously does not work, nor did wrapping the # in another command.

Suggestions? Yves


In ConTeXt you can use buffers.

# This is a generated file, DO NOT EDIT directly.
  • In latex filecontents or similar environments for verbatim output. – Ulrike Fischer Aug 9 '16 at 10:59

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