emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [new exporter] no \caption and \label upon export of #+BEGIN_LATEX block
@ 2012-11-10 22:02 Myles English
  2012-11-10 22:09 ` Myles English
  2012-11-10 22:52 ` Nicolas Goaziou
  0 siblings, 2 replies; 4+ messages in thread
From: Myles English @ 2012-11-10 22:02 UTC (permalink / raw)
  To: emacs-orgmode


Hello,

I'd like to use a tikz snippet in a few different documents and it would
be convenient to be able to include it in a latex document like so:

#+CAPTION: a fine figure
#+NAME:   figure:fine_figure
#+ATTR_LaTeX: width=5cm
#+BEGIN_LATEX
\input{/home/myles/tex/tikz_figure.tex}
#+END_LATEX

What is exported is just the \input line, with no \label or \caption, i.e.:

\input{/home/myles/tex/tikz_figure.tex}

I believe this was possible with current (old) exporter, based on this
thread:

http://lists.gnu.org/archive/html/emacs-orgmode/2012-10/msg00267.html

Is it currently possible or could it be added please?

On second thoughts, perhaps another way to do it would be to have a
source block make the tikz graphic as a standalone pdf/eps and then
insert it as a link to the file.  The disadvantage of that would be that
the tikz .tex file would need to be expanded to have it's own
\begin/end{document} and would loose some flexibility.  Any thoughts on
that route?

Thanks,

Myles

Org-mode version 7.9.2 (release_7.9.2-571-g359891 @ /home/myles/.emacs.d/plugins/org-mode/lisp/)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [new exporter] no \caption and \label upon export of #+BEGIN_LATEX block
  2012-11-10 22:02 [new exporter] no \caption and \label upon export of #+BEGIN_LATEX block Myles English
@ 2012-11-10 22:09 ` Myles English
  2012-11-10 22:52 ` Nicolas Goaziou
  1 sibling, 0 replies; 4+ messages in thread
From: Myles English @ 2012-11-10 22:09 UTC (permalink / raw)
  To: emacs-orgmode


Myles English writes:

> Hello,
>
> I'd like to use a tikz snippet in a few different documents and it would
> be convenient to be able to include it in a latex document like so:
>
> #+CAPTION: a fine figure
> #+NAME:   figure:fine_figure
> #+ATTR_LaTeX: width=5cm
> #+BEGIN_LATEX
> \input{/home/myles/tex/tikz_figure.tex}
> #+END_LATEX

I realise now that this is wishful thinking because org doesn't know
that the input file will result in a graphic and so doesn't know to wrap
the input file in \begin{figure} \end{figure}.

> What is exported is just the \input line, with no \label or \caption, i.e.:
>
> \input{/home/myles/tex/tikz_figure.tex}
>
> I believe this was possible with current (old) exporter, based on this
> thread:
>
> http://lists.gnu.org/archive/html/emacs-orgmode/2012-10/msg00267.html
>
> Is it currently possible or could it be added please?
>
> On second thoughts, perhaps another way to do it would be to have a
> source block make the tikz graphic as a standalone pdf/eps and then
> insert it as a link to the file.  The disadvantage of that would be that
> the tikz .tex file would need to be expanded to have it's own
> \begin/end{document} and would loose some flexibility.  Any thoughts on
> that route?
>
> Thanks,
>
> Myles
>
> Org-mode version 7.9.2 (release_7.9.2-571-g359891 @ /home/myles/.emacs.d/plugins/org-mode/lisp/)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [new exporter] no \caption and \label upon export of #+BEGIN_LATEX block
  2012-11-10 22:02 [new exporter] no \caption and \label upon export of #+BEGIN_LATEX block Myles English
  2012-11-10 22:09 ` Myles English
@ 2012-11-10 22:52 ` Nicolas Goaziou
  2012-11-13 14:59   ` Myles English
  1 sibling, 1 reply; 4+ messages in thread
From: Nicolas Goaziou @ 2012-11-10 22:52 UTC (permalink / raw)
  To: Myles English; +Cc: emacs-orgmode

Hello,

Myles English <mylesenglish@gmail.com> writes:

> I'd like to use a tikz snippet in a few different documents and it would
> be convenient to be able to include it in a latex document like so:
>
> #+CAPTION: a fine figure
> #+NAME:   figure:fine_figure
> #+ATTR_LaTeX: width=5cm
> #+BEGIN_LATEX
> \input{/home/myles/tex/tikz_figure.tex}
> #+END_LATEX
>
> What is exported is just the \input line, with no \label or \caption, i.e.:
>
> \input{/home/myles/tex/tikz_figure.tex}

Well, IMO, it doesn't make much sense to add a caption or a label to an
export block. Just write whatever you want within the block. I.e.:

    #+BEGIN_LATEX
    \caption{\label{figure:fine_figure}a fine figure}
    \input{/home/myles/tex/tikz_figure.tex}
    #+END_LATEX

Is there any downside to it?

> I believe this was possible with current (old) exporter, based on this
> thread:
>
> http://lists.gnu.org/archive/html/emacs-orgmode/2012-10/msg00267.html

This thread is about src blocks. Adding a label or a caption is fine for
them.

> On second thoughts, perhaps another way to do it would be to have a
> source block make the tikz graphic as a standalone pdf/eps and then
> insert it as a link to the file.  The disadvantage of that would be that
> the tikz .tex file would need to be expanded to have it's own
> \begin/end{document} and would loose some flexibility.  Any thoughts on
> that route?

I don't know. for my graphics, I use Asymptote src-blocks generating
links to pdf files. E.g.:

  #+NAME: app
  #+BEGIN_SRC asymptote :file application.pdf
  import graph;
  defaultpen(fontsize(10pt));
  unitsize(2cm);
  pen p=blue;
  real f(real x) { return x**2; }
  real g(real x) { return -x + 2; }
  draw(graph(f,0,1),p);
  draw(graph(g,1,2),p);
  xaxis(xmax=2.3,Ticks(Size=1mm,NoZero),Arrow(6pt));
  yaxis(ymax=1.3,Ticks(step=.5,Step=1,Size=1mm,NoZero),Arrow(6pt));
  label("$O$",(0,0),SW);
  label("$C_f$",(1.5,g(1.5)),2N,p);
  #+END_SRC

  #+BEGIN_CENTER
  #+RESULTS: app
  [[file:application.pdf]]
  #+END_CENTER


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [new exporter] no \caption and \label upon export of #+BEGIN_LATEX block
  2012-11-10 22:52 ` Nicolas Goaziou
@ 2012-11-13 14:59   ` Myles English
  0 siblings, 0 replies; 4+ messages in thread
From: Myles English @ 2012-11-13 14:59 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode


Hi Nicolas,

Thanks for your help.  I am responding with a couple of points just to
complete this thread, in case someone else is wondering about the same
thing.

Nicolas Goaziou writes:

> Myles English <mylesenglish@gmail.com> writes:
>
>> I'd like to use a tikz snippet in a few different documents and it would
>> be convenient to be able to include it in a latex document like so:
>>
>> #+CAPTION: a fine figure
>> #+NAME:   figure:fine_figure
>> #+ATTR_LaTeX: width=5cm
>> #+BEGIN_LATEX
>> \input{/home/myles/tex/tikz_figure.tex}
>> #+END_LATEX
>>
>> What is exported is just the \input line, with no \label or \caption, i.e.:
>>
>> \input{/home/myles/tex/tikz_figure.tex}
>
> Well, IMO, it doesn't make much sense to add a caption or a label to an
> export block. Just write whatever you want within the block. I.e.:
>
>     #+BEGIN_LATEX
>     \caption{\label{figure:fine_figure}a fine figure}
>     \input{/home/myles/tex/tikz_figure.tex}
>     #+END_LATEX
>
> Is there any downside to it?

One downside is that I can't then refer to it using org label syntax
[[figure:fine_figure]] and have to use the latex syntax
\autoref{figure:fine_figure}.  So it is not a problem really.  The other
downside is that it is for latex export only.  That too is not a problem
in this case.

>> I believe this was possible with current (old) exporter, based on this
>> thread:
>>
>> http://lists.gnu.org/archive/html/emacs-orgmode/2012-10/msg00267.html
>
> This thread is about src blocks. Adding a label or a caption is fine for
> them.

I also found this thread which dicusses the same thing:

http://lists.gnu.org/archive/html/emacs-orgmode/2011-10/msg00232.html

For anyone else wondering what the best way is, I think that, basically,
you have to decide whether you are going to export to latex only or to
other formats as well.  If exporting to other formats then compile the
figure in a source block, convert to png if necessary, and have the
label, caption and other attributes as org markup on a link to the
graphics file.  This takes (comparatively) a lot of marking up and
option tweaking.  If only exporting to latex then the tikz snippet,
label, caption, sizing etc are best contained in a latex block (as
Nicolas says).

>> On second thoughts, perhaps another way to do it would be to have a
>> source block make the tikz graphic as a standalone pdf/eps and then
>> insert it as a link to the file.  The disadvantage of that would be that
>> the tikz .tex file would need to be expanded to have it's own
>> \begin/end{document} and would loose some flexibility.

The latex package 'standalone' overcomes this disadvantage because you
can *both* compile the tikz figs as, well, standalone pdfs *and* include
them in the latex block using \includestandalone (which works like
\includegraphics), and the advantage is that the tikz file does not need
to be changed at all for the different uses.

>> Any thoughts on that route?
>
> I don't know. for my graphics, I use Asymptote src-blocks generating
> links to pdf files. E.g.:
>
>   #+NAME: app
>   #+BEGIN_SRC asymptote :file application.pdf
>   import graph;
>   defaultpen(fontsize(10pt));
>   unitsize(2cm);
>   pen p=blue;
>   real f(real x) { return x**2; }
>   real g(real x) { return -x + 2; }
>   draw(graph(f,0,1),p);
>   draw(graph(g,1,2),p);
>   xaxis(xmax=2.3,Ticks(Size=1mm,NoZero),Arrow(6pt));
>   yaxis(ymax=1.3,Ticks(step=.5,Step=1,Size=1mm,NoZero),Arrow(6pt));
>   label("$O$",(0,0),SW);
>   label("$C_f$",(1.5,g(1.5)),2N,p);
>   #+END_SRC
>
>   #+BEGIN_CENTER
>   #+RESULTS: app
>   [[file:application.pdf]]
>   #+END_CENTER

Thanks for this example I will surely find a use for it.

Myles

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-11-13 14:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-10 22:02 [new exporter] no \caption and \label upon export of #+BEGIN_LATEX block Myles English
2012-11-10 22:09 ` Myles English
2012-11-10 22:52 ` Nicolas Goaziou
2012-11-13 14:59   ` Myles English

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).