0
votes

I'm having this problem: My org file with a source code block, when exporting to PDF the source is not properly exported. Here is the content of the file:

#+TITLE: A Document with Emacs-Lisp Source Code

#+NAME:map_example
#+BEGIN_SRC emacs-lisp :exports code
(setq org-latex-pdf-process '("latexmk  -f -pdf %f"))
#+END_SRC

#+RESULTS: map_example
| latexmk  -f -pdf %f |

Here is the the generated .tex file:

% Created 2019-08-07 Wed 13:22
% Intended LaTeX compiler: pdflatex
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{grffile}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}
\usepackage[normalem]{ulem}
\usepackage{wrapfig}
\usepackage{soul}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
\usepackage{latexsym}
\usepackage{amssymb}
\usepackage{hyperref}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}
\usepackage[normalem]{ulem}
\usepackage{wrapfig}
\usepackage{soul}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
\usepackage{latexsym}
\usepackage{amssymb}
\usepackage{hyperref}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}
\usepackage[normalem]{ulem}
\usepackage{wrapfig}
\usepackage{soul}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
\usepackage{latexsym}
\usepackage{amssymb}
\usepackage{hyperref}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}
\usepackage[normalem]{ulem}
\usepackage{wrapfig}
\usepackage{soul}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
\usepackage{latexsym}
\usepackage{amssymb}
\usepackage{hyperref}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}
\usepackage[normalem]{ulem}
\usepackage{wrapfig}
\usepackage{soul}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
\usepackage{latexsym}
\usepackage{amssymb}
\usepackage{hyperref}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}
\usepackage[normalem]{ulem}
\usepackage{wrapfig}
\usepackage{soul}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
\usepackage{latexsym}
\usepackage{amssymb}
\usepackage{hyperref}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}
\usepackage[normalem]{ulem}
\usepackage{wrapfig}
\usepackage{soul}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
\usepackage{latexsym}
\usepackage{amssymb}
\usepackage{hyperref}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}
\usepackage[normalem]{ulem}
\usepackage{wrapfig}
\usepackage{soul}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
\usepackage{latexsym}
\usepackage{amssymb}
\usepackage{hyperref}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}
\usepackage[normalem]{ulem}
\usepackage{wrapfig}
\usepackage{soul}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
\usepackage{latexsym}
\usepackage{amssymb}
\usepackage{hyperref}
\usepackage[margin=2cm]{geometry}
\author{Yu (Aaron) Shen}
\date{\today}
\title{A Document with Emacs-Lisp Source Code}
\hypersetup{
 pdfauthor={Yu (Aaron) Shen},
 pdftitle={A Document with Emacs-Lisp Source Code},
 pdfkeywords={},
 pdfsubject={},
 pdfcreator={Emacs 26.2 (Org mode 9.2.3)}, 
 pdflang={English}}
\begin{document}

\maketitle
\tableofcontents

\lstset{language=Lisp,label=map_example,caption= ,captionpos=b,numbers=none}
\begin{lstlisting}
(setq org-latex-pdf-process '("latexmk  -f -pdf %f"))
\end{lstlisting}
\end{document}

Here is the output of Org LaTexOutput:

Latexmk: Run number 1 of rule 'pdflatex'
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
Collected error summary (may duplicate other messages):
  pdflatex: Command for 'pdflatex' gave return code 256
Latexmk: Use the -f option to force complete processing,
 unless error was exceeding maximum runs of latex/pdflatex.

With the generated test.tex from org file by exporting to PDF, and manually execute the following command:

latexmk  -f -pdf test.tex

There is a fatal error with the error trace:

*geometry* driver: auto-detecting
*geometry* detected driver: pdftex
(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsa.fd)
(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsb.fd)
(/usr/share/texlive/texmf-dist/tex/latex/wasysym/uwasy.fd)
(/usr/share/texlive/texmf-dist/tex/latex/base/ulasy.fd)
! Undefined control sequence.
l.165 \lstset
             {language=Lisp,label=map_example,caption= ,captionpos=b,numbers...

?

I tried to export the same file to HTML, it produces the expected HTML rendering

My emacs/org setup used to work with PDF export of source code.

How can I investigate and fix the problem?

1
What does the .tex file look like? What is the value of the variable org-latex-pdf-process?NickD
The value of org-latex-pdf-process is ("latexmk -pdf -quiet %f")Yu Shen
You might want to get rid of the -quiet for now, try it again and check the *Org PDF LaTeX Output* buffer for clues. If it's a LaTeX problem, that should provide some information. But if it's an Org mode problem, then looking at the contents of the .tex file (and adding it to your question if you can't figure out what's going on) is the way to go.NickD
The .tex file has a \tableofcontents so the PDF should contain a TOC. But that requires two runs of pdflatex, which latexmk does not do, I guess because it got an error in the first one. You might want to add the -f flag to your org-latex-pdf-process setting. For the source block, you are using listings and since there is no known language called 'dart', it falls back to Lisp which is bizarre.NickD
You might want to try the minted method for dealing with source block formatting. You need to set org-latex-listings to minted, but you also need to install the minted LaTeX package and the pygments package that it depends on. The doc string for org-latex-listings has details.NickD

1 Answers

1
votes

I have tried your code and if you add "-shell-escape" to your latex command should solve the problem.

#+BEGIN_SRC emacs-lisp :exports code
(setq org-latex-pdf-process '("latexmk -shell-escape -f -pdf %f"))
#+END_SRC