Dear John,
This does *not* work for me. See the attached files.
I begin to suspect a very recent bug : I'm following MELPA, which
updates about once a week. My org-version says: Org mode version 9.2.3
(9.2.3-11-g42abf5-elpaplus @ /home/charpent/.emacs.d/elpa/org-plus-
contrib-20190429/).
Cordially,
--Emmanuel Charpentier
Le mardi 30 avril 2019 à 13:46 -0400, John Kitchin a écrit :
> This works as expected in LaTeX for me with org-ref (you could
> probably use raw latex if you wanted):
> #+caption: The first source block. label:src-1#+BEGIN_SRC
> ipythonprint('Hello world')#+END_SRC
>
> Later we refer to the code in Listing ref:src-1 or ref:src-2. That is
> different than Figure ref:fig-1.
> #+caption: My figure. label:fig-1[[./test.png]]
>
> #+caption: The first source block. label:src-2#+BEGIN_SRC
> ipythonprint('Hello world')#+END_SRC
> The downside is that for html the src-block links are not numbered. I
> don't know how easy that would be to fix in the export functions.
> John
>
> -----------------------------------
> Professor John Kitchin
> Doherty Hall A207F
> Department of Chemical Engineering
> Carnegie Mellon University
> Pittsburgh, PA 15213
> 412-268-7803
> @johnkitchin
> http://kitchingroup.cheme.cmu.edu
>
>
>
> On Tue, Apr 30, 2019 at 1:40 PM Emmanuel Charpentier <
> [email protected]> wrote:
> > Hi, Nicolas !
> >
> >
> >
> > Le mardi 30 avril 2019 à 19:05 +0200, Nicolas Goaziou a écrit :
> >
> > > Hello,
> >
> > >
> >
> > > Emmanuel Charpentier <[email protected]> writes:
> >
> > >
> >
> > > > Whereas the HTML exporter correctly recognize a source block as
> >
> > > > such,
> >
> > > > the LaTeX/PDF exporter does not.
> >
> > > >
> >
> > > > This can be demonstrated in a (minimal) org file using *only*
> > the
> >
> > > > built-in tools (no external packages), where a source block is
> >
> > > > labelled
> >
> > > > as such by the HTML exporter but as a figure by the LaTeX
> >
> > > > exporter.The
> >
> > > > generated LaTeX source shows a suspicious
> >
> > > > "\captionof{figure}{\label{orgf2d4160}" in the export of the
> > source
> >
> > > > block.
> >
> > > >
> >
> > > > Further tests (not shown) show that the proble persists when
> > org-
> >
> > > > mode
> >
> > > > is set up to use the minted package for LaTeX export of source
> >
> > > > blocks
> >
> > > > (minted is indeed used, but the block is s still mislabeled).
> >
> > >
> >
> > > What LaTeX code do you suggest instead?
> >
> >
> >
> > Dunno. Maybe \captionof{listing} ? Or let minted do its thing ?
> > Anyway,
> >
> > in most cases, the code excerpts will be too long for a float ; the
> >
> > idea is to send them (unfloated but labeled/captioned) in an
> > appendix
> >
> > and point to them via a link.
> >
> >
> >
> > [ BTW : we should stop suggesting to use listings, which is
> > problematic
> >
> > for anything not strictly ASCII, bloody likely to occur at least on
> > a
> >
> > comment/prompt for most of mankind... Listingsutf8 is but a patch
> >
> > working only for (a subset of) European languages. Arabic, Hebrew,
> >
> > Asian languages : nope. Minted in (xe|lua)tex is probably more
> > usable
> >
> > (but needs --shell-escape, which can justifiably frowned upon... ].
> >
> >
> >
> > > > The org source and resulting pdf and html files are available
> > here
> >
> > > > :
> >
> > > >
> > https://drive.google.com/drive/folders/1bQmaefiztW9ZDRNLcjOD_WbEmTg4d8dG?usp=sharing
> >
> > >
> >
> > > Could you send your ECM in the ML without requiring to access
> > Google
> >
> > > Drive?
> >
> >
> >
> > Attached.
> >
> >
> >
> > But please coordinate with Bastien, who asked me just yesterday to
> >
> > avoid posting fat attachments to a message going to a lot of
> > people.
> >
> > Which I did (to no avail : the "heavy" mail went through anyway. Go
> >
> > figure.... ;-).
> >
> >
> >
> >
> >
> > > Thank you.
> >
> >
> >
> > You're welcome ;-). Thank YOU for considering scratching *MY*
> > itch...
> >
> >
> >
> > --
> >
> > Emmanuel Charpentier
> >
> >
> >
Title: Test of source block exports
The R block lst:DoFig generates the figure fig:DoFig:
![]()
Figure 1: Figure generated by R
curve(sin(x),from=-pi, to=pi)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).
Created: 2019-04-30 mar. 20:01
# 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 #+property: header-args:R :session #+title: Test of source block exports The R block ref:lst:DoFig generates the figure ref:fig:DoFig: #+name: DoFig #+begin_src R :exports results :results output graphics :file Fig.png curve(sin(x),from=-pi, to=pi) #+end_src #+caption: Figure generated by R label:fig:DoFig #+RESULTS: DoFig [[file:Fig.png]] #+caption: R code generating a figure label:lst:DoFig #+begin_src R :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).
C2.pdf
Description: Adobe PDF document% Created 2019-04-30 mar. 20:01 % 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} \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 R block \ref{lst:DoFig} generates the figure \ref{fig:DoFig}: \begin{figure}[htbp] \centering \includegraphics[width=.9\linewidth]{Fig.png} \caption{Figure generated by R \label{fig:DoFig}} \end{figure} \begin{verbatim} curve(sin(x),from=-pi, to=pi) \end{verbatim} \captionof{figure}{R code generating a figure \label{lst:DoFig}} 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). \end{document}
