From: Nick Dokos <nicholas.dokos@hp.com>
To: Carsten Dominik <carsten.dominik@gmail.com>
Cc: mailing-list-org-mode <emacs-orgmode@gnu.org>
Subject: Re: LaTeX export of images
Date: Tue, 29 Sep 2009 15:32:42 -0400 [thread overview]
Message-ID: <8809.1254252762@alphaville.usa.hp.com> (raw)
In-Reply-To: Message from Carsten Dominik <carsten.dominik@gmail.com> of "Tue, 29 Sep 2009 11:28:59 +0200." <10AD8929-948F-4985-8E26-F49C0DF525A7@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com> wrote:
> > 1) Images in the middle of the text
> >
> > If I have the following example:
> >
> > ,----
> > | For this example, I will use this image [[myimage.png]] which
> > is a very good one.
> > `----
> >
> > Then, when exported, it produces the following LaTeX code:
> >
> > ,----
> > | For this example, I will the use this image
> > | \centerline{\includegraphics{myimage}} which is a very good one.
> > `----
> >
> > Which produces weird layout when compiled to PDF.
> >
> > In this case, we should just generate \includegraphics{myimage}
> > without the
> > centerline command.
> >
Agree.
> >
> > 2) Images in floats
> >
> > In the case of floats, the correct generated code should be
> > something like:
> >
> > \begin{figure}[htb]
> > \centering
> > \includegraphics{myimage}
> > \label{LABEL}
> > \caption{CAPTION}
> > \end{figure}
> >
> > and not
> >
> > \begin{figure}[htb]
> > \centerline{\includegraphics{myimage}}
> > \label{LABEL}
> > \caption{CAPTION}
> > \end{figure}
> >
> > This can also be fixed quickly I think.
>
> Yes sure, but what is wrong with \centerline? does the \centering
> lead to a different result?
>
I've been running with the following patch for a little while and have
seen no problems (it does \centering rather than \centerline but I don't
think it makes a difference for an image - it would make a difference for a
floating centered paragraph with multiple lines however.)
There is another problem as well: there is a \n added after the
\end{figure} which leads to spurious paragraphs. The patch fixes
that too.
diff --git a/lisp/org-latex.el b/lisp/org-latex.el
index 4058891..248d653 100644
--- a/lisp/org-latex.el
+++ b/lisp/org-latex.el
@@ -1553,8 +1585,8 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
(cond ((and imgp (plist-get org-export-latex-options-plist :inline-images))
(insert
(concat
- (if floatp "\\begin{figure}[htb]\n")
- (format "\\centerline{\\includegraphics[%s]{%s}}\n"
+ (if floatp "\\begin{figure}[htb]\n\\centering\n")
+ (format "\\includegraphics[%s]{%s}\n"
attr
(if (file-name-absolute-p raw-path)
(expand-file-name raw-path)
@@ -1563,7 +1595,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
(format "\\caption{%s%s}\n"
(if label (concat "\\label{" label "}") "")
(or caption "")))
- (if floatp "\\end{figure}\n"))))
+ (if floatp "\\end{figure}"))))
(coderefp
(insert (format
(org-export-get-coderef-format path desc)
But there is the additional question that's raised in the thread:
Carsten Dominik <carsten.dominik@gmail.com> wrote:
>
> On Sep 23, 2009, at 11:09 PM, S=E9bastien Vauban wrote:
>
> > Jeff Kowalczyk wrote:
> >> S=E9bastien Vauban <wxhgmqzgwmuf@...> writes:
> >>> Francesco Pizzolante wrote:
> >>>> In this case, we should just generate \includegraphics{myimage} =20
> >>>> without
> >>>> the centerline command.
> >>>
> >>> Given the output of the `\centerline' command, I guess that the =20
> >>> inlining of
> >>> an image inside a line of text is not supported as is by Org. I =20
> >>> can second
> >>> such a choice.
> >>
> >> +1 for default to inline graphics. When using Org for How-To and =20
> >> project
> >> documentation delivered as PDF, floating screenshot-size images =20
> >> typically
> >> situate far from the descriptive text.
> >
> > My point was mainly that, IMHO, floating or not should not be tied =20
> > to the
> > presence or absence of caption/label.
> >
> > Your problem with screenshots far away should be solved by putting =20
> > the H
> > specifier to the float environment and loading the `float' package.
> >
> >
> >> I would prefer inline images by default (or option), and a file/=20
> >> subtree
> >> level option to use LaTeX floating layout.
> >
> > That'd be a great way to be able to specify which type of "inlining" =20=
>
> > we want.
> > On a per file basis seems sufficient for me.
>
> Hi Sebastien,
>
> how about working out a detailed proposal how this should work?
>
> - Carsten
>
>
Currently, specifying either a #+CAPTION or a #+LABEL (or both) floats
the image. Absent both of these the image is inlined (although without
the above patch, it's inlined badly).
LaTeX implicitly assumes that a floating figure has a caption: that's
where the figure number is incremented for example. Given that, it does
not seem productive to have a separate indicator for floats.
Of course, if one is willing to forego the incrementing of the counter,
then a float without a caption is possible in LaTeX - but is it useful?
If it is, then using the #+LABEL specifier alone is enough to float the
image (but currently, there is a problem in org-latex in that a \caption
is always output - but that is a minor problem, easily fixed, if so
desired).
To summarize: org-latex currently always produces a \caption which
causes LaTeX to increment the figure counter, but also to produce
a "Figure <N>:" caption, even if the caption is empty. We could
change org-latex not to produce a \caption if #+CAPTION is absent,
but that would mean that the figure counter does not get incremented.
I'm not sure that a saparate specifier is needed (it might be
desirable only on readability grounds: saying #+FLOAT, rather than
#+CAPTION or #+LABEL makes it a bit more obvious). These specifiers are
per-image, afaict, not per-file/subtree. For my part, I don't
see the need for the coarser kind of control: per-image is enough.
But if desired, then maybe
#+FLOAT: t (default nil)
or perhaps better
#+OPTIONS: float:t
can be used for the coarser control.
I hope this is clear but if there are questions, let me know. What do
you think?
Thanks,
Nick
next prev parent reply other threads:[~2009-09-29 19:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-22 13:39 LaTeX export of images Francesco Pizzolante
[not found] ` <87pr9jf68i.fsf-djc/iPCCuDYQheJpep6IedvLeJWuRmrY@public.gmane.org>
2009-09-23 14:04 ` Sébastien Vauban
2009-09-23 15:30 ` Jeff Kowalczyk
2009-09-23 21:09 ` Sébastien Vauban
2009-09-29 9:30 ` Carsten Dominik
2009-10-02 6:55 ` Carsten Dominik
2009-10-02 13:04 ` Darlan Cavalcante Moreira
2009-10-02 15:23 ` Nick Dokos
2009-10-03 7:05 ` Carsten Dominik
2009-10-05 14:19 ` Darlan Cavalcante Moreira
[not found] ` <B2499F80-4D9D-4F76-9432-ACF04E38C8EE-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-10-13 10:03 ` Francesco Pizzolante
2009-10-20 10:18 ` Carsten Dominik
2009-09-29 9:28 ` Carsten Dominik
2009-09-29 19:32 ` Nick Dokos [this message]
2009-09-30 7:30 ` Carsten Dominik
[not found] ` <8809.1254252762-/Z0n3E7Cx4uRQBexplnFlPegYHeGw8Jk@public.gmane.org>
2009-09-30 8:53 ` Francesco Pizzolante
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8809.1254252762@alphaville.usa.hp.com \
--to=nicholas.dokos@hp.com \
--cc=carsten.dominik@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.