I know that hardly any information is passed to the PDF when a .tex file is compiled.

But is there a tool that can convert a PDF document back to (La)TeX?

  • 12
    The answer is going to be 'no', more or less, but it would be helpful to say a little more about the nature of your PDF files and desired LaTeX output. For example, converting simple text is a different issue to converting maths or graphics. – Joseph Wright Jan 8 '11 at 15:06
  • 2
    you can convert to doc (nitroreader.com) and then with word2tex (chikrii.com) to LaTeX. But the code maybe lousy ... – user2478 Jan 8 '11 at 15:20
  • 2
  • Decide what information you're hoping to preserve. Google for information on conversion to intermediate formats such as text or html that might preserve that information. – Ben Crowell Feb 18 '13 at 4:35
  • 1
    Machine learning – Rainb Jun 4 '20 at 11:26

If you install AbiWord with the additional import and export plugins,* you can open a PDF file in the Word Processor, and then export to LaTeX. In fact, you can also convert from the command line:

abiword --to=tex filename.pdf

Be warned that both its PDF import routine and its LaTeX export routine have serious limitations, and you should not expect anything that will be usable without serious tweaking afterwards.

(* IIRC, the extra plugins are installed by selecting a custom install on Windows and checking all the import and export options it gives you. For Linux, you typically need to install a separate package called "abiword-plugins" or "abiword-plugin-mathview" depending on distro. No clue for Mac.)

Inkscape can open PDFs and export to either PSTricks or TikZ codes; this might be useful if the PDF in question is just a diagram or vector image you want to edit.

There's a project listed on sourceforge called pdf2latex, but it doesn't look like any real work has been done on it. I'm not sure it's a real project. (The page looks fishy; almost as if someone was just posting an idea.)

  • 1
    Thanks! Unfortunately abiword outputs: AbiWord: could not open the file [filename]. – Martin Vseticka Jan 9 '11 at 14:50
  • Is the PDF import plugin installed? Can you open other PDFs? If so, and it still doesn't work for the one you want, it's probably too complex a PDF for it. – frabjous Jan 9 '11 at 15:09
  • from abisource.org/wiki/FaqCreatingPDFs Can I use the PDF plugin mentioned on the PluginMatrix page? No, this plugin hasnt been maintained in many years and doesnt ship with newer versions of AbiWord . Seems to be an export plugin, though. I cannot find an input plugin. Windows here. – n611x007 Jan 29 '13 at 11:16
  • 1
    abiword seems to output a lot of invalid characters, the latex doesn't compile, and after fixing a few things it doesn't look like I'll be able to clean it up in a reasonable amount of effort. Though I don't know of any better option. – davidparks21 Mar 14 '18 at 2:46
  • 2
    @41041729 what errors are you getting? file a bug report... open source software doesn't work unless we work to make it better. – frabjous Nov 27 '18 at 14:30

Check out InftyReader.

Quoting the start page:

InftyReader is an Optical Character Recognition (OCR) application that recognizes and translates scientific documents (including math symbols) into LaTeX, MathML and XHTML!

  • 13
    Eunice, your answer was a bit … simple. Hope you don’t mind my adding of some more information. But nonetheless I don’t want to forget the following: Welcome to TeX.sx! – Speravir Sep 28 '12 at 2:14
  • 4
    note, the trial version only allows 1 page to be converted at a time. Also you can only use it 5 times per DAY! Still, an incredible solution that really, really works! – ecoe Dec 5 '13 at 6:50
  • Also, it looks like it is only available for Windows, and not for Linux or Mac. – evaristegd Jun 16 '19 at 3:24

I found no tool that can deal with formatting, but for extracting the text on Linux, there is a two step procedure that produces good results:

$ pdf2ps paper.pdf
$ ps2ascii paper.ps > paper.txt

From: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=recovertex

  • 2
    related: pdftotext – Sean Allred Jun 14 '15 at 15:38
  • 7
    Except the question was how to convert PDF to LaTeX, not pdf to ASCII – hd1 Jan 11 '16 at 12:52
  • @hd1 Yes, but the answer does explain why the solution offered does not do that i.e. why it is the best possible, though not one which meets the desiderata. If it just presented this without qualification, the comment would be a more reasonable one. (Or, even, if there was a better solution.) – cfr Feb 24 '18 at 2:10
  • 1
    If you want to learn more about pdftotext : glyphandcog.com/opensource.html ; and on Ubuntu you can run man pdftotext .You can also check out the post: askubuntu.com/questions/52040/… – evaristegd Jun 16 '19 at 3:34

Import the file using LibreOffice. It will create a Draw file. You have to copy and edit it by pieces into Writer. Then you can use the plugin writer2latex to export the results to LaTeX. The final code is dirty, with plenty of stuff you don't need and some errors.

If your docs are large enough, this process might be easier than re-typing everything.

Another alternative, if you are dealing mostly with pure and simple text, is to save the file as a *.txt from the PDF reader. Then copy/paste the thing into your LaTeX editor.

  • 1
    Both of these approaches will break ligatures unfortunately - the only solution I've found is a lot of find&replace. – Chris H Jul 29 '13 at 10:21
  • how writer2latex export? I couldn't find it from the libre office menu, after installing the plugin – liang Jun 13 '20 at 12:53

The solutions mentioned by @frabjous @eunice work great. To add to the answers above to make a complete list of tools available online for converting things to TeX, I have been using:


and it works really well. This tool does not directly convert PDFs to TeX code, however, it is super useful to convert equations to TeX code and it works very accurately. Working with it is as easy as taking a snapshot of your target equations and it spits out the TeX code. It's very useful particularly when you are dealing with long equations.


Here is an approach that combines InftyReader and AbiWord.

Suppose we have a file


First process it with the free version of InftyReader. This will not give the TeX directly (except for the first page) but it will produce a file


Then you can run AbiWord on this file:

abiword --to=tex example.pdf2txt

The result is not great, but not too bad either.


Convert PDF to Latex by acquiring the source .doc or .docx.

If you can acquire the .docx file that generated the .pdf, then you can one-shot .docx -> latex and get decent results using:

  1. Online website docx-to-latex converter, or
  2. Microsoft Word's propitiatory docx-to-latex file menu->convert features or
  3. Openoffice or Libreoffice's approximation of #2 above.

Alternatively, If you're sure the PDF was generated by Microsoft Word, but don't have it, then:

  1. Use an online converter, Microsoft Word, or Openoffice to convert the PDF to .docx. This is a potentially data lossy operation since anything that touches microsoft is a rube goldberg machine of evolution.
  2. Use an online converter, Microsoft Word, or Openoffice to convert the .docx to Latex.
  • 8
    you're assuming that the pdf file was created by word. but the question explicitly said that the pdf file was the result of compilation from tex source. (this usually means that the original tex source was lost.) – barbara beeton Dec 28 '18 at 2:09

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