emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Exporting multiple images in a float (LaTeX)
@ 2015-08-06 16:42 Suvayu Ali
  2015-08-06 22:27 ` Rasmus
  0 siblings, 1 reply; 13+ messages in thread
From: Suvayu Ali @ 2015-08-06 16:42 UTC (permalink / raw)
  To: Emacs Org mode

Hi,

Is there an easy way to export multiple images wrapped in a single
floating environment (e.g. figure) when exporting to LaTeX?  For how
many years I have been doing this:

  #+name: fig:myfig1
  #+caption: This is a single figure, entered in the usual way.
  file:myfig1.pdf

  #+begin_latex
  \begin{figure}[htb]
    \centering
    \includegraphics[width=0.8\linewidth]{myfig2.pdf}
    \includegraphics[width=0.8\linewidth]{myfig3.pdf}
    \caption{\label{fig:myfig23} Two images in one floating environment.}
  \end{figure}
  #+end_latex

It would be great if I could avoid the LaTeX block for the second case.
An intuitive way might be, when two figures are not separated by empty
lines, treat them as part of the same float.  The above would translate
to:

  #+name: fig:myfig23
  #+caption: Two images in one floating environment.
  #+attr_latex: :width 0.8\linewidth
  file:myfig2.pdf
  file:myfig3.pdf

Presently the above is exported as:

  \begin{figure}[htb]
    \centering
    \includegraphics[width=.8\linewidth]{myfig2.pdf}
    \caption{\label{fig:myfig23} Two images in one floating environment.}
  \end{figure}
  \begin{figure}[htb]
    \centering
    \includegraphics[width=.8\linewidth]{myfig3.pdf}
    \caption{\label{fig:myfig23} Two images in one floating environment.}
  \end{figure}

Actually, the above could probably be considered incorrect.  The figures
have the same caption and labels, which is for all practical purposes
incorrect.  Am I missing something?  Is my "expectation" reasonable?

Cheers,

-- 
Suvayu

Open source is the future. It sets us free.

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

* Re: Exporting multiple images in a float (LaTeX)
  2015-08-06 16:42 Exporting multiple images in a float (LaTeX) Suvayu Ali
@ 2015-08-06 22:27 ` Rasmus
  2015-08-06 22:31   ` Rasmus
  0 siblings, 1 reply; 13+ messages in thread
From: Rasmus @ 2015-08-06 22:27 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

Suvayu Ali <fatkasuvayu+linux@gmail.com> writes:

>   #+name: fig:myfig1
>   #+caption: This is a single figure, entered in the usual way.
>
>   file:myfig1.pdf
>
>   #+begin_latex
>   \begin{figure}[htb]
>     \centering
>     \includegraphics[width=0.8\linewidth]{myfig2.pdf}
>     \includegraphics[width=0.8\linewidth]{myfig3.pdf}
>     \caption{\label{fig:myfig23} Two images in one floating environment.}
>   \end{figure}
>   #+end_latex


You should probably use subcaption for that.  If so see maybe here:

    http://thread.gmane.org/gmane.emacs.orgmode/92820

For archiving the above you could just use a special block

     #+caption: foo
     #+attr_latex: :options [htb]
     #+begin_figure
     [[file:fig2.png]]
     [[file:fig3.png]]
     #+end_figure

Rasmus

-- 
Sådan en god dansk lagereddike kan man slet ikke bruge mere

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

* Re: Exporting multiple images in a float (LaTeX)
  2015-08-06 22:27 ` Rasmus
@ 2015-08-06 22:31   ` Rasmus
  2015-08-07  4:24     ` Suvayu Ali
  0 siblings, 1 reply; 13+ messages in thread
From: Rasmus @ 2015-08-06 22:31 UTC (permalink / raw)
  To: emacs-orgmode

Rasmus <rasmus@gmx.us> writes:

> Hi,
>
> Suvayu Ali <fatkasuvayu+linux@gmail.com> writes:
>
>>   #+name: fig:myfig1
>>   #+caption: This is a single figure, entered in the usual way.
>>
>>   file:myfig1.pdf
>>
>>   #+begin_latex
>>   \begin{figure}[htb]
>>     \centering
>>     \includegraphics[width=0.8\linewidth]{myfig2.pdf}
>>     \includegraphics[width=0.8\linewidth]{myfig3.pdf}
>>     \caption{\label{fig:myfig23} Two images in one floating environment.}
>>   \end{figure}
>>   #+end_latex
>
>
> You should probably use subcaption for that.  If so see maybe here:
>
>     http://thread.gmane.org/gmane.emacs.orgmode/92820
>
> For archiving the above you could just use a special block
>
>      #+caption: foo
>      #+attr_latex: :options [htb]
>
>      #+begin_figure
>      [[file:fig2.png]]
>      [[file:fig3.png]]
>      #+end_figure

Also, note that :float nil now handles captions and that you should be
able to give arbitrary citations commands.  Thus, you should be able to
recreate any old latex structure for images.

Rasmus

-- 
With monopolies the cake is a lie!

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

* Re: Exporting multiple images in a float (LaTeX)
  2015-08-06 22:31   ` Rasmus
@ 2015-08-07  4:24     ` Suvayu Ali
  2015-08-07 13:28       ` Eric S Fraga
  0 siblings, 1 reply; 13+ messages in thread
From: Suvayu Ali @ 2015-08-07  4:24 UTC (permalink / raw)
  To: emacs-orgmode

Hi Rasmus,

On Fri, Aug 07, 2015 at 12:31:37AM +0200, Rasmus wrote:
> Rasmus <rasmus@gmx.us> writes:
> > Suvayu Ali <fatkasuvayu+linux@gmail.com> writes:
> >
> >>   #+name: fig:myfig1
> >>   #+caption: This is a single figure, entered in the usual way.
> >>
> >>   file:myfig1.pdf
> >>
> >>   #+begin_latex
> >>   \begin{figure}[htb]
> >>     \centering
> >>     \includegraphics[width=0.8\linewidth]{myfig2.pdf}
> >>     \includegraphics[width=0.8\linewidth]{myfig3.pdf}
> >>     \caption{\label{fig:myfig23} Two images in one floating environment.}
> >>   \end{figure}
> >>   #+end_latex
> >
> >
> > You should probably use subcaption for that.  If so see maybe here:
> >
> >     http://thread.gmane.org/gmane.emacs.orgmode/92820

I usually don't need multiple captions, just one caption for a float
with multiple very closely related images.

> > For archiving the above you could just use a special block
> >
> >      #+caption: foo
> >      #+attr_latex: :options [htb]
> >
> >      #+begin_figure
> >      [[file:fig2.png]]
> >      [[file:fig3.png]]
> >      #+end_figure

This is very nice, thank you!  I think this will do it for me.  I have a
small question, is there a better way to add a % after the first image
in the above case other than adding a snippet?

  #+begin_figure
  #+attr_latex: :width 0.45\linewidth
  [[file:myfig2.pdf]]@@l:%@@
  [[file:myfig3.pdf]]
  #+end_figure

> Also, note that :float nil now handles captions and that you should be
> able to give arbitrary citations commands.  Thus, you should be able to
> recreate any old latex structure for images.

I'm not sure I understand the comment about arbitrary citation commands.

Cheers,

-- 
Suvayu

Open source is the future. It sets us free.

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

* Re: Exporting multiple images in a float (LaTeX)
  2015-08-07  4:24     ` Suvayu Ali
@ 2015-08-07 13:28       ` Eric S Fraga
  2015-08-07 14:14         ` Suvayu Ali
  0 siblings, 1 reply; 13+ messages in thread
From: Eric S Fraga @ 2015-08-07 13:28 UTC (permalink / raw)
  To: emacs-orgmode

On Friday,  7 Aug 2015 at 06:24, Suvayu Ali wrote:

[...]

> This is very nice, thank you!  I think this will do it for me.  I have a
> small question, is there a better way to add a % after the first image
> in the above case other than adding a snippet?
>
>   #+begin_figure
>   #+attr_latex: :width 0.45\linewidth
>   [[file:myfig2.pdf]]@@l:%@@
>   [[file:myfig3.pdf]]
>   #+end_figure

If you want the % simply to have LaTeX ignore the line end, you could
put the figures on the same line, such as

#+begin_figure
#+attr_latex: :width 0.45\linewidth
[[file:myfig2.pdf]][[file:myfig3.pdf]]
#+end_figure

(untested)
-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.50.2, Org release_8.3beta-1315-ga3b2b7

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

* Re: Exporting multiple images in a float (LaTeX)
  2015-08-07 13:28       ` Eric S Fraga
@ 2015-08-07 14:14         ` Suvayu Ali
  2015-08-07 14:23           ` Rasmus
  0 siblings, 1 reply; 13+ messages in thread
From: Suvayu Ali @ 2015-08-07 14:14 UTC (permalink / raw)
  To: emacs-orgmode

On Fri, Aug 07, 2015 at 02:28:58PM +0100, Eric S Fraga wrote:
> On Friday,  7 Aug 2015 at 06:24, Suvayu Ali wrote:
> 
> [...]
> 
> > This is very nice, thank you!  I think this will do it for me.  I have a
> > small question, is there a better way to add a % after the first image
> > in the above case other than adding a snippet?
> >
> >   #+begin_figure
> >   #+attr_latex: :width 0.45\linewidth
> >   [[file:myfig2.pdf]]@@l:%@@
> >   [[file:myfig3.pdf]]
> >   #+end_figure
> 
> If you want the % simply to have LaTeX ignore the line end, you could
> put the figures on the same line, such as
> 
> #+begin_figure
> #+attr_latex: :width 0.45\linewidth
> [[file:myfig2.pdf]][[file:myfig3.pdf]]
> #+end_figure

Cool, that works :).  Thanks a lot Eric.

-- 
Suvayu

Open source is the future. It sets us free.

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

* Re: Exporting multiple images in a float (LaTeX)
  2015-08-07 14:14         ` Suvayu Ali
@ 2015-08-07 14:23           ` Rasmus
  2015-08-07 16:19             ` Eric S Fraga
  2015-08-07 17:00             ` Suvayu Ali
  0 siblings, 2 replies; 13+ messages in thread
From: Rasmus @ 2015-08-07 14:23 UTC (permalink / raw)
  To: emacs-orgmode

Suvayu Ali <fatkasuvayu+linux@gmail.com> writes:

> On Fri, Aug 07, 2015 at 02:28:58PM +0100, Eric S Fraga wrote:
>> On Friday,  7 Aug 2015 at 06:24, Suvayu Ali wrote:
>> 
>
>> [...]
>> 
>> > This is very nice, thank you!  I think this will do it for me.  I have a
>> > small question, is there a better way to add a % after the first image
>> > in the above case other than adding a snippet?
>> >
>> >   #+begin_figure
>> >   #+attr_latex: :width 0.45\linewidth
>> >   [[file:myfig2.pdf]]@@l:%@@
>> >   [[file:myfig3.pdf]]
>> >   #+end_figure
>> 
>> If you want the % simply to have LaTeX ignore the line end, you could
>> put the figures on the same line, such as
>> 
>> #+begin_figure
>> #+attr_latex: :width 0.45\linewidth
>> [[file:myfig2.pdf]][[file:myfig3.pdf]]
>> #+end_figure
>
> Cool, that works :).  Thanks a lot Eric.

I guess there would also be no loss from actually inserting a "%" after
\includegraphics[·]{·} in ox-latex.

-- 
The second rule of Fight Club is: You do not talk about Fight Club

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

* Re: Exporting multiple images in a float (LaTeX)
  2015-08-07 14:23           ` Rasmus
@ 2015-08-07 16:19             ` Eric S Fraga
  2015-08-07 17:04               ` Suvayu Ali
  2015-08-08 19:23               ` Rasmus
  2015-08-07 17:00             ` Suvayu Ali
  1 sibling, 2 replies; 13+ messages in thread
From: Eric S Fraga @ 2015-08-07 16:19 UTC (permalink / raw)
  To: Rasmus; +Cc: emacs-orgmode

On Friday,  7 Aug 2015 at 16:23, Rasmus wrote:

[...]

> I guess there would also be no loss from actually inserting a "%" after
> \includegraphics[·]{·} in ox-latex.

Except that then the suggestion I just made would not work and would in
fact be quite confusing as the second figure would be lost in the
export?

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.50.2, Org release_8.3beta-1315-ga3b2b7

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

* Re: Exporting multiple images in a float (LaTeX)
  2015-08-07 14:23           ` Rasmus
  2015-08-07 16:19             ` Eric S Fraga
@ 2015-08-07 17:00             ` Suvayu Ali
  1 sibling, 0 replies; 13+ messages in thread
From: Suvayu Ali @ 2015-08-07 17:00 UTC (permalink / raw)
  To: emacs-orgmode

On Fri, Aug 07, 2015 at 04:23:48PM +0200, Rasmus wrote:
> Suvayu Ali <fatkasuvayu+linux@gmail.com> writes:
> > On Fri, Aug 07, 2015 at 02:28:58PM +0100, Eric S Fraga wrote:
> >> On Friday,  7 Aug 2015 at 06:24, Suvayu Ali wrote:
> >> 
> >> > This is very nice, thank you!  I think this will do it for me.  I have a
> >> > small question, is there a better way to add a % after the first image
> >> > in the above case other than adding a snippet?
> >> >
> >> >   #+begin_figure
> >> >   #+attr_latex: :width 0.45\linewidth
> >> >   [[file:myfig2.pdf]]@@l:%@@
> >> >   [[file:myfig3.pdf]]
> >> >   #+end_figure
> >> 
> >> If you want the % simply to have LaTeX ignore the line end, you could
> >> put the figures on the same line, such as
> >> 
> >> #+begin_figure
> >> #+attr_latex: :width 0.45\linewidth
> >> [[file:myfig2.pdf]][[file:myfig3.pdf]]
> >> #+end_figure
> >
> > Cool, that works :).  Thanks a lot Eric.
> 
> I guess there would also be no loss from actually inserting a "%" after
> \includegraphics[·]{·} in ox-latex.

I would agree with that :).

-- 
Suvayu

Open source is the future. It sets us free.

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

* Re: Exporting multiple images in a float (LaTeX)
  2015-08-07 16:19             ` Eric S Fraga
@ 2015-08-07 17:04               ` Suvayu Ali
  2015-08-08 19:23               ` Rasmus
  1 sibling, 0 replies; 13+ messages in thread
From: Suvayu Ali @ 2015-08-07 17:04 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Rasmus

On Fri, Aug 07, 2015 at 05:19:18PM +0100, Eric S Fraga wrote:
> On Friday,  7 Aug 2015 at 16:23, Rasmus wrote:
> 
> [...]
> 
> > I guess there would also be no loss from actually inserting a "%" after
> > \includegraphics[·]{·} in ox-latex.
> 
> Except that then the suggestion I just made would not work and would in
> fact be quite confusing as the second figure would be lost in the
> export?

True, I guess the question is which is more natural.

  file:foo.pdf
  file:bar.pdf

or,

  [[file:foo.pdf]] [[file:bar.pdf]]

One thing I can think of, the second option can be confusing in the Org
buffer when you do not want the space in between.

-- 
Suvayu

Open source is the future. It sets us free.

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

* Re: Exporting multiple images in a float (LaTeX)
  2015-08-07 16:19             ` Eric S Fraga
  2015-08-07 17:04               ` Suvayu Ali
@ 2015-08-08 19:23               ` Rasmus
  2015-08-08 23:56                 ` Suvayu Ali
  2015-08-10 11:59                 ` Eric S Fraga
  1 sibling, 2 replies; 13+ messages in thread
From: Rasmus @ 2015-08-08 19:23 UTC (permalink / raw)
  To: emacs-orgmode

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> On Friday,  7 Aug 2015 at 16:23, Rasmus wrote:
>
> [...]
>
>> I guess there would also be no loss from actually inserting a "%" after
>> \includegraphics[·]{·} in ox-latex.
>
> Except that then the suggestion I just made would not work and would in
> fact be quite confusing as the second figure would be lost in the
> export?

But we can insert "%\n" and in the latex end there's no difference between

    \includegraphics[]{}%
    \includegraphics[]{}%

And

    \includegraphics[]{}\includegraphics[]{}%

To the best of my knowledge.

Rasmus

-- 
Slowly unravels in a ball of yarn and the devil collects it

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

* Re: Exporting multiple images in a float (LaTeX)
  2015-08-08 19:23               ` Rasmus
@ 2015-08-08 23:56                 ` Suvayu Ali
  2015-08-10 11:59                 ` Eric S Fraga
  1 sibling, 0 replies; 13+ messages in thread
From: Suvayu Ali @ 2015-08-08 23:56 UTC (permalink / raw)
  To: emacs-orgmode

On Sat, Aug 08, 2015 at 09:23:57PM +0200, Rasmus wrote:
> Eric S Fraga <e.fraga@ucl.ac.uk> writes:
> 
> > On Friday,  7 Aug 2015 at 16:23, Rasmus wrote:
> >
> > [...]
> >
> >> I guess there would also be no loss from actually inserting a "%" after
> >> \includegraphics[·]{·} in ox-latex.
> >
> > Except that then the suggestion I just made would not work and would in
> > fact be quite confusing as the second figure would be lost in the
> > export?
> 
> But we can insert "%\n" and in the latex end there's no difference between
> 
>     \includegraphics[]{}%
>     \includegraphics[]{}%
> 
> And
> 
>     \includegraphics[]{}\includegraphics[]{}%
> 
> To the best of my knowledge.

I think you are correct!

-- 
Suvayu

Open source is the future. It sets us free.

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

* Re: Exporting multiple images in a float (LaTeX)
  2015-08-08 19:23               ` Rasmus
  2015-08-08 23:56                 ` Suvayu Ali
@ 2015-08-10 11:59                 ` Eric S Fraga
  1 sibling, 0 replies; 13+ messages in thread
From: Eric S Fraga @ 2015-08-10 11:59 UTC (permalink / raw)
  To: Rasmus; +Cc: emacs-orgmode

On Saturday,  8 Aug 2015 at 21:23, Rasmus wrote:
> But we can insert "%\n" and in the latex end there's no difference between
>
>     \includegraphics[]{}%
>     \includegraphics[]{}%
>
> And
>
>     \includegraphics[]{}\includegraphics[]{}%
>
> To the best of my knowledge.
>
> Rasmus

Indeed but I guess my view is that from the perspective of the org file,
two links on the same line are subtly different from two links on
separate lines.  Whether this matters or not is up for debate of course!

I don't actually mind either way as both of the above are usually what I
would want.

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.50.2, Org release_8.3-3-gb5f5d6

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

end of thread, other threads:[~2015-08-10 12:00 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-06 16:42 Exporting multiple images in a float (LaTeX) Suvayu Ali
2015-08-06 22:27 ` Rasmus
2015-08-06 22:31   ` Rasmus
2015-08-07  4:24     ` Suvayu Ali
2015-08-07 13:28       ` Eric S Fraga
2015-08-07 14:14         ` Suvayu Ali
2015-08-07 14:23           ` Rasmus
2015-08-07 16:19             ` Eric S Fraga
2015-08-07 17:04               ` Suvayu Ali
2015-08-08 19:23               ` Rasmus
2015-08-08 23:56                 ` Suvayu Ali
2015-08-10 11:59                 ` Eric S Fraga
2015-08-07 17:00             ` Suvayu Ali

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