From mboxrd@z Thu Jan 1 00:00:00 1970 From: shripad sinari Subject: Re: Passing an image reference to source code block Date: Tue, 27 Dec 2016 11:12:17 -0700 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11416284ea66d10544a7caea Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41134) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cLwEW-0005kt-Nv for emacs-orgmode@gnu.org; Tue, 27 Dec 2016 13:12:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cLwEV-0006ks-0U for emacs-orgmode@gnu.org; Tue, 27 Dec 2016 13:12:20 -0500 Received: from mail-qt0-x231.google.com ([2607:f8b0:400d:c0d::231]:36205) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cLwEU-0006ko-QD for emacs-orgmode@gnu.org; Tue, 27 Dec 2016 13:12:18 -0500 Received: by mail-qt0-x231.google.com with SMTP id k15so93636337qtg.3 for ; Tue, 27 Dec 2016 10:12:18 -0800 (PST) In-Reply-To: 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: John Kitchin Cc: Orgmode Mailing List --001a11416284ea66d10544a7caea Content-Type: text/plain; charset=UTF-8 Hello John, Thanks for the suggestion. The proposed solution does not work since the recent org versions generate their own labels and the label value cannot be predetermined. See the LaTeX code generated by the above example with your suggestion included: ----x-----------------x---- \section{Section name} \label{sec:org62816be} some text \begin{figure}[htbp] \centering \includegraphics[width=.9\linewidth]{img.jpg} \caption{\label{fig:org43b3d3f} Fig Caption} \end{figure} some reference to figure \ref{fig:org43b3d3f} \section{other section} \label{sec:org1e9d137} reference to Section \ref{sec:org62816be} % latex table generated in R 3.3.1 by xtable 1.8-2 package % Tue Dec 27 10:56:43 2016 \begin{table}[ht] \centering \begin{tabular}{rrr} \hline & Time & demand \\ \hline 1 & 1.00 & 8.30 \\ 2 & 2.00 & 10.30 \\ 3 & 3.00 & 19.00 \\ 4 & 4.00 & 16.00 \\ 5 & 5.00 & 15.60 \\ 6 & 7.00 & 19.80 \\ \hline \end{tabular} \caption{Link the image \ref{fig:image} to this table} \end{table} \end{document} ----x-----------------x---- the difference is the image is labelled "fig:org43b3d3f" and not "fig:image". Is there a way to solve this using CUSTOM_ID? Or is there a very different approach to the way such table should be generated and then org-caption should be used? Any pointers are appreciated. I believe this is common requirement in scientific writing which is what I do most often. I use orgmode to write papers. Till org version 8.2.10 at least I had a workaround in the following sense: ----x-----------------x---- * Section name some text #+CAPTION: Fig Caption #+LABEL: fig:image [[file:img.jpg]] some reference to figure [[fig:image]] * other section reference to Section [[Section name]] #+BEGIN_SRC R :session *sample* default :exports results :results output latex :tangle yes :var plot="\\\\ref{fig:image}" library(xtable) print(xtable(BOD , caption = paste("Link the image", plot,"to this table"))) #+END_SRC ----x-----------------x---- which produced the following latex code: ----x-----------------x---- \begin{document} \maketitle \tableofcontents \section{Section name} \label{sec-1} some text \begin{figure}[htb] \centering \includegraphics[width=.9\linewidth]{img.jpg} \caption{\label{fig:image}Fig Caption} \end{figure} some reference to figure \ref{fig:image} \section{other section} \label{sec-2} reference to Section \ref{sec-1} % latex table generated in R 3.3.1 by xtable 1.8-2 package % Tue Dec 27 11:08:40 2016 \begin{table}[ht] \centering \begin{tabular}{rrr} \hline & Time & demand \\ \hline 1 & 1.00 & 8.30 \\ 2 & 2.00 & 10.30 \\ 3 & 3.00 & 19.00 \\ 4 & 4.00 & 16.00 \\ 5 & 5.00 & 15.60 \\ 6 & 7.00 & 19.80 \\ \hline \end{tabular} \caption{Link the image \ref{fig:image} to this table} \end{table} % Emacs 24.5.1 (Org mode 8.2.10) \end{document} ----x-----------------x---- This code compiles to the desired document. Thanks and regards, Shripad Tucson, AZ On Tue, Dec 27, 2016 at 9:05 AM, John Kitchin wrote: > Can you pass \ref{fig:image} in? I think that is what you would do in > Latex. > > > On Mon, Dec 26, 2016 at 7:00 PM shripad sinari > wrote: > >> Hello all, >> I would like to know if there is a way to pass a reference for a figure >> to a source block as in the following example: >> >> ----x-----------x--- >> >> * Section name >> >> some text >> #+CAPTION: Fig Caption >> #+NAME: fig:image >> [[file:img.jpg]] >> some reference to figure [[fig:image]] >> >> * other section >> reference to Section [[Section name]] >> >> #+BEGIN_SRC R :session *sample* default :exports results :results output >> latex :tangle yes :var plot=[[fig:image]] >> library(xtable) >> print(xtable(BOD >> , caption = paste("Link the image", plot,"to this table"))) >> #+END_SRC >> >> >> ----x-----------x--- >> >> I would like the caption of the table to point to the image, at the point >> where the word "plot" is located, in LaTeX export of the org file. >> >> Any help or other workarounds are appreciated. I am using org version >> 9.0.3 in GNU Emacs 24.5.1. >> >> Thanks for your help and regards, >> >> Shripad >> Tucson, AZ >> >> >> >> >> --001a11416284ea66d10544a7caea Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hello John,
Th= anks for the suggestion. The proposed solution does not work since the rece= nt org versions generate their own labels and the label value cannot be pre= determined. See the LaTeX code generated by the above example with your sug= gestion included:

----x-----------------x----

\section{= Section name}
\label{sec:org62816be}
some text
\begin{figure}[htbp= ]
\centering
\includegraphics[width=3D.9\linewidth]{img.jpg}
\capt= ion{\label{fig:org43b3d3f}
Fig Caption}
\end{figure}
some referenc= e to figure \ref{fig:org43b3d3f}
\section{other section}
\label{sec:= org1e9d137}
reference to Section \ref{sec:org62816be}

% latex ta= ble generated in R 3.3.1 by xtable 1.8-2 package
% Tue Dec 27 10:56:43 2= 016
\begin{table}[ht]
\centering
\begin{tabular}{rrr}
=C2=A0 \h= line
=C2=A0& Time & demand \\
=C2=A0 \hline
1 & 1.00 = & 8.30 \\
=C2=A0 2 & 2.00 & 10.30 \\
=C2=A0 3 & 3.0= 0 & 19.00 \\
=C2=A0 4 & 4.00 & 16.00 \\
=C2=A0 5 & = 5.00 & 15.60 \\
=C2=A0 6 & 7.00 & 19.80 \\
=C2=A0=C2=A0= \hline
\end{tabular}
\caption{Link the image \ref{fig:image} to this= table}
\end{table}
\end{document}


----x-----------= ------x----

the difference is the image is labelled "fig:= org43b3d3f" and not "fig:image".

Is there a wa= y to solve this using CUSTOM_ID? Or is there a very different approach to t= he way such table should be generated and then org-caption should be used?<= br>
Any pointers are appreciated.

I believe this= is common requirement in scientific writing which is what I do most often.= I use orgmode to write papers. Till org version 8.2.10 at least I had a wo= rkaround in the following sense:

----x-----------------x----

= * Section name
some text
#+CAPTION: Fig Caption
#+LABEL: fig:image=
[[file:img.jpg]]
some reference to figure [[fig:image]]
* other = section
reference to Section [[Section name]]

#+BEGIN_SRC R :ses= sion *sample* default :exports results :results output latex :tangle yes :v= ar plot=3D"\\\\ref{fig:image}"
=C2=A0 library(xtable)
=C2= =A0 print(xtable(BOD
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 , caption =3D paste("Link the image", plot,= "to this table")))
#+END_SRC

----x-----------------x---= -

which produced the following latex code:

----x--= ---------------x----

\begin{document}

\maketitle
\tableofc= ontents

\section{Section name}
\label{sec-1}
some text
\beg= in{figure}[htb]
\centering
\includegraphics[width=3D.9\linewidth]{img= .jpg}
\caption{\label{fig:image}Fig Caption}
\end{figure}
some ref= erence to figure \ref{fig:image}
\section{other section}
\label{sec-= 2}
reference to Section \ref{sec-1}

=C2=A0% latex table generate= d in R 3.3.1 by xtable 1.8-2 package
% Tue Dec 27 11:08:40 2016
\begi= n{table}[ht]
\centering
\begin{tabular}{rrr}
=C2=A0 \hline
=C2= =A0& Time & demand \\
=C2=A0 \hline
1 & 1.00 & 8.30 = \\
=C2=A0 2 & 2.00 & 10.30 \\
=C2=A0 3 & 3.00 & 19.= 00 \\
=C2=A0 4 & 4.00 & 16.00 \\
=C2=A0 5 & 5.00 & = 15.60 \\
=C2=A0 6 & 7.00 & 19.80 \\
=C2=A0=C2=A0 \hline
= \end{tabular}
\caption{Link the image \ref{fig:image} to this table} \end{table}
% Emacs 24.5.1 (Org mode 8.2.10)
\end{document}

<= br>----x-----------------x----


This code compiles to = the desired document.

Thanks and regards,
<= div>

=
Shripad
Tucson, AZ
=

On Tue, Dec 27, 2016 at 9:05 AM, John Kitchi= n <jkitchin@andrew.cmu.edu> wrote:
Can you pass \ref{fig:image} in? I think that is what= you would do in Latex.=C2=A0
=


On Mon, Dec 26, 201= 6 at 7:00 PM shripad sinari <shripad.sinari@gmail.com> wrote:
Hello all,
I would like to know if there i= s a way to pass a reference for a figure to a source block as in the follow= ing example:

----x-----------x---

* Secti= on name

some text
#+CAPTION: Fig Caption
#+NAME:= fig:image
[[file:img.jpg]]
some reference to figure [[fig:ima= ge]]

* other section
reference to Section [[Section name]]

#+BEGIN_SRC R :se= ssion *sample* default :exports results :results output latex :tangle yes := var plot=3D[[fig:image]]
=C2=A0= library(xtable)
=C2=A0 print(x= table(BOD
=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 , caption =3D paste(&qu= ot;Link the image", plot,"to this table")))
#+END_SRC


----x-----------x---

I would like the = caption of the table to point to the image, at the point where the word &qu= ot;plot" is located, in LaTeX export of the org file.

Any help or other workaro= unds are appreciated. I am using org version 9.0.3 in GNU Emacs 24.5.1.

Thanks for y= our help and regards,

Shripad
Tucson, AZ


=



--001a11416284ea66d10544a7caea--