emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Emmanuel Charpentier <emm.charpentier@free.fr>
To: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Correction and addition [Re: BUG: the builtin LaTeX/P DF exporter mislabels source blocks as figures.]
Date: Tue, 30 Apr 2019 23:27:22 +0200	[thread overview]
Message-ID: <e7129715377c89b1d5c8c28d885c34dd677df45f.camel@free.fr> (raw)
In-Reply-To: <fd833ebea313c2c61bb95cd9ea1a89e05a92ae31.camel@free.fr>

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

I reported incorrectly that the bug Ireported was also present when
using the "minted" package to format source blocks.

This is incorrect : I re-checked my trials, and re-wrote another test,
which gives the ecpected result. See attached files.

This might help pinpointing the problem happening when minted is *NOT*
used.

HTH,

--
Emmanuel Charpentier

[ Previous posts : Snip... ]


[-- Attachment #2: C4.html --]
[-- Type: text/html, Size: 11225 bytes --]

[-- Attachment #3: C4.org --]
[-- Type: text/plain, Size: 1555 bytes --]

# An archi-minimal test of source blocks labelling,
# using only the built-in tools.

#+options: tex:t title:nil author:nil date:nil toc:nil
#+title: Test of source block exports

#+begin_src emacs-lisp :exports none :results none
  (setq
   org-latex-pdf-process
   (list "latexmk -pdf -pdflatex='%latex -interaction=nonstopmode -shell-escape' -bibtex -f %f")
   org-latex-listings 'minted)
  (add-to-list 'org-latex-packages-alist '("newfloat" "minted" t))
#+end_src

# #+latex_header: \usepackage[newfloat]{minted}
# #+latex_header: \usepackage{listings}

The Python block [[lst:DoFig]] generates the figure [[fig:DoFig]]

#+name: DoFig
#+begin_src python :results file :exports none
import matplotlib, numpy
matplotlib.use('Agg')
import matplotlib.pyplot as plt
fig=plt.figure(figsize=(4,2))
x=numpy.linspace(-15,15)
plt.plot(numpy.sin(x)/x)
fig.tight_layout()
plt.savefig('Fig2.png')
return 'Fig2.png'
#+end_src

#+RESULTS: DoFig
[[file:Fig2.png]]

#+name: fig:DoFig
#+caption: Figure generated by python
#+ATTR_LATEX: :height 2.5in
[[file:Fig2.png]]

# #+name: fig:DoFig
# #+caption: Figure generated by python
# #+RESULTS: DoFig
# [[file:Fig2.png]]


#+name: lst:DoFig
#+caption: Python code generating a figure
#+begin_src python :eval no :exports code :noweb yes
<<DoFig>>
#+end_src

Problem: whereas the HTML export labels the source listing as "Listing 1" and is correctly refers to 1, the PDF export labels it "Figure 2" (and points to it) *when the default ~verbatim~ method is used.* When one bothers to use ~minted~, the result is correct.

[-- Attachment #4: C4.pdf --]
[-- Type: application/pdf, Size: 60828 bytes --]

[-- Attachment #5: C4.tex --]
[-- Type: text/x-tex, Size: 1553 bytes --]

% Created 2019-04-30 mar. 23:15
% 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[newfloat]{minted}
\date{}
\title{Test of source block exports}
\hypersetup{
 pdfauthor={Emmanuel Charpentier},
 pdftitle={Test of source block exports},
 pdfkeywords={},
 pdfsubject={},
 pdfcreator={Emacs 26.1 (Org mode 9.2.3)}, 
 pdflang={English}}
\begin{document}

The Python block \ref{org471e7a4} generates the figure \ref{fig:orgb0ae5e3}

\begin{figure}[htbp]
\centering
\includegraphics[height=2.5in]{Fig2.png}
\caption{\label{fig:orgb0ae5e3}
Figure generated by python}
\end{figure}


\begin{listing}[htbp]
\begin{minted}[]{python}
import matplotlib, numpy
matplotlib.use('Agg')
import matplotlib.pyplot as plt
fig=plt.figure(figsize=(4,2))
x=numpy.linspace(-15,15)
plt.plot(numpy.sin(x)/x)
fig.tight_layout()
plt.savefig('Fig2.png')
return 'Fig2.png'
\end{minted}
\caption{\label{org471e7a4}
Python code generating a figure}
\end{listing}

Problem: whereas the HTML export labels the source listing as "Listing 1" and is correctly refers to 1, the PDF export labels it "Figure 2" (and points to it) \textbf{when the default \texttt{verbatim} method is used.} When one bothers to use \texttt{minted}, the result is correct.
\end{document}

[-- Attachment #6: Fig2.png --]
[-- Type: image/png, Size: 11763 bytes --]

      parent reply	other threads:[~2019-04-30 21:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-30  7:18 BUG: the builtin LaTeX/P DF exporter mislabels source blocks as figures Emmanuel Charpentier
2019-04-30 17:05 ` Nicolas Goaziou
2019-04-30 17:39   ` Emmanuel Charpentier
2019-04-30 17:46     ` John Kitchin
2019-04-30 18:05       ` Emmanuel Charpentier
2019-05-01 16:26     ` Nicolas Goaziou
2019-04-30 21:27 ` Emmanuel Charpentier [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e7129715377c89b1d5c8c28d885c34dd677df45f.camel@free.fr \
    --to=emm.charpentier@free.fr \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).