9

How do you track down errors reported during the export process? I am writing an Org document and exporting it to PDF. (I do not know LaTeX).

I was getting the following error: org-latex-compile: PDF file ./myfile.pdf wasn't produced: [undefined control sequence] [package error] Runaway argument. By trial and error, I narrowed it down to this section of the document:

* Prefix key
  * ~M-p~ (currently unassigned)
  * ~H-c~ (currently unassigned)
  * ~H-;~ (currently unassigned)

After much web searching, I discovered that a limitation of LaTeX is that verbatim text cannot be used in a subheading. The LaTeX generated from the above snippet included lines like:

\subsubsection{\verb~M-p~ (currently unassigned)}

Changing the subheadings to an unordered list fixed the problem:

* Prefix key
  - ~M-p~ (currently unassigned)
  - ~H-c~ (currently unassigned)
  - ~H-;~ (currently unassigned)

because those generated lines looked more like this:

\item \verb~M-p~ (currently unassigned)

Now, finally, here is my question: Is there a better way of tracking down, diagnosing, and solving such errors than my trial-and-error-plus-web-search (short of, say, spending a few weeks learning LaTeX)?

Currently, my file produces a seemingly-fine PDF... but the export process does issue an error message: Process completed with errors: [package error]. I have no idea whether this is serious, whether it has affected my PDF output in a way that I haven't noticed yet, or if it's trivial and should be ignored. Any help is appreciated.

  • 5
    There's a buffer, where Org logs output from tex2pdf or whatever other command you use to generate PDF. Switch to *Org PDF LaTeX Output* to see it. Package error typically means that you used some package, which you didn't install (you are missing some STY file). – wvxvw Jul 10 '15 at 15:51
  • Aha! Very interesting, I had not noticed that. Sure enough, there is the error— not caused by a missing package, but generated by a package. inputenc complained because I used a UTF character that LaTeX apparently can't represent. Thanks! – Sue D. Nymme Jul 10 '15 at 16:04
  • Related: How to debug org-mode export to Beamer – itsjeyd Jul 11 '15 at 7:29
7

As @wvxvw suggested in the comments, looking at the *Org PDF LaTeX Output* buffer is the place to check on the errors. With some basic familiarity with LaTeX, you should be able to track down relatively simple errors like these (which in my experience almost always come from the \verb command. However, it would seem that you won't be able to directly trace the error back to the original Org file.

  • There is no way to directly go to the offending line in the .org file? – becko Sep 25 '18 at 21:27
1

I find binding a macro like the following one very useful:

(local-set-key (kbd "C-c m o")
               (kbd "C-x b org SPC output RET M-< C-s fatal SPC error"))

It just:

  • Switches to the buffer using ido
  • Searches for the string "fatal error"

Of course you can do the same more programmatically but I think this is enough for such a basic usage. Also it's a nice example of the power of emacs bindings and macros, specially for people coming from vim that are used to noremap binding style.

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.