emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* LaTeX export: images in margin
@ 2013-08-16 11:59 Roger Mason
  2013-08-16 12:47 ` Suvayu Ali
  0 siblings, 1 reply; 6+ messages in thread
From: Roger Mason @ 2013-08-16 11:59 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

I'd like to have images in the margin when exporting to LaTeX (or 
creating a pdf via LaTeX).  I see from a message on one of the TeX 
mailing lists that this can be done like this:

\marginpar{\includegraphics[]{../images/Walkthrough_1-001.jpg}}

How can I get org (8.0.3 on linux) to wrap calls to \includegraphics 
with a call to \marginpar?  Maybe this is in the FAQ or a mailing list 
message, but if so, I did not find it.

Thanks,
Roger


This electronic communication is governed by the terms and conditions at
http://www.mun.ca/cc/policies/electronic_communications_disclaimer_2012.php

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

* Re: LaTeX export: images in margin
  2013-08-16 11:59 LaTeX export: images in margin Roger Mason
@ 2013-08-16 12:47 ` Suvayu Ali
  2013-08-16 13:15   ` Suvayu Ali
  0 siblings, 1 reply; 6+ messages in thread
From: Suvayu Ali @ 2013-08-16 12:47 UTC (permalink / raw)
  To: emacs-orgmode

On Fri, Aug 16, 2013 at 09:29:58AM -0230, Roger Mason wrote:
> Hello,
> 
> I'd like to have images in the margin when exporting to LaTeX (or creating a
> pdf via LaTeX).  I see from a message on one of the TeX mailing lists that
> this can be done like this:
> 
> \marginpar{\includegraphics[]{../images/Walkthrough_1-001.jpg}}
> 
> How can I get org (8.0.3 on linux) to wrap calls to \includegraphics with a
> call to \marginpar?  Maybe this is in the FAQ or a mailing list message, but
> if so, I did not find it.

You can adapt this to your needs:

  <http://article.gmane.org/gmane.emacs.orgmode/74876>

Hope this helps,

-- 
Suvayu

Open source is the future. It sets us free.

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

* Re: LaTeX export: images in margin
  2013-08-16 12:47 ` Suvayu Ali
@ 2013-08-16 13:15   ` Suvayu Ali
  2013-08-16 14:04     ` Roger Mason
  0 siblings, 1 reply; 6+ messages in thread
From: Suvayu Ali @ 2013-08-16 13:15 UTC (permalink / raw)
  To: emacs-orgmode

On Fri, Aug 16, 2013 at 02:47:07PM +0200, Suvayu Ali wrote:
> On Fri, Aug 16, 2013 at 09:29:58AM -0230, Roger Mason wrote:
> > Hello,
> > 
> > I'd like to have images in the margin when exporting to LaTeX (or creating a
> > pdf via LaTeX).  I see from a message on one of the TeX mailing lists that
> > this can be done like this:
> > 
> > \marginpar{\includegraphics[]{../images/Walkthrough_1-001.jpg}}
> > 
> > How can I get org (8.0.3 on linux) to wrap calls to \includegraphics with a
> > call to \marginpar?  Maybe this is in the FAQ or a mailing list message, but
> > if so, I did not find it.
> 
> You can adapt this to your needs:
> 
>   <http://article.gmane.org/gmane.emacs.orgmode/74876>
> 

It's in the FAQ now: <http://orgmode.org/worg/org-faq.html#filter>

Cheers,

-- 
Suvayu

Open source is the future. It sets us free.

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

* Re: LaTeX export: images in margin
  2013-08-16 13:15   ` Suvayu Ali
@ 2013-08-16 14:04     ` Roger Mason
  2013-08-16 14:32       ` Roger Mason
  0 siblings, 1 reply; 6+ messages in thread
From: Roger Mason @ 2013-08-16 14:04 UTC (permalink / raw)
  To: emacs-orgmode

Hello again,

On 08/16/2013 10:45 AM, Suvayu Ali wrote:
>> You can adapt this to your needs: 
>> <http://article.gmane.org/gmane.emacs.orgmode/74876> 
> It's in the FAQ now: <http://orgmode.org/worg/org-faq.html#filter>
>
> Cheers,
>
Thanks for your response.  I have it working somewhat:

(defun margin-graphics (contents backend info)
   (when (eq backend 'latex)
     (replace-regexp-in-string "\\`\\\\includegraphics.+\\({.+}\\)"
        "\\\\marginpar{\\\\includegraphics\1} " contents)))

(add-to-list 'org-export-filter-link-functions 'margin-graphics)

However, the LaTeX file contains this:

\marginpar{\includegraphics\x01^A}

rather than the expected

\marginpar{\includegraphics\x01[]{filename}}

Something is wrong with my regexp, but what?

Thanks,
Roger

This electronic communication is governed by the terms and conditions at
http://www.mun.ca/cc/policies/electronic_communications_disclaimer_2012.php

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

* Re: LaTeX export: images in margin
  2013-08-16 14:04     ` Roger Mason
@ 2013-08-16 14:32       ` Roger Mason
  2013-08-16 14:44         ` Suvayu Ali
  0 siblings, 1 reply; 6+ messages in thread
From: Roger Mason @ 2013-08-16 14:32 UTC (permalink / raw)
  To: emacs-orgmode

Hello once more,

On 08/16/2013 11:34 AM, Roger Mason wrote:
>
> (defun margin-graphics (contents backend info)
>   (when (eq backend 'latex)
>     (replace-regexp-in-string "\\`\\\\includegraphics.+\\({.+}\\)"
>        "\\\\marginpar{\\\\includegraphics\1} " contents)))
>
> (add-to-list 'org-export-filter-link-functions 'margin-graphics)
>
> However, the LaTeX file contains this:
>
> \marginpar{\includegraphics\x01^A}
>
> rather than the expected
>
> \marginpar{\includegraphics\x01[]{filename}}
This line:

(replace-regexp-in-string "\\`\\\\includegraphics.+\\({.+}\\)"
        "\\\\marginpar{\\\\includegraphics\1} " contents)))

should be:

(replace-regexp-in-string "\\`\\\\includegraphics.+\\({.+}\\)"
        "\\\\marginpar{\\\\includegraphics\\1} " contents)))

Note the double backslash before the '1' in the replacement text.

Cheers,
Roger

This electronic communication is governed by the terms and conditions at
http://www.mun.ca/cc/policies/electronic_communications_disclaimer_2012.php

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

* Re: LaTeX export: images in margin
  2013-08-16 14:32       ` Roger Mason
@ 2013-08-16 14:44         ` Suvayu Ali
  0 siblings, 0 replies; 6+ messages in thread
From: Suvayu Ali @ 2013-08-16 14:44 UTC (permalink / raw)
  To: emacs-orgmode

On Fri, Aug 16, 2013 at 12:02:46PM -0230, Roger Mason wrote:
> 
> (replace-regexp-in-string "\\`\\\\includegraphics.+\\({.+}\\)"
>        "\\\\marginpar{\\\\includegraphics\1} " contents)))
> 
> should be:
> 
> (replace-regexp-in-string "\\`\\\\includegraphics.+\\({.+}\\)"
>        "\\\\marginpar{\\\\includegraphics\\1} " contents)))
> 
> Note the double backslash before the '1' in the replacement text.

That is a lisp gotcha, :-p.  The regexp needs a backslash, however since
it is the escape character in lisp strings, it needs to be escaped
itself.

Glad things worked out for you.

Cheers,

-- 
Suvayu

Open source is the future. It sets us free.

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

end of thread, other threads:[~2013-08-16 14:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-16 11:59 LaTeX export: images in margin Roger Mason
2013-08-16 12:47 ` Suvayu Ali
2013-08-16 13:15   ` Suvayu Ali
2013-08-16 14:04     ` Roger Mason
2013-08-16 14:32       ` Roger Mason
2013-08-16 14:44         ` 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).