views:

420

answers:

2
+3  Q: 

latex escape chars

Hi,

I want to prepare a text for the use in a LaTeX document. I wrote a SQL Function which does a lot of REPLACE. For example "_" -> "_" and so on.

But there are so many special chars and sometimes I get errors... Does anyone know a sql-function or a java package for escaping text to LaTeX?

greatings Uwe

+2  A: 

Use a verbatim environment or the listings package, then you can enter source code without escaping.

Philipp
That is similar to `<pre>` from HTML, meaning it has a strict, pre-defined formatting. Sometimes we just want to generate LaTeX code, and add text coming from SQL as normal paragraphs. Thus, such packages aren't adequate.
Denilson Sá
The `listings` package is pretty customizable. If you don't need syntax highlighting, simply redefine `\verbatim@font`.
Philipp
That's not the point. If I want an entire paragraph, or just one value inside a table, I don't think we should use this verbatim package. For instance, this package won't automatically break lines and justify the text at the left and the right.
Denilson Sá
+1  A: 

There are only 10 special chars: \ { } _ ^ # & $ % ~.

Alexey Malistov
And tilde: ~, used for NBS
o_O Tync
Yes. And tilde. Thanks
Alexey Malistov
Hey, Alexey, could you please edit your answer to add the tilde to the list? It will make the answer better for future readers.
Denilson Sá
I've added it. However, there are many other special characters, and the set isn't fixed: every character with a category code other than 11 or 12 will get special treatment.
Philipp