0

I have tried already:

  • Devising a macro in my text editor (sublime text 3) to rid of all the syntax in the editor that is latex related without any luck.
  • Using code/syntax folding to easily copy and paste the text so functions and such collapse.
  • Google searching for a solution to this.

I can't work out a way, does anyone know how to achieve this?

Reasons I want to do this:

  • Sharing the text I have inputted to other people in say .txt format for not TeX users.
  • Word counting.
  • Backing up.
  • Many other reasons.
  • Does tex.stackexchange.com/a/405115/36296 help? – user36296 Mar 28 at 20:24
  • The only issues I have with this method so far is I am using Windows, and further to that I am using Overleaf which I believe does not support detex? Additionally getting detex working on windows seems to be troublesome. – SomeT Mar 28 at 20:38
  • If detex doesn't work, LaTeX2HTML is available for windows. Then you just strip out html tags. It depends on what your LaTeX document is as to whether this makes sense. – Andrew Kepert Mar 28 at 20:42
  • But then I am left with the issue of stripping out the HTML tags thus the problem remains highgly similar. – SomeT Mar 28 at 20:44
  • 1
    even with gui: urchin.earth.li/~tomford/detex – user36296 Mar 28 at 20:46
2

For those willing to try OpenDetex on Windows10 64 bit, an older 2.8.1 produces this result.

NOTE colouring is me to show pale blue extracted and yellow replaced. [click to zoom]

enter image description here

Available from the nearest Google Code Archive near you.

  • I preferred pandoc tbh as it does not rely on a GUI and I can called it from the command line, across other applications and code and such. – SomeT Mar 29 at 19:48
  • 1
    I do understand there are many more options with pandoc for html etc. its just that you may get more tex in the output such as \maketitle [] []{.lettrine} etc. The simplicity of a basic Detex in.tex>out.txt is that its useful for a quick and dirty input to Grammarly etc – user170109 Mar 29 at 19:58
  • You make a good point. My two answers below though are more suited to my specific use cases in overleaf. The solution I found for overleaf works pretty much the same as detex, perhaps even using it, itself? – SomeT Mar 30 at 16:02
  • 1
    Yes the overleaf method is possibly a customised/enhanced detex and I would use pandoc for say docx rather than attempt to spent time reformatting the colours and layout of a graphics tex with \included images etc. Each have their uses – user170109 Mar 30 at 16:07
1

This is the purest and easiest way I found to achieve conversion in Windows, and even does it nicely to .docx as well:

https://pandoc.org/

I then just used the commands listed here to get the hang of how it works:

https://pandoc.org/demos.html

0

As I mentioned overleaf above, I contact them and tested this method and it works also but not as good as Pandoc:

Hello,

Thanks for getting in touch.

Here's a hack that may (or may not) work with your project: Add a file named "latexmkrc" (without file extension) in the top level of your Overleaf project, and paste the following line in it:

END { system ('detex main.tex > plain.txt'); }

Replace main.tex with whatever file you want to check on. If main.tex contains \input or \include, it will automatically read those files as well. The detex utility will try to strip only the plain text from main.tex (and included .tex files), outputting them to plain.txt. Some arguments from some LaTeX commands may still get in.

Then in the list of generated files (see https://www.overleaf.com/learn/how-to/View_generated_files

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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