3

I am using LaTeX to generate descriptive receipts for an online system. I use special character tags and replace these with content e.g. {{ first_name }}. Now, there are several of these and they should all be escaped, to make sure no LaTeX code is compiled. I've tried to use the fancyverbatim package, but I've found verbatim environments don't quite line break correctly giving problems for me. Then I tried listings, however listings don't allow special characters, which is a nightmare!

TL;DR: What can I do to escape user text strings of LaTeX code?

2
  • 2
    are there any actual latex commands in this "content"? if not, then you can just use \texttt{...}, which doesn't have any of the restrictions associated with verbatim. Commented Dec 30, 2013 at 22:18
  • A user might go add latex commands, that is why they must be handled
    – mikkelam
    Commented Dec 30, 2013 at 22:23

1 Answer 1

4
\detokenize{......}

Should do what you want. (If not please edit your question to have a complete document that shows the problem)

3
  • Yes, this is exactly what i want. How can i make it allowing special characters like: æøå?
    – mikkelam
    Commented Dec 31, 2013 at 1:26
  • @user3062857 you should be careful what you ask for: you asked that all latex commands be disabled, and (in classic tex) æøå (expand to) commands to produce the required letters, so \detokenize breaks those. It would not in xetex or luatex as there the engine is naturally unicode and so there those letters are not special characters, they are simply normal characters. Commented Dec 31, 2013 at 1:30
  • Okay. I meant that i need an environment that only restricts not making more commands, e.g. treats everything as text, but still able to linebreak and color etc.
    – mikkelam
    Commented Dec 31, 2013 at 3:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .