From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: BUG: the builtin LaTeX/P DF exporter mislabels source blocks as figures. Date: Tue, 30 Apr 2019 13:46:38 -0400 Message-ID: References: <87pnp35spi.fsf@nicolasgoaziou.fr> <93aa2902139cde9b8d0d9c5d5a1ba8b7332757fe.camel@free.fr> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000005215e40587c2fc79" Return-path: Received: from eggs.gnu.org ([209.51.188.92]:52880) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLWqG-00019F-NQ for emacs-orgmode@gnu.org; Tue, 30 Apr 2019 13:47:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLWqD-0008A8-NB for emacs-orgmode@gnu.org; Tue, 30 Apr 2019 13:46:55 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:37317) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLWqB-00088e-S3 for emacs-orgmode@gnu.org; Tue, 30 Apr 2019 13:46:52 -0400 Received: by mail-wr1-x429.google.com with SMTP id r6so22047105wrm.4 for ; Tue, 30 Apr 2019 10:46:51 -0700 (PDT) In-Reply-To: <93aa2902139cde9b8d0d9c5d5a1ba8b7332757fe.camel@free.fr> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Emmanuel Charpentier Cc: emacs-orgmode , Nicolas Goaziou --0000000000005215e40587c2fc79 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 ipython print('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 ipython print('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 < emm.charpentier@free.fr> wrote: > Hi, Nicolas ! > > Le mardi 30 avril 2019 =C3=A0 19:05 +0200, Nicolas Goaziou a =C3=A9crit : > > Hello, > > > > Emmanuel Charpentier 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=3Dsharing > > > > 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 > > --0000000000005215e40587c2fc79 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
This works as expected in LaTeX for me wi= th org-ref (you could probably use raw latex if you wanted):

=
#+caption: The first source block. label:src-1
#+BEGIN_= SRC ipython
print('Hello world')
#+END_SRC


Later we refer to the code in Listing r= ef:src-1 or ref:src-2. That is different than Figure ref:fig-1.
<= br>
#+caption: My figure. label:fig-1
[[./test.png]]


#+caption: The first source block. la= bel:src-2
#+BEGIN_SRC ipython
print('Hello world= 9;)
#+END_SRC

The downside is that for h= tml the src-block links are not numbered. I don't know how easy that wo= uld be to fix in the export functions.

John=

-----------------------------------
Professor John Kitchin=C2=A0=
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Me= llon University
Pittsburgh, PA 15213
412-268-7803


On Tue, Apr 30, 2019 at 1:40 PM Emmanuel Charpentie= r <emm.charpentier@free.fr> wrote:
Hi,= Nicolas !

Le mardi 30 avril 2019 =C3=A0 19:05 +0200, Nicolas Goaziou a =C3=A9crit : > 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 o= f 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 her= e
> > :
> > http= s://drive.google.com/drive/folders/1bQmaefiztW9ZDRNLcjOD_WbEmTg4d8dG?usp=3D= 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

--0000000000005215e40587c2fc79--