Hi, this is a quick fix for image inlining. It would be nice to have it checked by more people. The code is a bit convoluted and it would be nice to have time and sit quietly or it.
Best, /PA On Tue, 25 Feb 2025 at 19:19, Ihor Radchenko <yanta...@posteo.net> wrote: > Pedro Andres Aranda Gutierrez <paag...@gmail.com> writes: > > >> Figures inside tables will be inlined. They are not floats and cannot > >> have caption, name, be referenced. > > Isn’t that a bit too … restrictive? > > That's mostly a limitation of Org syntax (current Org syntax; I hope > that will change in future). > > We currently work around this fact by re-using affiliated keywords from > the parent element as attributes for image (see how ATTR is computed in > `org-latex--inline-image'). But there is no way we can have, for > example, a reference to such image or put a caption - we risk ambiguity > about caption/reference being assigned to the containing > paragraph/table/etc or even other inline images inside. > > Maybe ox-latex can allow inlined floats. But I have a hard time > understanding how an image can be both float and also a part of the > containing paragraph/table/minipage/etc. > > >>> What approach would fit best > >>> > >>> 1. Keep tables and figures separate, which may imply a good amount of > Lisp, still to be investigated. > >>> 2. Make everything with tables and have > >>> a) headings starting with ’Table’ for figures > >>> b) non consecutive figure numbering > >> > >> Just \includegraphics will do. > >> Basically, leave things as they are now. The main problem is not > >> including image, but using \begin{center} ... where it cannot be used. > > Will see, but it sounds rather poor to me… > > I actually do no oppose more sophisticated behavior. > But we at least need to fix the reproducer not compiling at all. > Anything else is a nice-to-have extra. > > For your suggestion about separating tables and figures, I am not > sure. I see images inside tables as a legitimate use-case. > > -- > Ihor Radchenko // yantar92, > Org mode maintainer, > Learn more about Org mode at <https://orgmode.org/>. > Support Org development at <https://liberapay.com/org-mode>, > or support my work at <https://liberapay.com/yantar92> > -- Fragen sind nicht da, um beantwortet zu werden, Fragen sind da um gestellt zu werden Georg Kreisler Headaches with a Juju log: unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run a leader-deposed hook here, but we can't yet Year 1 of the New Koprocracy
From 99eaedda168707862c03ff8b5337de321caa54a7 Mon Sep 17 00:00:00 2001 From: "Pedro A. Aranda" <paag...@gmail.com> Date: Thu, 27 Feb 2025 08:30:39 +0100 Subject: [PATCH] Quick fix for image inlining --- lisp/ox-latex: Allow plain inlining of images * lisp/ox-latex.el: Fixed (org-latex--inline-image): when an image is inlined in the text, it will be passed to this function without attributes. We now check this to generate `image-code' and when deciding whether to wrap `image-code' in a center environment or not. Link: https://list.orgmode.org/87y0xvrz9j.fsf@localhost/T/#m91c32e5fd74b9058e01fa2fd2bdf6817707d646a lisp/ox-latex.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index af3ac308b..95692d972 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -2955,7 +2955,8 @@ used as a communication channel." (setq options (concat options ",page=" search-option)))) (setq image-code (format "\\includegraphics%s{%s}" - (cond ((not (org-string-nw-p options)) "") + (cond ((null attr) "") ;; this is a plain image with no attrs + ((not (org-string-nw-p options)) "") ((string-prefix-p "," options) (format "[%s]" (substring options 1))) (t (format "[%s]" options))) @@ -3023,7 +3024,8 @@ used as a communication channel." (if center "\\centering" "") comment-include image-code (if caption-above-p "" caption))) - ((guard center) + ((guard (and (not (null attr)) center)) + ;; if we have attributes that demand centering (format "\\begin{center} %s%s %s\\end{center}" -- 2.34.1