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... ]Title: Test of source block exports
The Python block 1 generates the figure 1
Figure 1: Figure generated by 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'
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.
Created: 2019-04-30 mar. 23:15
# 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.
C4.pdf
Description: Adobe PDF document
% 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}