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?

  • 13
    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
    Commented Jan 8, 2011 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
    Commented Jan 8, 2011 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.
    – user6853
    Commented Feb 18, 2013 at 4:35
  • 2
    Machine learning
    – Rainb
    Commented Jun 4, 2020 at 11:26

8 Answers 8


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]. Commented Jan 9, 2011 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
    Commented Jan 9, 2011 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
    Commented Jan 29, 2013 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. Commented Mar 14, 2018 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
    Commented Nov 27, 2018 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!

  • 15
    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
    Commented Sep 28, 2012 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
    Commented Dec 5, 2013 at 6:50
  • 3
    Also, it looks like it is only available for Windows, and not for Linux or Mac.
    – evaristegd
    Commented Jun 16, 2019 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: https://texfaq.org/FAQ-recovertex

  • 4
    related: pdftotext Commented Jun 14, 2015 at 15:38
  • 9
    Except the question was how to convert PDF to LaTeX, not pdf to ASCII
    – hd1
    Commented Jan 11, 2016 at 12:52
  • 1
    @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
    Commented Feb 24, 2018 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
    Commented Jun 16, 2019 at 3:34
  • 1
    funnily, last time I used this scheme I got utf-8 maths symbols produced by ps2ascii, which was great for my purposes :-) Commented Jul 16, 2021 at 10:20

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.

  • Seemingly now the conversion is supported in mathpix?
    – Yai0Phah
    Commented Sep 2, 2021 at 5:56
  • this is the best solution (tried different on-line tools). To use it you need to create an free account and go to web-version. It convert almost everything in Latex Commented Apr 9, 2023 at 19:10
  • I think, at this point, this is probably the "BEST" solution. I could convert very complex slides with math equations. It worked fantastic. Of course, it missed some big downward arrows, but I would say it got 90% of the LaTeX code back. It saved me almost 3 hours of headache.
    – Coder
    Commented Jun 8 at 0:18

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
    Commented Jul 29, 2013 at 10:21
  • how writer2latex export? I couldn't find it from the libre office menu, after installing the plugin
    – liang
    Commented Jun 13, 2020 at 12:53

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.


A two step process has worked well for me.

Step 1) Convert PDF to DOCX (MS Word) You can use pdf2docx or use the acrobat online service (if your doc is public)

Step 2) Convert the DOCX to LaTeX with pandoc.

pandoc -f docx -t latex --standalone -o converted.tex input.docx

Pandoc does not accept pdf as input and docx is a very rich format. So, this combination produces reasonably good results.


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.
  • 11
    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.) Commented Dec 28, 2018 at 2:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .