emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Emmanuel Charpentier <emm.charpentier@free.fr>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: BUG: the builtin LaTeX/P DF exporter mislabels source blocks as figures.
Date: Tue, 30 Apr 2019 19:39:24 +0200	[thread overview]
Message-ID: <93aa2902139cde9b8d0d9c5d5a1ba8b7332757fe.camel@free.fr> (raw)
In-Reply-To: <87pnp35spi.fsf@nicolasgoaziou.fr>

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

Hi, Nicolas !

Le mardi 30 avril 2019 à 19:05 +0200, Nicolas Goaziou a écrit :
> Hello,
> 
> Emmanuel Charpentier <emm.charpentier@free.fr> 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


[-- Attachment #2: C1.html --]
[-- Type: text/html, Size: 10176 bytes --]

[-- Attachment #3: C1.org --]
[-- Type: text/plain, Size: 774 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
#+property: header-args:R :session
#+title: Test of source block exports

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

#+name: DoFig
#+begin_src R :exports results :results output graphics :file Fig.png
curve(sin(x),from=-pi, to=pi)
#+end_src

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

#+name: lst:DoFig
#+caption: R code generating a figure
#+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).

[-- Attachment #4: C1.pdf --]
[-- Type: application/pdf, Size: 55457 bytes --]

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

% Created 2019-04-30 mar. 09:10
% 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{orgf2d4160} generates the figure \ref{fig:org1c384b0}:

\begin{figure}[htbp]
\centering
\includegraphics[width=.9\linewidth]{Fig.png}
\caption{\label{fig:org1c384b0}
Figure generated by R}
\end{figure}

\begin{verbatim}
curve(sin(x),from=-pi, to=pi)
\end{verbatim}
\captionof{figure}{\label{orgf2d4160}
R code generating a figure}

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}

[-- Attachment #6: Fig.png --]
[-- Type: image/png, Size: 7444 bytes --]

  reply	other threads:[~2019-04-30 17:39 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 [this message]
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 ` Correction and addition [Re: BUG: the builtin LaTeX/P DF exporter mislabels source blocks as figures.] Emmanuel Charpentier

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=93aa2902139cde9b8d0d9c5d5a1ba8b7332757fe.camel@free.fr \
    --to=emm.charpentier@free.fr \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    /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).