emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Emmanuel Charpentier <emanuel.charpentier@gmail.com>
To: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Problem with references to babel source blocks (possible bug).
Date: Wed, 19 Dec 2018 17:05:11 +0100	[thread overview]
Message-ID: <CAFG8T6UXZm0eK5pODHy=7rsb83LtSJDXhK-++g6qejd46Zn2wg@mail.gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 2094 bytes --]

[ Sixth '!) attempt to send this question to emacs-orgmode. Sorry for the
possible duplicates... ]

I wish to be able to reference (i. e cross-references, lists) both some
tables or figures AND the code producing the objects.

To this effect, I added (distinct) #+caption:s to the source blocks AND
to the results, adorned with (distinct) org-ref's labels. An example is
included in the enclosed file Min-Ref.org.

The comparison of this source, the LaTeX code obtained by org-latex
export-to latex (Min-Ref.tex) and the resultant PDF (Min-Ref exported
by org-latex-export-to-pdf.pdf) show that the labels attributed to
source blocks are mislabeled as figures. Furthermore, while the org
source requests a list of figure, a list of table and a list of
listings (in that order), the list of figures appears *after* the list
of tables.

I am tempted to conclude that there is some confusion between figures
and listings. Further attempts tend to show that the problem may live n
the core org's code, rather than any specific exporter :

The ODT "native" exporter (org-odt-export-to-odt) is much less capable,
as shown in Min-Ref exported by org-odt-export-to-odt.odt.

Attempts to export via Pandoc to PDF (Min-Ref exported by org-pandoc-
export-to-latex-pdf.pdf), ODT (Min-Ref exported by org-pandoc-export-
to-odt.odt) and DOCX (Min-Ref.docx) show that these exporters may need
some specific configurations in order to be even vaguely usable.

Previous trials, using #+names: rather than org-ref's labels, gave
similar failures. If needed, I can reproduce these trials.

So I have a couple questions :

1) Is the confusion of source blocks and figures a bug, or do I miss a
subtle point ?

2) Is there some introductory material to the care and feeding of ox-
pandoc demonstrating the use of this exporter's options to enable the
addition of the needed features (figure inclusion, tables of tables /
figures / listings, etc...) ? The "manual" available as a README is way
too terse to be usable without diving in the source code and pandoc's
documentation.

Sincerely,

--
Emmanuel Charpentier

[-- Attachment #1.2: Type: text/html, Size: 8637 bytes --]

[-- Attachment #2: Min-Ref.org --]
[-- Type: application/octet-stream, Size: 1645 bytes --]


#+options: toc:nil
#+property: header-args:python :session
#+language: fr

#+title: What's up with references ?
#+author:
#+date: December 2018

#+toc: headlines
#+toc: figures
#+toc: tables
#+toc: listings

* Some reference samples

This is created using =org-ref= 's =label= 's and =ref= 's.

** A reference...

... to cite:gelmanBayesianDataAnalysis2013 ,a /good/ textbook.

** A table

A Python block producing a (silly) table.

#+caption: A (silly) Python block. label:lst:Python1
#+BEGIN_SRC python :results table :exports both
[[u+str(v) for v in range(1,4)] for u in ["a", "b"]]
#+END_SRC

#+caption: A (silly) Python table. label:tab:Python1
#+RESULTS:
| a1 | a2 | a3 |
| b1 | b2 | b3 |

The table ref:tab:Python1 is produced by the code ref:lst:Python1.

** A figure

A Python block producing a figure.

#+caption: A Python block producing a figure. label:lst:Python2
#+BEGIN_SRC python :results file :exports both
import matplotlib.pyplot as plt, numpy as np
from sympy import *
x=symbols("x")
f=lambda x:sin(x)/x
t=np.arange(-6*np.pi,6*np.pi, 0.1)
ft=[f(u) for u in t]
fig=plt.figure(figsize=(3,2))
plt.plot(t, ft, "b-")
fig.tight_layout()
plt.savefig("tstfig.pdf")
"tstfig.pdf"
#+END_SRC

#+caption: A (not so silly) figure produced by Python. label:fig:Python2
#+RESULTS:
[[file:tstfig.pdf]]

The figure ref:fig:Python2 is produced by the code ref:lst:Python2.

[[bibliographystyle:vancouver]]
[[bibliography:Minimal.bib]]

# Local Variables:
# org-latex-packages-alist: (("AUTO" "babel" t ("pdflatex")) ("AUTO" "polyglossia" t ("xelatex" "lualatex")))
# org-latex-pdf-process: ("latexmk -shell-escape -bibtex -f -pdf %f")
# End:

[-- Attachment #3: Min-Ref.docx --]
[-- Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document, Size: 10789 bytes --]

[-- Attachment #4: Min-Ref.tex --]
[-- Type: text/x-tex, Size: 2236 bytes --]

% Created 2018-12-17 lun. 15:49
% 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[frenchb]{babel}
\date{December 2018}
\title{What's up with references ?}
\hypersetup{
 pdfauthor={},
 pdftitle={What's up with references ?},
 pdfkeywords={},
 pdfsubject={},
 pdfcreator={Emacs 27.0.50 (Org mode 9.1.14)}, 
 pdflang={Frenchb}}
\begin{document}

\maketitle
\tableofcontents
\listoftables
\listoffigures

\section{Some reference samples}
\label{sec:orgfe4b8ad}

This is created using \texttt{org-ref} 's \texttt{label} 's and \texttt{ref} 's.

\subsection{A reference\ldots{}}
\label{sec:org22891f6}

\ldots{} to \cite{gelmanBayesianDataAnalysis2013} ,a \emph{good} textbook.

\subsection{A table}
\label{sec:org844d514}

A Python block producing a (silly) table.

\begin{verbatim}
[[u+str(v) for v in range(1,4)] for u in ["a", "b"]]
\end{verbatim}
\captionof{figure}{A (silly) Python block. \label{lst:Python1}}

\begin{table}[htbp]
\caption{A (silly) Python table. \label{tab:Python1}}
\centering
\begin{tabular}{lll}
a1 & a2 & a3\\
b1 & b2 & b3\\
\end{tabular}
\end{table}

The table \ref{tab:Python1} is produced by the code \ref{lst:Python1}.

\subsection{A figure}
\label{sec:orgf75a27d}

A Python block producing a figure.

\begin{verbatim}
import matplotlib.pyplot as plt, numpy as np
from sympy import *
x=symbols("x")
f=lambda x:sin(x)/x
t=np.arange(-6*np.pi,6*np.pi, 0.1)
ft=[f(u) for u in t]
fig=plt.figure(figsize=(3,2))
plt.plot(t, ft, "b-")
fig.tight_layout()
plt.savefig("tstfig.pdf")
"tstfig.pdf"
\end{verbatim}
\captionof{figure}{A Python block producing a figure. \label{lst:Python2}}

\begin{figure}[htbp]
\centering
\includegraphics[width=.9\linewidth]{tstfig.pdf}
\caption{A (not so silly) figure produced by Python. \label{fig:Python2}}
\end{figure}

The figure \ref{fig:Python2} is produced by the code \ref{lst:Python2}.

\bibliographystyle{vancouver}
\bibliography{Minimal}
\end{document}

[-- Attachment #5: Min-Ref exported by org-pandoc-export-to-odt.odt --]
[-- Type: application/vnd.oasis.opendocument.text, Size: 17044 bytes --]

[-- Attachment #6: Min-Ref exported by org-latex-export-to-pdf.pdf --]
[-- Type: application/pdf, Size: 143423 bytes --]

[-- Attachment #7: Min-Ref exported by org-odt-export-to-odt.odt --]
[-- Type: application/vnd.oasis.opendocument.text, Size: 18946 bytes --]

[-- Attachment #8: Min-Ref exported by org-pandoc-export-to-latex-pdf.pdf --]
[-- Type: application/pdf, Size: 202284 bytes --]

             reply	other threads:[~2018-12-19 16:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-19 16:05 Emmanuel Charpentier [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-12-19 19:26 Problem with references to babel source blocks (possible bug) Emmanuel Charpentier
2018-12-20 20:47 ` John Kitchin
2018-12-21 16:29   ` Emmanuel Charpentier
     [not found] <1669578320.377567952.1545064721537.JavaMail.root@zimbra43-e7.priv.proxad.net>
2018-12-17 16:40 ` emm.charpentier
2018-12-18 17:00 ` Emmanuel Charpentier
2018-12-17 15:32 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='CAFG8T6UXZm0eK5pODHy=7rsb83LtSJDXhK-++g6qejd46Zn2wg@mail.gmail.com' \
    --to=emanuel.charpentier@gmail.com \
    --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).