emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* LaTeX export of org file uses listings instead of minted, why?
@ 2017-04-19 22:35 vendo.libri
  2017-04-20  0:31 ` Nick Dokos
  0 siblings, 1 reply; 5+ messages in thread
From: vendo.libri @ 2017-04-19 22:35 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1128 bytes --]

Hello there!I'm having a bit of a problem telling emacs to use MINTED instead of LISTINGS to handle code blocks enclosed within #+BEGIN_SRC and #+END_SRC when exporting from an org file. 
I've had to Customize Org Groups using the GUI menu `Org' but as soon as I close and restart emacs, it goes back to LISTINGS. I know this because when I export a minimum working example org file, the resulting pdf does not recognize code. If I manually change the .tex file and run it, it works perfectly.
I've added a few lines into my .emac file (please find it attached to this mail) but because it's uneven, often repetitive and scrappy, I suspect there's some conflict going on which I, as a simple user of orgmode, am not able to detect.
Can someone please check the file and tell me why emacs/orgmode keeps reverting to LISTINGS every time I shut down and restart emacs?
I'm running org mode 8.2, emacs 24 on a Windows 7 machine. I also have a working TeX Live 2015 distro with MINTED pkg properly working in AUCTeX and I have python's pygmentize.exe in my C:\Python27\Scrips\  directory. What am I missing? Can you help me fix this?

[-- Attachment #1.2: Type: text/html, Size: 1260 bytes --]

[-- Attachment #2: .emacs --]
[-- Type: application/octet-stream, Size: 11683 bytes --]

;;; Schlosser's .emacs
 (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))

;; ;;; Brent.Longborough's .emacs
 (setq inhibit-splash-screen t); Disable splash screen
 (setq visible-bell t); Flashes on error
 (show-paren-mode 1); Matches parentheses and such in every mode


;;; AUCTeX
;; Customary Customization, p. 1 and 16 in the manual, and http://www.emacswiki.org/emacs/AUCTeX#toc2
 (setq TeX-parse-self t); Enable parse on load.
 (setq TeX-auto-save t); Enable parse on save.
 (setq-default TeX-master nil)

 (setq TeX-PDF-mode t); PDF mode (rather than DVI-mode)

;activate Aspell, for all modes(?), not just TeX;
(add-to-list 'exec-path "C:/Program Files/Aspell/bin/")
(setq-default ispell-program-name "C:/Program Files/Aspell/bin/aspell.exe"); M-x ispell-change-dictionary RET to change dictionary
(setq ispell-dictionary "italiano"); Default dictionary. To change do M-x ispell-change-dictionary RET.
(require 'ispell) ;turn on dictionary check

;; (add-hook 'TeX-mode-hook 'flyspell-mode); Enable Flyspell mode for TeX modes such as AUCTeX. Highlights all misspelled words.
;; (add-hook 'emacs-lisp-mode-hook 'flyspell-prog-mode); Enable Flyspell program mode for emacs lisp mode, which highlights all misspelled words in comments and strings.

 (add-hook 'TeX-mode-hook
           (lambda () (TeX-fold-mode 1))); Automatically activate TeX-fold-mode.
;; (setq LaTeX-babel-hyphen nil); Disable language-specific hyphen insertion.

;; " expands into csquotes macros (for this to work babel must be loaded after csquotes).
;; (setq LaTeX-csquotes-close-quote "}"
;;       LaTeX-csquotes-open-quote "\\enquote{")

;from StackExchange question "AUCTeX preview font size too small"
 (set-default 'preview-scale-function 1.2)

;; LaTeX-math-mode http://www.gnu.org/s/auctex/manual/auctex/Mathematics.html
 (add-hook 'TeX-mode-hook 'LaTeX-math-mode)

;; -shell-escape for minted pkg (COMMENT WHEN NOT IN USE)
(add-hook 'TeX-mode-hook
  (lambda ()
    (setq TeX-command-extra-options "-shell-escape")
  )
 )
;;;


(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(ansi-color-faces-vector
   [default default default italic underline success warning error])
 '(cdlatex-math-symbol-prefix 64)
 '(custom-enabled-themes (quote (tango-dark)))
 '(org-format-latex-options
   (quote
    (:foreground default :background default :scale 1.2 :html-foreground "Black" :html-background "Transparent" :html-scale 1.0 :matchers
		 ("begin" "$1" "$" "$$" "\\(" "\\["))))
 '(org-latex-listings (quote minted))
 '(org-latex-minted-langs
   (quote
    ((emacs-lisp "common-lisp")
     (cc "c++")
     (cperl "perl")
     (shell-script "bash")
     (caml "ocaml")
     (latex "tex"))))
 '(org-latex-minted-options
   (quote
    (("fontsize" "\\footnotesize")
     ("bgcolor" "white")
     ("obeytabs" "true"))))
 '(org-startup-with-latex-preview nil)
 '(preview-default-document-pt 10)
 '(show-paren-mode t)
 '(transient-mark-mode (quote (only . t))))
  
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )


;; yasnippet
(add-to-list 'load-path "~/.emacs.d/elpa/yasnippet-0.8.0")
(require 'yasnippet)
(setq yas-snippet-dirs '("~/.emacs.d/elpa/yasnippet-0.8.0/snippets"))
  ;(setq-default mode-require-final-newline nil) 
(yas-global-mode 1)
(defun disable-final-newline () (interactive) (set (make-local-variable 'require-final-newline) nil))



;; minted + Pygments in Org-mode
(require 'ox-latex)
  (add-to-list 'org-latex-packages-alist '("" "minted"))
(setq org-latex-listings 'minted)
(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"))



;; solving yasnippet and org-mode conflict as per manual
 (defun yas/org-very-safe-expand ()
   (let ((yas/fallback-behavior 'return-nil)) (yas/expand)))
(add-hook 'org-mode-hook
                    (lambda ()
                      (make-variable-buffer-local 'yas/trigger-key)
                      (setq yas/trigger-key [tab])
                      (add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
                      (define-key yas/keymap [tab] 'yas/next-field)))

;;emacs and SumatraPDF sync as per StackOverflow question "sync emacs auctex with SumatraPDF"
(setq TeX-PDF-mode t)
(setq TeX-source-correlate-mode t)
(setq TeX-source-correlate-method 'synctex)
(setq TeX-view-program-list
   '(("Sumatra PDF" ("\"C:/Program Files/SumatraPDF/SumatraPDF.exe\" -reuse-instance" (mode-io-correlate " -forward-search %b %n ") " %o"))))

(eval-after-load 'tex
  '(progn
     (assq-delete-all 'output-pdf TeX-view-program-selection)
     (add-to-list 'TeX-view-program-selection '(output-pdf "Sumatra PDF"))))


;code taken from SX "Cleveref: AUCTeX and RefTeX set-up"
(eval-after-load
    "latex"
  '(TeX-add-style-hook
    "cleveref"
    (lambda ()
      (if (boundp 'reftex-ref-style-alist)
      (add-to-list
       'reftex-ref-style-alist
       '("Cleveref" "cleveref"
         (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
      (reftex-ref-style-activate "Cleveref")
      (TeX-add-symbols
       '("cref" TeX-arg-ref)
       '("Cref" TeX-arg-ref)
       '("cpageref" TeX-arg-ref)
       '("Cpageref" TeX-arg-ref)))))


;; PDFs exported from Org-mode are opened in SumatraPDF  not Adobe Reader
(eval-after-load "org" '(progn (setcdr (assoc "\\.pdf\\'" org-file-apps) "SumatraPDF %s")))

;; Org mode and Beamer export
(require 'ox-beamer)
(setq org-latex-to-pdf-process 
  '("pdflatex --shell-escape -interaction nonstopmode -output-directory %o %f"
"pdflatex --shell-escape -interaction nonstopmode -output-directory %o %f"
"pdflatex --shell-escape -interaction nonstopmode -output-directory %o %f"))
 
(defun my-beamer-bold (contents backend info)
 (when (eq backend 'beamer)
  (replace-regexp-in-string "\\`\\\\[A-Za-z0-9]+" "\\\\textbf" contents)))

(add-to-list 'org-export-filter-bold-functions 'my-beamer-bold)

(setq org-src-fontify-natively t)
(org-babel-do-load-languages
 'org-babel-load-languages
 '((python . t)
  (latex . t)))
(setq org-confirm-babel-evaluate nil)
(setq org-babel-python-command "ipython --pylab --pdb --nosep --classic --no-banner --no-confirm-exit")

(setq org-latex-listings 'minted)
(setq org-latex-minted-options
   '(("fontsize" "\\footnotesize")("bgcolor" "white")("obeytabs" "true")))

(require 'ox-latex)

(setq org-latex-listings t)
(add-to-list 'org-latex-packages-alist '("" "tabularx"))
(setq org-src-fontify-natively t)
(setq org-latex-pdf-process
   '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
    "pdflatex -shell-escape -interaction nonstopmode -output-directory %o   %f"
    "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))
(setq org-src-preserve-indentation t)

; allow bold or italics for parts of a word, from StakOverflow discussion "How to make part of a word bold in org-mode?"
 (setcar org-emphasis-regexp-components " \t('\"{[:alpha:]")
 (setcar (nthcdr 1 org-emphasis-regexp-components) "[:alpha:]- \t.,:!?;'\")}\\")
 (org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)


;;Word count by Paul Sexton (orgmode.org/worg/org-hacks.html) as of Jan '16
(defun org-word-count (beg end
                           &optional count-latex-macro-args?
                           count-footnotes?)
  "Report the number of words in the Org mode buffer or selected region.
Ignores:
- comments
- tables
- source code blocks (#+BEGIN_SRC ... #+END_SRC, and inline blocks)
- hyperlinks (but does count words in hyperlink descriptions)
- tags, priorities, and TODO keywords in headers
- sections tagged as 'not for export'.

The text of footnote definitions is ignored, unless the optional argument
COUNT-FOOTNOTES? is non-nil.

If the optional argument COUNT-LATEX-MACRO-ARGS? is non-nil, the word count
includes LaTeX macro arguments (the material between {curly braces}).
Otherwise, and by default, every LaTeX macro counts as 1 word regardless
of its arguments."
  (interactive "r")
  (unless mark-active
    (setf beg (point-min)
          end (point-max)))
  (let ((wc 0)
        (latex-macro-regexp "\\\\[A-Za-z]+\\(\\[[^]]*\\]\\|\\){\\([^}]*\\)}"))
    (save-excursion
      (goto-char beg)
      (while (< (point) end)
        (cond
         ;; Ignore comments.
         ((or (org-in-commented-line) (org-at-table-p))
          nil)
         ;; Ignore hyperlinks. But if link has a description, count
         ;; the words within the description.
         ((looking-at org-bracket-link-analytic-regexp)
          (when (match-string-no-properties 5)
            (let ((desc (match-string-no-properties 5)))
              (save-match-data
                (incf wc (length (remove "" (org-split-string
                                             desc "\\W")))))))
          (goto-char (match-end 0)))
         ((looking-at org-any-link-re)
          (goto-char (match-end 0)))
         ;; Ignore source code blocks.
         ((org-in-regexps-block-p "^#\\+BEGIN_SRC\\W" "^#\\+END_SRC\\W")
          nil)
         ;; Ignore inline source blocks, counting them as 1 word.
         ((save-excursion
            (backward-char)
            (looking-at org-babel-inline-src-block-regexp))
          (goto-char (match-end 0))
          (setf wc (+ 2 wc)))
         ;; Count latex macros as 1 word, ignoring their arguments.
         ((save-excursion
            (backward-char)
            (looking-at latex-macro-regexp))
          (goto-char (if count-latex-macro-args?
                         (match-beginning 2)
                       (match-end 0)))
          (setf wc (+ 2 wc)))
         ;; Ignore footnotes.
         ((and (not count-footnotes?)
               (or (org-footnote-at-definition-p)
                   (org-footnote-at-reference-p)))
          nil)
         (t
          (let ((contexts (org-context)))
            (cond
             ;; Ignore tags and TODO keywords, etc.
             ((or (assoc :todo-keyword contexts)
                  (assoc :priority contexts)
                  (assoc :keyword contexts)
                  (assoc :checkbox contexts))
              nil)
             ;; Ignore sections marked with tags that are
             ;; excluded from export.
             ((assoc :tags contexts)
              (if (intersection (org-get-tags-at) org-export-exclude-tags
                                :test 'equal)
                  (org-forward-same-level 1)
                nil))
             (t
              (incf wc))))))
        (re-search-forward "\\w+\\W*")))
    (message (format "%d words in %s." wc
                     (if mark-active "region" "buffer")))))


;Python
(setq python-shell-interpreter "C:\Python27")

^ permalink raw reply	[flat|nested] 5+ messages in thread
* LaTeX export of org file uses listings instead of minted, why?
@ 2017-04-23 12:02 vendo.libri
  2017-04-23 13:00 ` Kaushal Modi
  0 siblings, 1 reply; 5+ messages in thread
From: vendo.libri @ 2017-04-23 12:02 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 4920 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 6899 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread
* LaTeX export of org file uses listings instead of minted, why?
@ 2017-04-23 16:03 vendo.libri
  0 siblings, 0 replies; 5+ messages in thread
From: vendo.libri @ 2017-04-23 16:03 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1708 bytes --]

Does this code from the backed-up .emacs interfere with TeX not working with MINTED in the body of the .tex file? Should I eliminate it? 
I'm thinking of posting all the bits of code where `minted' is mentioned, in the hopes that some of you experts can tell me whether I could eliminate/edit it. Please help me out!
Again, I'm using Org 8.2, Emacs 24 on a Win 7 32-bit machine (have no intention of upgrading, for now). Thank you in advance.

-----------------------------------------------------------------------------------(custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(ansi-color-faces-vector   [default default default italic underline success warning error]) '(cdlatex-math-symbol-prefix 64) '(custom-enabled-themes (quote (tango-dark))) '(org-format-latex-options   (quote    (:foreground default :background default :scale 1.2 :html-foreground "Black" :html-background "Transparent" :html-scale 1.0 :matchers		 ("begin" "$1" "$" "$$" "\\(" "\\[")))) '(org-latex-listings (quote minted)) '(org-latex-minted-langs   (quote    ((emacs-lisp "common-lisp")     (cc "c++")     (cperl "perl")     (shell-script "bash")     (caml "ocaml")     (latex "tex")))) '(org-latex-minted-options   (quote    (("fontsize" "\\footnotesize")     ("bgcolor" "white")     ("obeytabs" "true")))) '(org-startup-with-latex-preview nil) '(preview-default-document-pt 10) '(show-paren-mode t) '(transient-mark-mode (quote (only . t))))-----------------------------------------------------------------------------------------

[-- Attachment #2: Type: text/html, Size: 2484 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-04-23 16:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-19 22:35 LaTeX export of org file uses listings instead of minted, why? vendo.libri
2017-04-20  0:31 ` Nick Dokos
  -- strict thread matches above, loose matches on Subject: below --
2017-04-23 12:02 vendo.libri
2017-04-23 13:00 ` Kaushal Modi
2017-04-23 16:03 vendo.libri

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).