* Question on LaTeX scaling of images
@ 2012-01-04 20:57 François Pinard
2012-01-04 21:17 ` Nick Dokos
0 siblings, 1 reply; 8+ messages in thread
From: François Pinard @ 2012-01-04 20:57 UTC (permalink / raw)
To: emacs-orgmode
Hi, Org people.
I'm currently using Org mode for preparing a report, and notice that
through "C-c C-e d", small icon-style images meant to be inlined within
the text, and which are nicely seen in the Emacs window, are getting
spurious scaled fairly big in the produced PDF. Apparently, if I guess
correctly, just so to get from the current position to the right margin.
I wonder if there is a way to inhibit this growth and keep the images
inlined in the output. In a previous document using reStructuredText
(and Sphinx), I used such a feature a lot (for those familiar, through
reST "|macros|" for keeping the writing fluid), and would like to see if
I can do something similar with Org mode. (Emacs inlining of images is
already quite confortable, yet macros also have their own virtues.)
For now, this is not really a problem, as I only need bigger screenshot
or diagrams, which seem to work just fine for the experiments I did.
Iconic marks and decorations are more on the side of fine tuning, I can
go without them. :-).
François
P.S. Be comfortable to tell me, if you feel I'm abusing this forum with
questions and should rather ask elsewhere.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Question on LaTeX scaling of images
2012-01-04 20:57 Question on LaTeX scaling of images François Pinard
@ 2012-01-04 21:17 ` Nick Dokos
2012-01-04 23:18 ` François Pinard
0 siblings, 1 reply; 8+ messages in thread
From: Nick Dokos @ 2012-01-04 21:17 UTC (permalink / raw)
To: =?utf-8?Q?Fran=C3=A7ois?= Pinard; +Cc: nicholas.dokos, emacs-orgmode
François Pinard <pinard@iro.umontreal.ca> wrote:
> Hi, Org people.
>
> I'm currently using Org mode for preparing a report, and notice that
> through "C-c C-e d", small icon-style images meant to be inlined within
> the text, and which are nicely seen in the Emacs window, are getting
> spurious scaled fairly big in the produced PDF. Apparently, if I guess
> correctly, just so to get from the current position to the right margin.
>
This is probably a bug. Here is a work-around:
--8<---------------cut here---------------start------------->8---
#+BIND: org-export-latex-image-default-option ""
* foo
This is an inline image: [[./scomp3.png]]. It should not be scaled.
--8<---------------cut here---------------end--------------->8---
> I wonder if there is a way to inhibit this growth and keep the images
> inlined in the output. In a previous document using reStructuredText
> (and Sphinx), I used such a feature a lot (for those familiar, through
> reST "|macros|" for keeping the writing fluid), and would like to see if
> I can do something similar with Org mode. (Emacs inlining of images is
> already quite confortable, yet macros also have their own virtues.)
>
> For now, this is not really a problem, as I only need bigger screenshot
> or diagrams, which seem to work just fine for the experiments I did.
> Iconic marks and decorations are more on the side of fine tuning, I can
> go without them. :-).
>
> François
>
> P.S. Be comfortable to tell me, if you feel I'm abusing this forum with
> questions and should rather ask elsewhere.
>
Not at all - this is exactly the right place.
Nick
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Question on LaTeX scaling of images
2012-01-04 21:17 ` Nick Dokos
@ 2012-01-04 23:18 ` François Pinard
2012-01-05 0:19 ` Nick Dokos
0 siblings, 1 reply; 8+ messages in thread
From: François Pinard @ 2012-01-04 23:18 UTC (permalink / raw)
To: nicholas.dokos; +Cc: emacs-orgmode
Nick Dokos <nicholas.dokos@hp.com> writes:
> François Pinard <pinard@iro.umontreal.ca> wrote:
>> P.S. Be comfortable to tell me, if you feel I'm abusing this forum
>> with questions and should rather ask elsewhere.
> Not at all - this is exactly the right place.
Wow, thanks! You might regret having opened that door! :-)
>> [...] through "C-c C-e d", small icon-style images meant to be
>> inlined within the text [...] are getting spurious scaled fairly big
>> in the produced PDF.
> This is probably a bug. Here is a work-around:
> #+BIND: org-export-latex-image-default-option ""
Hey hey! This works! :-)
A consequent question, if I may. The bottom of the image is lined up
with the baseline of the text (at first glance at least) in the produced
PDF, while in the Emacs buffer, the center of the image is, which looks
a bit nicer. Do we have some control over this?
François
P.S. And thanks for replying. Moreover, this was very quick! :-)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Question on LaTeX scaling of images
2012-01-04 23:18 ` François Pinard
@ 2012-01-05 0:19 ` Nick Dokos
2012-01-05 8:08 ` Sebastien Vauban
0 siblings, 1 reply; 8+ messages in thread
From: Nick Dokos @ 2012-01-05 0:19 UTC (permalink / raw)
To: =?utf-8?Q?Fran=C3=A7ois?= Pinard; +Cc: nicholas.dokos, emacs-orgmode
François Pinard <pinard@iro.umontreal.ca> wrote:
> Nick Dokos <nicholas.dokos@hp.com> writes:
>
> > François Pinard <pinard@iro.umontreal.ca> wrote:
>
> >> P.S. Be comfortable to tell me, if you feel I'm abusing this forum
> >> with questions and should rather ask elsewhere.
>
> > Not at all - this is exactly the right place.
>
> Wow, thanks! You might regret having opened that door! :-)
>
I'm regretting it already ;-)
> >> [...] through "C-c C-e d", small icon-style images meant to be
> >> inlined within the text [...] are getting spurious scaled fairly big
> >> in the produced PDF.
>
> > This is probably a bug. Here is a work-around:
> > #+BIND: org-export-latex-image-default-option ""
>
> Hey hey! This works! :-)
>
> A consequent question, if I may. The bottom of the image is lined up
> with the baseline of the text (at first glance at least) in the produced
> PDF, while in the Emacs buffer, the center of the image is, which looks
> a bit nicer. Do we have some control over this?
>
There are various ways to do that in latex. The basic command is
\includegraphics{foo.png}: this produces a box of a certain width and height,
so you can use a box-making command to do what you want, e.g.
\parbox[c]{1.2in}{\includegraphics{foo.png}
or better:
\raisebox{-\height / 2}{\includegraphics{foo.png}}
The parbox does not measure its argument, so the only way to determine
the width is trial and error. The raisebox does measure it and leaves
the dimensions in \width and \height. Note that in order to do arithmetic
you need to \usepackage{calc} (or really use low-level TeX stuff, which is
the hair-shirt approach).
So you can do something like this:
--8<---------------cut here---------------start------------->8---
## +BIND: org-export-latex-image-default-option ""
#+LaTeX_HEADER: \usepackage{calc}
* foo
This is an inline image:
#+LaTeX: \raisebox{-\height / 2}{\includegraphics{scomp3.png}}
. It should not be scaled.
--8<---------------cut here---------------end--------------->8---
Of course that's hardly a satisfactory state of affairs. The obvious
way of doing it however does not work:
,----
| #+LaTeX: \raisebox{-\height / 2}{
| [[./scomp3.png]]
| #+LaTeX: }
`----
The latex exporter mangles it to:
,----
| This is an inline image:
| \raisebox{-\height / 2}{%
| [[./scomp3.png][./scomp3.png]]
| }%
| . It should not be scaled.
`----
and I don't know any way to convince it to do it "right". Unless somebody
can come up with such a way, the only possibility that remains is to hack
org-latex.el.
Nick
PS. I adapted the \raisebox approach from the discussion in
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=topgraph
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Question on LaTeX scaling of images
2012-01-05 0:19 ` Nick Dokos
@ 2012-01-05 8:08 ` Sebastien Vauban
2012-01-05 19:35 ` Nick Dokos
0 siblings, 1 reply; 8+ messages in thread
From: Sebastien Vauban @ 2012-01-05 8:08 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Hi Nick and François,
Nick Dokos wrote:
> François Pinard <pinard-CRDzTM1onBSWkKpYnGOUKg@public.gmane.org> wrote:
>> The bottom of the image is lined up with the baseline of the text (at first
>> glance at least) in the produced PDF, while in the Emacs buffer, the center
>> of the image is, which looks a bit nicer. Do we have some control over
>> this?
>
> You can do something like this:
>
> ## +BIND: org-export-latex-image-default-option ""
> #+LaTeX_HEADER: \usepackage{calc}
>
> * foo
>
> This is an inline image:
> #+LaTeX: \raisebox{-\height / 2}{\includegraphics{scomp3.png}}
> . It should not be scaled.
>
> Of course that's hardly a satisfactory state of affairs. The obvious
> way of doing it however does not work:
>
> ,----
> | #+LaTeX: \raisebox{-\height / 2}{
> | [[./scomp3.png]]
> | #+LaTeX: }
> `----
>
> The latex exporter mangles it to:
>
> ,----
> | This is an inline image:
> | \raisebox{-\height / 2}{%
> | [[./scomp3.png][./scomp3.png]]
> | }%
> | . It should not be scaled.
> `----
Using this:
#+begin_src org
## +BIND: org-export-latex-image-default-option ""
#+LaTeX_HEADER: \usepackage{calc}
* foo
This is an inline image:
#+LaTeX: \raisebox{-\height / 2}{\includegraphics{scomp3.png}}
. It should not be scaled.
#+end_src
produces that for me:
#+begin_src latex
This is an inline image:
\raisebox{-\height / 2}{\includegraphics{scomp3.png}}
. It should not be scaled.
#+end_src
So, it worked out-of-the-box.
> and I don't know any way to convince it to do it "right". Unless somebody
> can come up with such a way, the only possibility that remains is to hack
> org-latex.el.
You can try the dirty trick given by Carsten: adding `{}' in front of your
environment -- as "environments are only detected if they are the first thing
in a new line":
#+LaTeX: {}\raisebox{-\height / 2}{
See http://comments.gmane.org/gmane.emacs.orgmode/21183.
Best regards,
Seb
--
Sebastien Vauban
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Question on LaTeX scaling of images
2012-01-05 8:08 ` Sebastien Vauban
@ 2012-01-05 19:35 ` Nick Dokos
2012-01-05 22:04 ` Sebastien Vauban
0 siblings, 1 reply; 8+ messages in thread
From: Nick Dokos @ 2012-01-05 19:35 UTC (permalink / raw)
To: Sebastien Vauban; +Cc: nicholas.dokos, emacs-orgmode
Sebastien Vauban <wxhgmqzgwmuf@spammotel.com> wrote:
> Using this:
>
> #+begin_src org
> ## +BIND: org-export-latex-image-default-option ""
> #+LaTeX_HEADER: \usepackage{calc}
>
> * foo
>
> This is an inline image:=20
> #+LaTeX: \raisebox{-\height / 2}{\includegraphics{scomp3.png}}
> . It should not be scaled.
> #+end_src
>
> produces that for me:
>
> #+begin_src latex
> This is an inline image:=20
> \raisebox{-\height / 2}{\includegraphics{scomp3.png}}
> . It should not be scaled.
> #+end_src
>
> So, it worked out-of-the-box.
>
The problem is not that it does not work: of course it does. The problem is
that it is too closely tied to latex - forget about exporting it to HTML or
any other format.
> > and I don't know any way to convince it to do it "right". Unless somebody
> > can come up with such a way, the only possibility that remains is to hack
> > org-latex.el.
>
> You can try the dirty trick given by Carsten: adding `{}' in front of your
> environment -- as "environments are only detected if they are the first thi=
> ng
> in a new line":
>
> #+LaTeX: {}\raisebox{-\height / 2}{
>
> See http://comments.gmane.org/gmane.emacs.orgmode/21183.
>
Thanks for the pointer - I'll have to try to remember this for future
reference (but we all know how that will work out for me :-) ). However,
in this case, the problem is not the recognition of the environment: the
latex exporter seems to mangle the link that follows. So far, the only
thing that has worked is actually hacking org-latex to insinuate the
\raisebox in the proper place.
Thanks,
Nick
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Question on LaTeX scaling of images
2012-01-05 19:35 ` Nick Dokos
@ 2012-01-05 22:04 ` Sebastien Vauban
2012-01-05 23:04 ` Nick Dokos
0 siblings, 1 reply; 8+ messages in thread
From: Sebastien Vauban @ 2012-01-05 22:04 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Hi Nick,
Nick Dokos wrote:
> Sebastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> wrote:
>
>> Using this:
>>
>> #+begin_src org
>> ## +BIND: org-export-latex-image-default-option ""
>> #+LaTeX_HEADER: \usepackage{calc}
>>
>> * foo
>>
>> This is an inline image:=20
>> #+LaTeX: \raisebox{-\height / 2}{\includegraphics{scomp3.png}}
>> . It should not be scaled.
>> #+end_src
>>
>> produces that for me:
>>
>> #+begin_src latex
>> This is an inline image:=20
>> \raisebox{-\height / 2}{\includegraphics{scomp3.png}}
>> . It should not be scaled.
>> #+end_src
>>
>> So, it worked out-of-the-box.
>
> The problem is not that it does not work: of course it does. The problem is
> that it is too closely tied to latex - forget about exporting it to HTML or
> any other format.
OK; sorry. I just took the bad expression, it seems. By bad, I mean the
workaround you used, not the original expression you wanted to use. I guess it
was somehow too early in the morning for me ;-)
>> > and I don't know any way to convince it to do it "right". Unless somebody
>> > can come up with such a way, the only possibility that remains is to hack
>> > org-latex.el.
>>
>> You can try the dirty trick given by Carsten: adding `{}' in front of your
>> environment -- as "environments are only detected if they are the first thi=
>> ng
>> in a new line":
>>
>> #+LaTeX: {}\raisebox{-\height / 2}{
>>
>> See http://comments.gmane.org/gmane.emacs.orgmode/21183.
>
> Thanks for the pointer - I'll have to try to remember this for future
> reference (but we all know how that will work out for me :-) ).
Not sure to grasp that last sentence...
> However, in this case, the problem is not the recognition of the
> environment: the latex exporter seems to mangle the link that follows. So
> far, the only thing that has worked is actually hacking org-latex to
> insinuate the \raisebox in the proper place.
Did you send a patch? Or is this too fragile to be applied to the core? I
really think I will need such a thing quite soon -- I've got such a
problematic LaTeX construct coming up in slides I'm working on.
Best regards,
Seb
--
Sebastien Vauban
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Question on LaTeX scaling of images
2012-01-05 22:04 ` Sebastien Vauban
@ 2012-01-05 23:04 ` Nick Dokos
0 siblings, 0 replies; 8+ messages in thread
From: Nick Dokos @ 2012-01-05 23:04 UTC (permalink / raw)
To: Sebastien Vauban; +Cc: nicholas.dokos, emacs-orgmode
Sebastien Vauban <wxhgmqzgwmuf@spammotel.com> wrote:
> > the only thing that has worked is actually hacking org-latex to
> > insinuate the \raisebox in the proper place.
>
> Did you send a patch? Or is this too fragile to be applied to the core? I
> really think I will need such a thing quite soon -- I've got such a
> problematic LaTeX construct coming up in slides I'm working on.
>
No - I can't send patches, but in any case, this was just a
proof-of-concept hack. I just wrapped the \includegraphics on line 2282
or so of org-latex.el (the default case of the cond which is the
inlined-image case) inside the \raisebox construct. One still needs to
add a \usepackage{calc} by hand to make even this trivial hack to work,
but more importantly, one would need to make the alignment configurable
by the user: that's the tougher part.
Nick
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-01-05 23:04 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-04 20:57 Question on LaTeX scaling of images François Pinard
2012-01-04 21:17 ` Nick Dokos
2012-01-04 23:18 ` François Pinard
2012-01-05 0:19 ` Nick Dokos
2012-01-05 8:08 ` Sebastien Vauban
2012-01-05 19:35 ` Nick Dokos
2012-01-05 22:04 ` Sebastien Vauban
2012-01-05 23:04 ` 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).