emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Controlling image width and placement in Beamer export
@ 2013-11-26 13:51 Jarmo Hurri
  2013-11-26 15:06 ` John Hendy
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jarmo Hurri @ 2013-11-26 13:51 UTC (permalink / raw)
  To: emacs-orgmode


Greetings.

I needed to create an Asymptote-generated centered image with a smaller
width than the default .9\linewidth in a Beamer export. After trial and
error I ended with the method shown below. In particular, to my surprise
an

#+ATTR_LATEX: :width 5cm

_above_ the #+BEGIN_SRC did not work, so I had to place the line above
#+RESULTS:

Is the following the best way to do this, or is there a more concise
method?

# ---------------------------------------------------------------
#+BEGIN_SRC asymptote :file triangle.pdf
  size (8cm, 0);
  pair A = (0, 0), B = (4, 1), C = (3, 2);
  draw (A -- B -- C -- cycle);
#+END_SRC

#+LATEX: \begin{center}
#+ATTR_LATEX: :width 5cm
#+RESULTS:
[[file:triangle.pdf]]
#+LATEX: \end{center}
# ---------------------------------------------------------------

All the best,

Jarmo

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

* Re: Controlling image width and placement in Beamer export
  2013-11-26 13:51 Controlling image width and placement in Beamer export Jarmo Hurri
@ 2013-11-26 15:06 ` John Hendy
  2013-11-27  6:28   ` Jarmo Hurri
  2013-11-26 15:08 ` John Hendy
  2013-11-26 15:19 ` Nick Dokos
  2 siblings, 1 reply; 6+ messages in thread
From: John Hendy @ 2013-11-26 15:06 UTC (permalink / raw)
  To: Jarmo Hurri; +Cc: emacs-orgmode

On Tue, Nov 26, 2013 at 7:51 AM, Jarmo Hurri <jarmo.hurri@syk.fi> wrote:
>
> Greetings.
>
> I needed to create an Asymptote-generated centered image with a smaller
> width than the default .9\linewidth in a Beamer export. After trial and
> error I ended with the method shown below. In particular, to my surprise
> an
>
> #+ATTR_LATEX: :width 5cm
>
> _above_ the #+BEGIN_SRC did not work, so I had to place the line above
> #+RESULTS:
>
> Is the following the best way to do this, or is there a more concise
> method?
>
> # ---------------------------------------------------------------
> #+BEGIN_SRC asymptote :file triangle.pdf
>   size (8cm, 0);
>   pair A = (0, 0), B = (4, 1), C = (3, 2);
>   draw (A -- B -- C -- cycle);
> #+END_SRC
>
> #+LATEX: \begin{center}
> #+ATTR_LATEX: :width 5cm
> #+RESULTS:
> [[file:triangle.pdf]]
> #+LATEX: \end{center}
> # ---------------------------------------------------------------

This comes up all the time. See this thread:
- http://lists.gnu.org/archive/html/emacs-orgmode/2012-07/msg00323.html

The key is to put it 1) before results (as you've done) and 2) to use
a named source block (with #+name: foo above your babel code) so that
Org knows what the results block actually is. Otherwise, as you
currently have it, if you re-run the babel block, you'll keep the
results section you already have and it will spit out another one
below it since it no longer recognizes that the babel block and
current, modified results block go together.


Good luck,
John

>
> All the best,
>
> Jarmo
>
>

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

* Re: Controlling image width and placement in Beamer export
  2013-11-26 13:51 Controlling image width and placement in Beamer export Jarmo Hurri
  2013-11-26 15:06 ` John Hendy
@ 2013-11-26 15:08 ` John Hendy
  2013-11-26 15:19 ` Nick Dokos
  2 siblings, 0 replies; 6+ messages in thread
From: John Hendy @ 2013-11-26 15:08 UTC (permalink / raw)
  To: Jarmo Hurri; +Cc: emacs-orgmode

On Tue, Nov 26, 2013 at 7:51 AM, Jarmo Hurri <jarmo.hurri@syk.fi> wrote:
>
> Greetings.
>
> I needed to create an Asymptote-generated centered image with a smaller
> width than the default .9\linewidth in a Beamer export. After trial and
> error I ended with the method shown below. In particular, to my surprise
> an
>
> #+ATTR_LATEX: :width 5cm
>
> _above_ the #+BEGIN_SRC did not work, so I had to place the line above
> #+RESULTS:
>
> Is the following the best way to do this, or is there a more concise
> method?
>
> # ---------------------------------------------------------------
> #+BEGIN_SRC asymptote :file triangle.pdf
>   size (8cm, 0);
>   pair A = (0, 0), B = (4, 1), C = (3, 2);
>   draw (A -- B -- C -- cycle);
> #+END_SRC
>
> #+LATEX: \begin{center}
> #+ATTR_LATEX: :width 5cm
> #+RESULTS:
> [[file:triangle.pdf]]
> #+LATEX: \end{center}
> # ---------------------------------------------------------------
>

Oh, and not that it matters, but I typically do:

#+begin_center
#+ATTR_LATEX: :width 5cm
#+RESULTS:
[[file:triangle.pdf]]
#+end_center

Theoretically, more flexible for different types of exports. Even if
you're only doing LaTeX, it's still less characters to type :)


John

> All the best,
>
> Jarmo
>
>

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

* Re: Controlling image width and placement in Beamer export
  2013-11-26 13:51 Controlling image width and placement in Beamer export Jarmo Hurri
  2013-11-26 15:06 ` John Hendy
  2013-11-26 15:08 ` John Hendy
@ 2013-11-26 15:19 ` Nick Dokos
  2 siblings, 0 replies; 6+ messages in thread
From: Nick Dokos @ 2013-11-26 15:19 UTC (permalink / raw)
  To: emacs-orgmode

Jarmo Hurri <jarmo.hurri@syk.fi> writes:

> Greetings.
>
> I needed to create an Asymptote-generated centered image with a smaller
> width than the default .9\linewidth in a Beamer export. After trial and
> error I ended with the method shown below. In particular, to my surprise
> an
>
> #+ATTR_LATEX: :width 5cm
>
> _above_ the #+BEGIN_SRC did not work, so I had to place the line above
> #+RESULTS:
>
> Is the following the best way to do this, or is there a more concise
> method?
>
> # ---------------------------------------------------------------
> #+BEGIN_SRC asymptote :file triangle.pdf
>   size (8cm, 0);
>   pair A = (0, 0), B = (4, 1), C = (3, 2);
>   draw (A -- B -- C -- cycle);
> #+END_SRC
> #+LATEX: \begin{center}
> #+ATTR_LATEX: :width 5cm
> #+RESULTS:
> [[file:triangle.pdf]]
> #+LATEX: \end{center}
> # ---------------------------------------------------------------
>

My recommendation is to always name code blocks: then the corresponding results
blocks are named as well, tying the two together; subsequent evaluations
will just refresh the appropriate results block without introducincg new
results blocks. This is not as much of a problem as it used to be, but
naming code blocks is still a good guideline, imo.

Other than that, I think that's the best that you can do.

Nick

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

* Re: Controlling image width and placement in Beamer export
  2013-11-26 15:06 ` John Hendy
@ 2013-11-27  6:28   ` Jarmo Hurri
  2013-11-27 13:51     ` Nick Dokos
  0 siblings, 1 reply; 6+ messages in thread
From: Jarmo Hurri @ 2013-11-27  6:28 UTC (permalink / raw)
  To: emacs-orgmode


Greetings John.

John Hendy <jw.hendy@gmail.com> writes:

> This comes up all the time. 

Perhaps we could lower the frequency by making a small change to the
manual?

> The key is to put it 1) before results (as you've done) and 2) to use
> a named source block (with #+name: foo above your babel code) so that
> Org knows what the results block actually is. Otherwise, as you
> currently have it, if you re-run the babel block, you'll keep the
> results section you already have and it will spit out another one
> below it since it no longer recognizes that the babel block and
> current, modified results block go together.

Done. For some reason not doing 2) also worked correctly, but I agree
that it is still a good idea to name the blocks.

> Oh, and not that it matters, but I typically do:

> #+begin_center
> #+ATTR_LATEX: :width 5cm
> #+RESULTS:
> [[file:triangle.pdf]]
> #+end_center

Good point, thanks.

Jarmo

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

* Re: Controlling image width and placement in Beamer export
  2013-11-27  6:28   ` Jarmo Hurri
@ 2013-11-27 13:51     ` Nick Dokos
  0 siblings, 0 replies; 6+ messages in thread
From: Nick Dokos @ 2013-11-27 13:51 UTC (permalink / raw)
  To: emacs-orgmode

Jarmo Hurri <jarmo.hurri@syk.fi> writes:

> Greetings John.
>
> John Hendy <jw.hendy@gmail.com> writes:
>
>> This comes up all the time. 
>
> Perhaps we could lower the frequency by making a small change to the
> manual?
>
>> The key is to put it 1) before results (as you've done) and 2) to use
>> a named source block (with #+name: foo above your babel code) so that
>> Org knows what the results block actually is. Otherwise, as you
>> currently have it, if you re-run the babel block, you'll keep the
>> results section you already have and it will spit out another one
>> below it since it no longer recognizes that the babel block and
>> current, modified results block go together.
>
> Done. For some reason not doing 2) also worked correctly, but I agree
> that it is still a good idea to name the blocks.
>

Yes, Eric fixed that problem some months ago, so the urgency of naming
code blocks has gone way down - but it should still be considered "best
practice" imo.

-- 
Nick

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

end of thread, other threads:[~2013-11-27 13:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-26 13:51 Controlling image width and placement in Beamer export Jarmo Hurri
2013-11-26 15:06 ` John Hendy
2013-11-27  6:28   ` Jarmo Hurri
2013-11-27 13:51     ` Nick Dokos
2013-11-26 15:08 ` John Hendy
2013-11-26 15:19 ` Nick Dokos

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