0

I'm running Orgmode 8.2.10 with emacs 24.4 on a Win 7 machine. I've installed python, pygment and minted and added the following code to my .emacs file:

(setq org-export-latex-listings 'minted
  org-latex-packages-alist '(("" "minted"))
  org-latex-pdf-process
  '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
    "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))

For some unknown reason, when exporting to latex (and consequently to pdf), the minted pkg is loaded in the preamble of the tex file but in the body of that same tex file pkg listings and its corresponding cmds are used. As a result the final pdf shows no formatting of, say, a short python code-block enclosed in #+BEGIN_SRC and #+END_SRC in the org file.

I know minted works because if I manually correct the tex file and recompile it with pdflatex it yields the code block correctly.

Why isn't the latex export of the org-file using the minted command/environment in the body of the document?


EDIT 1

I managed somehow to set minted not listings as the go-to package that handles code blocks enclosed within #+BEGIN_SRCand #+END_SRC in an *.org file. I did that by using the GUI of emacs not the .emacs conf file (will study that file at a later moment). Menu Org > Customize > Browse Org Group then patiently finding the Group Org Export > LaTeX > LaTeX Listings and setting this variable to minted instead of leaving it as listings. Saved for future sessions, and clicked Apply and Save. I see I can set Options (such as background color of code) under Org Latex Minted Options. Here's a screenshot:

screenshot of minted in exported pdf

6
  • In org 9.0.5 the variable is org-latex-listings - maybe it changed names as far back as 8.2.10, so try that.
    – NickD
    Commented Apr 18, 2017 at 21:52
  • Tried that, didn't work. I keep getting the following in the .tex export -- \lstset{language=Python,label= ,caption= ,numbers=none} \begin{lstlisting} print "Jack and Jill went up a hill" \end{lstlisting} % Emacs 24.4.1 (Org mode 8.2.10) Commented Apr 18, 2017 at 22:22
  • What did you try? (setq org-latex-listings 'minted)
    – xuhdev
    Commented Apr 18, 2017 at 22:39
  • I wrote in my .emacs file the following: (setq org-latex-listings 'minted org-latex-packages-alist '(("" "minted")) org-latex-pdf-process '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f" "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f")) . Notice export is no more, double parentheses wrap up everything. Commented Apr 19, 2017 at 15:26
  • Are you sure the .emacs is read? This is Windows after all. Try C-h v org-latex-listings RET and see what the value is. In any case, with a minimal .emacs (with the org-latex-listings version of the setq form above) on my Fedora 24 system and doing emacs -q -l /path/to/minimal.emacs I get minted all the way through.
    – NickD
    Commented Apr 19, 2017 at 17:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.