# Exporting string with newline and tab symbols to LaTeX

We have a string that has "tab" symbol between letters "B" and "C" and "newline" symbol between letters "C" and "D":

Input:

"A B\tC\nD"


Output:

The output is formatted accordingly to special symbols used.

But when I export the same string to LaTeX, the special symbols \n and \t are interpreted literally like so:

Input:

ExportString["A b\tc\nd", "TeXFragment"]


Output:

$\text{A b$$\backslash$$tc$$\backslash$$newlined}$


If you put this Latex code into some TeX file the document will display literally "A B\tC\nD" and without "tab" and "newline" symbols.

How to tell the Mathematica to export the special symbols into LaTeX accordingly?

• Why don't you use "Text" as the format since you don't need any special TeX markup? – Somos Nov 23 '20 at 22:43
• Because I want to save it into TeX file - that is why I exported it into TeXFragment. – azerbajdzan Nov 23 '20 at 22:57
• Okay. What do you want the Mathematica output string result to be? Please include that information in your question. – Somos Nov 23 '20 at 23:06
• Do you see the first output? That is what I want but not inside mathematica but inside TeX document. You can use instead ExportString["A B\tC\nD", "TeX"] then save the output string to file.tex then open that file and you will see that the output in the TeX file is without tab and newline. – azerbajdzan Nov 23 '20 at 23:25
• A "TeX" or "LaTeX" file is just a file with text characters except there are conventions on how to interpret those text characters. Thus, in your case, what is the string of text characters that you want to be in the file? You need to specify that in your question. This seems to be a TeX question and not a Mathematica question. – Somos Nov 23 '20 at 23:30

txt =