0
$\begingroup$

I prepared in Mathematica some long text:

text = string1 <> string2 <> ... <> stringn;

(some strings contains TeX code). Then I would like to export text to some text file and I use:

Export[path,text,"Text"]

Unfortunatelly, when I look into the file instead of the expected text I found Mathematica command:

StringJoin[string1,string2,...]

What to do, to have text, which I created in Mathematica in my file?

$\endgroup$

1 Answer 1

1
$\begingroup$

use ToString and " " enclose the text. And insert blank "\ " or "\n" when we need some format.

text = ToString[α + a // HoldForm // TeXForm] <> "\ " <> 
   "a,b,c" <> "\ " <> "A+B+C";
Export["new.txt", text, "Text"]
Import["new.txt"]
text = ToString[α + a //HoldForm//TeXForm] <> "\n" <> "a,b,c" <> "\n" <>
    "A+B+C";
Export["new.txt", text, "Text"]
Import["new.txt"]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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