emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] LaTeX export of org file uses listings instead of minted, why?


From: address@hidden
Subject: [O] LaTeX export of org file uses listings instead of minted, why?
Date: Sun, 23 Apr 2017 14:02:59 +0200 (CEST)

Hello again, 
I'm still trying to find out why emacs doesn't pick up MINTED instead of LISTINGS to handle code blocks when exporting files from .org to .pdf, via .tex.

I backed-up my previous .emacs file (which had a lot of customization for Beamer, AUCTeX etc.), loaded Nick Dokos' minimal init file, restarted emacs then tried exporting a minimal working example (MWE) of an Org file. IT WORKS!!! (Even though the background color is Black and I'd like it to be White!)

I've tried exporting a more complicated Org file and it works too! (Albeit with a dark background that makes it hard to read some lines).

Now the question is how do I integrate these lines in my old .emacs file so that I can keep all other modes' settings AND export code flawlessly from Org mode?

This is the result of `C-h v org-latex-listings' variable given while .emacs file was open. In truth, this was its value also a couple of days ago, with my old .emacs file active.

------------------------------------------------------------------
org-latex-listings is a variable defined in `ox-latex.el'.
Its value is minted
Original value was nil
------------------------------------------------------------------

Here's the very simple MWE of an Org file:
------------------------------------------------------------
#+TITLE: My Minted Experiment
#+AUTHOR: me
#+DATE: 
#+STARTUP: nolatexpreview
#+OPTIONS: toc:nil
#+LATEX_CLASS: article
#+LATEX_CLASS_OPTIONS: [a4paper,10pt]
#+ATTR_LATEX: :mode table :booktabs
#+LATEX_HEADER: \usepackage{esdiff}
#+LATEX_HEADER: \usepackage[version=4]{mhchem}
#+LATEX_HEADER: \usepackage{amssymb}
#+LATEX_HEADER: \usepackage{siunitx}
#+LATEX_HEADER: \usepackage{booktabs}
#+LATEX_HEADER: \setcounter{secnumdepth}{0}
#+LATEX_HEADER: \usepackage[margin=1in]{geometry}
#+LATEX_HEADER: \frenchspacing \allowdisplaybreaks
#+LATEX_HEADER: \usepackage{fancyhdr}
#+LATEX_HEADER: \pagestyle{fancy} % choose page-style
#+LATEX_HEADER: \fancyhf{}  % erase and clean up
#+LATEX_HEADER: \fancyhf[HLE,HRO]{\thepage} % H or F=Header or Footer, LCR=Left, Centre, Right
#+LATEX_HEADER: \fancyhf[HC]{My minted experiment}

* SECTION
#+BEGIN_SRC python
 print "there's some code here";
 a= True;
#+END_SRC
---------------------------------------------------------------


Here's the TeX file generated with the Export command (C-c C-e l o)
---------------------------------------------------------------
% Created 2017-04-23 Sun 13:23
\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
\usepackage{amssymb}
\usepackage{hyperref}
\tolerance=1000
\usepackage{minted}
\usepackage{esdiff}
\usepackage[version=4]{mhchem}
\usepackage{amssymb}
\usepackage{siunitx}
\usepackage{booktabs}
\setcounter{secnumdepth}{0}
\usepackage[margin=1in]{geometry}
\frenchspacing \allowdisplaybreaks
\usepackage{fancyhdr}
\pagestyle{fancy} % choose page-style
\fancyhf{}  % erase and clean up
\fancyhf[HLE,HRO]{\thepage} % H or F=Header or Footer, LCR=Left, Centre, Right
\fancyhf[HC]{My minted experiment}
\author{me}
\date{}
\title{My Minted Experiment}
\hypersetup{
  pdfkeywords={},
  pdfsubject={},
  pdfcreator={Emacs 24.4.1 (Org mode 8.2.10)}}
\begin{document}

\maketitle

\section{SECTION}
\label{sec-1}
\begin{minted}[fontsize=\footnotesize,bgcolor=black,obeytabs=true]{python}
 print "there's some code here";
 a= True;
\end{minted}
% Emacs 24.4.1 (Org mode 8.2.10)
\end{document}
---------------------------------------------------------------

This is how the .emacs file looks now: 
-------------------------------------------------
 (server-start)
; (add-hook 'LaTeX-mode-hook 'turn-on-reftex)
 (setq reftex-plug-into-AUCTeX t)

;;; a key for tilde symbol
(define-key key-translation-map (kbd "M-2") (kbd "~"))
;;; a key for backquote symbol
(define-key key-translation-map (kbd "M-6") "")
(define-key key-translation-map (kbd "M-9") (kbd "`"))
;;this one's only for CDLaTeX math insertion
(define-key key-translation-map (kbd "C-1") (kbd "`"))

;; visual line word wrapping
(global-visual-line-mode t)

;;automatically recognize org files
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))

;; MINIMAL init FILE. HERE'S WHERE NICK'S INIT FILE STARTS

(add-to-list 'load-path "~/src/emacs/org/org-mode/lisp")

(require 'org-loaddefs)
(require 'org)

(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))

(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-cc" 'org-capture)
(global-set-key "\C-ca" 'org-agenda)

;;; 

(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"))
-------------------------------------------------

reply via email to

[Prev in Thread] Current Thread [Next in Thread]