From: Emmanuel Charpentier <emm.charpentier@free.fr>
To: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Problem with references to babel source blocks (possible bug).
Date: Mon, 17 Dec 2018 16:32:39 +0100 [thread overview]
Message-ID: <6b7de4cdd0226d5d69fdab829cad54831de89749.camel@free.fr> (raw)
[-- Attachment #1: Type: text/plain, Size: 1994 bytes --]
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 i way
too terse to be usable without diving in the source code and pandoc's
documentation.
Sincerely,
--
Emmanuel Charpentier
[-- Attachment #2: Min-Ref.docx --]
[-- Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document, Size: 10789 bytes --]
[-- Attachment #3: Min-Ref.org --]
[-- Type: text/plain, 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 #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-latex-export-to-pdf.pdf --]
[-- Type: application/pdf, Size: 143423 bytes --]
[-- Attachment #6: Min-Ref exported by org-odt-export-to-odt.odt --]
[-- Type: application/vnd.oasis.opendocument.text, Size: 18946 bytes --]
[-- Attachment #7: Min-Ref exported by org-pandoc-export-to-latex-pdf.pdf --]
[-- Type: application/pdf, Size: 202284 bytes --]
[-- Attachment #8: Min-Ref exported by org-pandoc-export-to-odt.odt --]
[-- Type: application/vnd.oasis.opendocument.text, Size: 17044 bytes --]
next reply other threads:[~2018-12-17 15:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-17 15:32 Emmanuel Charpentier [this message]
[not found] <1669578320.377567952.1545064721537.JavaMail.root@zimbra43-e7.priv.proxad.net>
2018-12-17 16:40 ` Problem with references to babel source blocks (possible bug) emm.charpentier
2018-12-18 17:00 ` Emmanuel Charpentier
-- strict thread matches above, loose matches on Subject: below --
2018-12-19 16:05 Emmanuel Charpentier
2018-12-19 19:26 Emmanuel Charpentier
2018-12-20 20:47 ` John Kitchin
2018-12-21 16:29 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6b7de4cdd0226d5d69fdab829cad54831de89749.camel@free.fr \
--to=emm.charpentier@free.fr \
--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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.