Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to convert a large LaTeX project (i.e. spanning multiple files) into plain text. The purpose is generation of statistics, so representing mathematics is not an issue. In fact, all mathematics is ideally ignored.

I have found http://code.google.com/p/textricks/ but could not get it to run. It seems unfinished, but is exactly what I am looking for otherwise.

share|improve this question
    
(if anyone knows a good tag, feel free to edit the question) –  Ben Oct 17 '11 at 20:00
1  
Done. plain-tex was definitely wrong, which is about plain-TeX not plain-text files. I added the conversion tag and created a new text-only tag (which might be renamed) –  Martin Scharrer Oct 17 '11 at 20:10
3  
I would compile the document into a PDF and then use pdftotext to convert it to a text file. This ensures that you are using the LaTeX output not the input which might differ. Of course, if you want to do statistics about the LaTeX files and not the document generated by it, then you need to convert the source instead. –  Martin Scharrer Oct 17 '11 at 20:18
3  
The UK Tex FAQ lists some options for this: tex.ac.uk/cgi-bin/texfaq2html?label=fmtconv+toascii –  Daniel Oct 17 '11 at 20:23
    
pdftotext is good enough for my purposes. I can post-process the file if needed. The question might still be interesting, though. Can it be done without going via PDF? –  Ben Oct 17 '11 at 20:27
show 1 more comment

1 Answer

up vote 5 down vote accepted

I would compile the document into a PDF and then use pdftotext to convert it to a text file. You should disable all hyphenation and remove the page header (\pagestyle{empty}) to get only the raw text. This ensures that you are using the LaTeX output not the input which might differ.

Of course, if you want to do statistics about the LaTeX files and not the document generated by it, then you need to convert the source instead. Stripping all macros is very difficult because (La)TeX is quite dynamic and macros can be redefined anyway (even by itself). A full correct stripping could only be implemented in (La)TeX itself because of this and then it is still very difficult. Some tools might simply remove all macros and brace arguments. This might be enough for your tasks.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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