* [BUG] Org-mode Side-by-Side Images [9.5.3 (release_9.5.3-3-gd54104)]
@ 2023-01-26 12:24 Gustaf Waldemarson
2023-02-13 14:48 ` [FR] Side-by-side images during export (was: [BUG] Org-mode Side-by-Side Images [9.5.3 (release_9.5.3-3-gd54104)]) Ihor Radchenko
0 siblings, 1 reply; 3+ messages in thread
From: Gustaf Waldemarson @ 2023-01-26 12:24 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 14208 bytes --]
Hello!
This is a small issue that have vexed me a number of times when I've
been writing up a report or something where I want to export the results
into multiple formats (such as both LaTeX and HTML in the below
example).
At least for me, it is very common to want to display more than one
image side-by-side, but so far I haven't been able to find any solution
that really works in all regards. The example document below shows some
of the things I've tried and mentions some of the issues:
#+LATEX_CLASS: article
#+LATEX_CLASS_OPTIONS: [a4paper,11pt,twoside]
#+LATEX_HEADER: \usepackage{svg}
#+LATEX_HEADER: \usepackage{subcaption}
#+LATEX_HEADER: \usepackage{placeins}
#+LATEX_HEADER: \usepackage{float}
#+LATEX_HEADER: \usepackage{wrapfig}
#+LATEX_HEADER: \usepackage{graphicx}
#+LATEX_HEADER: \usepackage{xspace}
#+LATEX_HEADER: \captionsetup[subfigure]{labelformat=empty}
#+NAME: a
#+BEGIN_SRC dot :file /tmp/a.png :cmdline -Tpng -Gsize=9,15\! -Gdpi=10
digraph {
1 -> 2;
2 -> 3;
}
#+END_SRC
#+NAME: b
#+BEGIN_SRC dot :file /tmp/b.png :cmdline -Tpng -Gsize=9,15\! -Gdpi=10
digraph {
1 -> 3;
2 -> 3;
}
#+END_SRC
* LaTeX
#+BEGIN_CENTER
#+ATTR_LATEX: :height 0.4\textwidth :center
#+RESULTS: a
[[file:/tmp/a.png]]
#+ATTR_LATEX: :height 0.4\textwidth :center
#+RESULTS: b
[[file:/tmp/b.png]]
#+END_CENTER
* HTML
(Works, but can't control height for both images.)
#+ATTR_HTML: :align center :height 300
[[/tmp/a.png]]
[[/tmp/b.png]]
* HTML + LaTeX
Works in both HTML and LaTeX but disables per-image attributes (:height,
:center etc). Additionally, images in tabular environments tend to be a
bit
fragile in LaTeX depending on which document style is being used. Also
adds
undesired lines above/below the table.
#+ATTR_HTML: :align center
| [[/tmp/a.png]] | [[/tmp/b.png]] |
* LaTeX Only
LaTeX example using the common 'subfigure' package.
\begin{figure}
\centering
\begin{subfigure}[c]{0.5\textwidth}
\centering
\includegraphics[width=0.9\textwidth]{/tmp/a.png}
\caption{a.png}
\end{subfigure}
\begin{subfigure}[c]{0.3\textwidth}
\centering
\includegraphics[width=0.9\textwidth]{/tmp/b.png}
\caption{b.png}
\end{subfigure}
\caption{Subfigures}%
\end{figure}
This question was originally asked almost 5 years ago on
[[
https://emacs.stackexchange.com/questions/38745/orgmode-image-export-side-by-side-to-both-latex-and-html][Emacs
Stack Exchange]], but so far only have a very limited solution in my
opinion. Ideally, I'm looking for some kind of org-mode environment
that could export to most backends (at least HTML and LaTeX) without
duplicating the image exports for each of them individually.
Does something like that already exist in org-mode? Alternatively,
what is the recommended and most portable approach to placing images
side-by-side?
Best Regards,
Gustaf
Emacs : GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.20, cairo version 1.16.0)
of 2022-05-04
Package: Org mode version 9.5.3 (release_9.5.3-3-gd54104 @
/home/guswal01/.local/share/emacs/29.0.50/lisp/org/)
current state:
==============
(setq
org-link-elisp-confirm-function 'yes-or-no-p
org-directory "/home/guswal01/.config/emacs/org/"
org-bibtex-headline-format-function #[257 "\300 \236A\207" [:title] 3
"\n\n(fn ENTRY)"]
org-log-into-drawer t
org-latex-images-centered nil
org-export-before-parsing-hook '(org-attach-expand-links)
org-archive-hook '(org-attach-archive-delete-maybe)
org-odt-format-inlinetask-function
'org-odt-format-inlinetask-default-function
org-ascii-format-drawer-function #[771 " \207" [] 4 "\n\n(fn NAME CONTENTS
WIDTH)"]
org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers
org-cycle-show-empty-lines
org-optimize-window-after-visibility-change)
org-modules '(org-tempo ol-w3m ol-bbdb ol-bibtex ol-docview ol-gnus
ol-info ol-irc ol-mhe
ol-rmail ol-eww)
org-mode-hook '(org-tempo-setup
#[0 "\300\301\302\303\304$\207"
[add-hook change-major-mode-hook org-show-all append
local] 5]
#[0 "\300\301\302\303\304$\207"
[add-hook change-major-mode-hook
org-babel-show-result-all append local]
5]
org-babel-result-hide-spec org-babel-hide-all-hashes
#[0 "\301\211 \207" [imenu-create-index-function
org-imenu-get-tree] 2]
my-org-hook turn-on-org-cdlatex)
org-babel-load-languages '((emacs-lisp . t) (dot . t) (ditaa . t) (python
. t)
(gnuplot . t) (shell . t) (org . t) (plantuml .
t) (latex . t))
org-latex-format-drawer-function #[514 "\207" [] 3 "\n\n(fn _ CONTENTS)"]
org-latex-format-headline-function
'org-latex-format-headline-default-function
org-confirm-shell-link-function 'yes-or-no-p
org-adapt-indentation 'headline-data
org-html-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"]
outline-isearch-open-invisible-function 'outline-isearch-open-invisible
org-export-before-processing-hook '(my/org-inline-css-hook)
org-latex-classes '(("acmart" "\\documentclass{acmart}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
("article" "\\documentclass[11pt]{article}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
("report" "\\documentclass[11pt]{report}"
("\\part{%s}" . "\\part*{%s}") ("\\chapter{%s}" .
"\\chapter*{%s}")
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}"))
("book" "\\documentclass[11pt]{book}" ("\\part{%s}" .
"\\part*{%s}")
("\\chapter{%s}" . "\\chapter*{%s}")
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}"))
)
org-highlight-latex-and-related '(latex)
org-odt-format-headline-function 'org-odt-format-headline-default-function
org-agenda-before-write-hook '(org-agenda-add-entry-text)
org-babel-tangle-lang-exts '(("latex" . "tex") ("python" . "py")
("emacs-lisp" . "el")
("elisp" . "el"))
org-src-mode-hook '(org-src-babel-configure-edit-buffer
org-src-mode-configure-edit-buffer)
org-latex-default-packages-alist '(("AUTO" "inputenc" t ("pdflatex"))
("T1" "fontenc" t ("pdflatex")) (""
"graphicx" t)
("" "longtable" nil) ("" "wrapfig" nil)
("" "rotating" nil) ("normalem" "ulem"
t)
("" "amsmath" t) ("" "capt-of" nil) (""
"hyperref" nil))
org-confirm-elisp-link-function 'yes-or-no-p
org-latex-listings 'minted
org-html-head-extra "<style type=\"text/css\">\n pre.src{background-color:
#2e3436; color: #eeeeec;}</style>\n<style type=\"text/css\">\n
pre.src{background-color: #2e3436; color: #eeeeec;}</style>\n<style
type=\"text/css\">\n pre.src{background-color: #2e3436; color:
#eeeeec;}</style>\n<style type=\"text/css\">\n pre.src{background-color:
#2e3436; color: #eeeeec;}</style>\n<style type=\"text/css\">\n
pre.src{background-color: #2e3436; color: #eeeeec;}</style>\n<style
type=\"text/css\">\n pre.src{background-color: #2e3436; color:
#eeeeec;}</style>\n<style type=\"text/css\">\n pre.src{background-color:
#2e3436; color: #eeeeec;}</style>\n<style type=\"text/css\">\n
pre.src{background-color: #2e3436; color: #eeeeec;}</style>\n<style
type=\"text/css\">\n pre.src{background-color: #2e3436; color:
#eeeeec;}</style>\n<style type=\"text/css\">\n pre.src{background-color:
#2e3436; color: #eeeeec;}</style>\n<style type=\"text/css\">\n
pre.src{background-color: #2e3436; color: #eeeeec;}</style>\n<style
type=\"text/css\">\n pre.src{background-color: #2e3436; color:
#eeeeec;}</style>\n<style type=\"text/css\">\n pre.src{background-color:
#2e3436; color: #eeeeec;}</style>\n<style type=\"text/css\">\n
pre.src{background-color: #2e3436; color: #eeeeec;}</style>\n<style
type=\"text/css\">\n pre.src{background-color: #2e3436; color:
#eeeeec;}</style>\n<style type=\"text/css\">\n pre.src{background-color:
#2e3436; color: #eeeeec;}</style>\n<style type=\"text/css\">\n
pre.src{background-color: #2e3436; color: #eeeeec;}</style>\n<style
type=\"text/css\">\n pre.src{background-color: #2e3436; color:
#eeeeec;}</style>\n<style type=\"text/css\">\n pre.src{background-color:
#2e3436; color: #eeeeec;}</style>\n<style type=\"text/css\">\n
pre.src{background-color: #2e3436; color: #eeeeec;}</style>\n<style
type=\"text/css\">\n pre.src{background-color: #2e3436; color:
#eeeeec;}</style>\n<style type=\"text/css\">\n pre.src{background-color:
#2e3436; color: #eeeeec;}</style>\n<style type=\"text/css\">\n
pre.src{background-color: #2e3436; color: #eeeeec;}</style>\n<style
type=\"text/css\">\n pre.src{background-color: #2e3436; color:
#eeeeec;}</style>\n<style type=\"text/css\">\n pre.src{background-color:
#2e3436; color: #eeeeec;}</style>\n<style type=\"text/css\">\n
pre.src{background-color: #2e3436; color: #eeeeec;}</style>\n<style
type=\"text/css\">\n pre.src{background-color: #2e3436; color:
#eeeeec;}</style>\n<style type=\"text/css\">\n pre.src{background-color:
#2e3436; color: #eeeeec;}</style>\n<style type=\"text/css\">\n
pre.src{background-color: #2e3436; color: #eeeeec;}</style>\n"
org-speed-command-hook '(org-speed-command-activate
org-babel-speed-command-activate)
org-html-format-inlinetask-function
'org-html-format-inlinetask-default-function
org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default
org-latex-prefer-user-labels t
org-odt-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"]
org-export-backends '(ascii html latex odt)
org-confirm-babel-evaluate nil
org-latex-format-inlinetask-function
'org-latex-format-inlinetask-default-function
org-tab-first-hook '(org-babel-hide-result-toggle-maybe
org-babel-header-arg-expand)
org-link-shell-confirm-function 'yes-or-no-p
org-babel-pre-tangle-hook '(save-buffer)
org-agenda-loop-over-headlines-in-active-region nil
org-occur-hook '(org-first-headline-recenter)
org-metadown-hook '(org-babel-pop-to-session-maybe)
org-link-parameters '(("attachment" :follow org-attach-follow :complete
org-attach-complete-link)
("id" :follow org-id-open)
("treemacs" :store treemacs-store-org-link)
("eww" :follow org-eww-open :store
org-eww-store-link)
("rmail" :follow org-rmail-open :store
org-rmail-store-link)
("mhe" :follow org-mhe-open :store
org-mhe-store-link)
("irc" :follow org-irc-visit :store
org-irc-store-link :export
org-irc-export)
("info" :follow org-info-open :export
org-info-export :store
org-info-store-link)
("gnus" :follow org-gnus-open :store
org-gnus-store-link)
("docview" :follow org-docview-open :export
org-docview-export :store
org-docview-store-link)
("bibtex" :follow org-bibtex-open :store
org-bibtex-store-link)
("bbdb" :follow org-bbdb-open :export
org-bbdb-export :complete
org-bbdb-complete-link :store org-bbdb-store-link)
("w3m" :store org-w3m-store-link) ("file+sys")
("file+emacs")
("shell" :follow org-link--open-shell)
("news" :follow
#[514 "\301\300\302 Q \"\207" ["news" browse-url
":"] 6
"\n\n(fn URL ARG)"]
)
("mailto" :follow
#[514 "\301\300\302 Q \"\207" ["mailto" browse-url
":"] 6
"\n\n(fn URL ARG)"]
)
("https" :follow
#[514 "\301\300\302 Q \"\207" ["https" browse-url
":"] 6
"\n\n(fn URL ARG)"]
)
("http" :follow
#[514 "\301\300\302 Q \"\207" ["http" browse-url
":"] 6
"\n\n(fn URL ARG)"]
)
("ftp" :follow
#[514 "\301\300\302 Q \"\207" ["ftp" browse-url
":"] 6
"\n\n(fn URL ARG)"]
)
("help" :follow org-link--open-help :store
org-link--store-help)
("file" :complete org-link-complete-file)
("elisp" :follow org-link--open-elisp))
org-html-format-headline-function
'org-html-format-headline-default-function
org-metaup-hook '(org-babel-load-in-session-maybe)
org-latex-pdf-process '("latexmk -shell-escape -bibtex -f -pdf %f")
org-src-lang-modes '(("plantuml" . plantuml) ("C" . c) ("C++" . c++)
("asymptote" . asy)
("bash" . sh) ("beamer" . latex) ("calc" .
fundamental) ("cpp" . c++)
("ditaa" . artist) ("dot" . fundamental) ("elisp" .
emacs-lisp)
("ocaml" . tuareg) ("screen" . shell-script) ("shell"
. sh)
("sqlite" . sql))
org-tab-before-tab-emulation-hook '(org-tempo-complete-tag)
)
[-- Attachment #2: Type: text/html, Size: 18604 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* [FR] Side-by-side images during export (was: [BUG] Org-mode Side-by-Side Images [9.5.3 (release_9.5.3-3-gd54104)])
2023-01-26 12:24 [BUG] Org-mode Side-by-Side Images [9.5.3 (release_9.5.3-3-gd54104)] Gustaf Waldemarson
@ 2023-02-13 14:48 ` Ihor Radchenko
2023-02-14 7:58 ` Jean Louis
0 siblings, 1 reply; 3+ messages in thread
From: Ihor Radchenko @ 2023-02-13 14:48 UTC (permalink / raw)
To: Gustaf Waldemarson; +Cc: emacs-orgmode
Gustaf Waldemarson <gustaf.waldemarson@gmail.com> writes:
> Does something like that already exist in org-mode? Alternatively,
> what is the recommended and most portable approach to placing images
> side-by-side?
No, AFAIK.
There are two problems:
1. We currently lack object-granular control over export attributes.
Attributes for images are set for the whole paragraph and Org uses a
paragraph starting with image as a special case, assigning paragraph
to the image.
2. There is no easy universal way to create side-by-side images for all
possible backends. The best thing we might provide is merging
multiple images into one using, for example, a LaTeX minipage export
to create merged image to be included into the exported document.
Patches welcome!
This feature is requested from time to time.
--
Ihor Radchenko // yantar92,
Org mode contributor,
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>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [FR] Side-by-side images during export (was: [BUG] Org-mode Side-by-Side Images [9.5.3 (release_9.5.3-3-gd54104)])
2023-02-13 14:48 ` [FR] Side-by-side images during export (was: [BUG] Org-mode Side-by-Side Images [9.5.3 (release_9.5.3-3-gd54104)]) Ihor Radchenko
@ 2023-02-14 7:58 ` Jean Louis
0 siblings, 0 replies; 3+ messages in thread
From: Jean Louis @ 2023-02-14 7:58 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: Gustaf Waldemarson, emacs-orgmode
* Ihor Radchenko <yantar92@posteo.net> [2023-02-13 17:50]:
> Gustaf Waldemarson <gustaf.waldemarson@gmail.com> writes:
>
> > Does something like that already exist in org-mode? Alternatively,
> > what is the recommended and most portable approach to placing images
> > side-by-side?
>
> No, AFAIK.
Org is already a text structure that has elementary objects defined,
as you said, not everything is granular, but there is no limit what
users can define in Org.
Elementary Objects:
https://www.dougengelbart.org/content/view/110/460/#2a1a
So anything can be elementary object, no matter in what kind of a
system.
By having that in mind, I think other objects could be used to get
what user wants.
In Asciidoctor I can make table with invisible lines, and position
pictures inside of cells, or place some text on sides. There exists
Asciidoc export for Org. What you read is now my thoughts about it,
development towards possible solution:
| My left | My right |
|---------+----------|
| left | right |
Giving this with Asciidoc Org export:
[width="80%",options="header"]
|====
| My left| My right
| left| right
|====
Then this here:
| [[./img/a.jpg]] | [[./img/b.jpg]] |
Get correctly exported as:
[width="80%"]
|====
| image:./img/a.jpg[]| image:./img/b.jpg[]
|====
in Asciidoctor.
One can use that as fundamental point. Instead of using Asciidoctor
export, one could use source blocks to generate LaTeX export by using
Asciidoctor markup.
Here is only the idea:
#+BEGIN_SRC asciidoctor-to-latex
[width="80%"]
|====
| image:./img/a.jpg[]| image:./img/b.jpg[]
|====
#+END_SRC
Then based on following function, one can conevert that above:
(defun rcd-asciidoc-snippet-no-header-footer-to-latex (text)
"Return LaTeX for Asciidoc snippet TEXT without header and footer."
(let* ((text (rcd-asciidoctor text "-s" "-b" "docbook5"))
(text (rcd-pandoc-convert-string text "docbook" "latex")))
text))
(rcd-asciidoc-snippet-no-header-footer-to-latex "
[width=\"80%\"]
|====
| image:./img/a.jpg[]| image:./img/b.jpg[]
|====
") ➜ "\\begin{longtable}[]{@{}
>{\\raggedright\\arraybackslash}p{(\\columnwidth - 2\\tabcolsep) * \\real{0.4000}}
>{\\raggedright\\arraybackslash}p{(\\columnwidth - 2\\tabcolsep) * \\real{0.4000}}@{}}
\\toprule\\noalign{}
\\endhead
\\bottomrule\\noalign{}
\\endlastfoot
\\includegraphics{./img/a.jpg} & \\includegraphics{./img/b.jpg} \\\\
\\end{longtable}
"
and by using the above think process, it is possible to make
following, by using the Org snippet:
#+BEGIN_SRC org-to-asciidoc-to-latex
| [[./img/a.jpg]] | [[./img/b.jpg]] |
#+END_SRC
then such Org snippet can be converted to Asciidoc, then to docbook5,
then to LaTeX or to HTML.
Solution is right there by using pandoc, asciidoctor and "elementary
objects" as Org Babel source blocks.
And this may not be the only solution.
> There are two problems:
> 1. We currently lack object-granular control over export attributes.
> Attributes for images are set for the whole paragraph and Org uses a
> paragraph starting with image as a special case, assigning paragraph
> to the image.
By using above method, that is solved for each individual user how
they wish and want. It does not need much adaptation IMHO.
> 2. There is no easy universal way to create side-by-side images for all
> possible backends.
As if you do not control those backends, there is also no need for that.
However, by using the above method, it is possible to solve it for all
backends straight from Org, by only adding conversion function.
> The best thing we might provide is merging multiple images into one
> using, for example, a LaTeX minipage export to create merged image
> to be included into the exported document.
Merging multiple images sounds to me as hard coding.
Providing small conversion functions for various exports like HTML,
Org would just make it work.
I did not provide final example in this e-mail, but now you could, I
gave you the thought process and functionality.
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-14 7:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-26 12:24 [BUG] Org-mode Side-by-Side Images [9.5.3 (release_9.5.3-3-gd54104)] Gustaf Waldemarson
2023-02-13 14:48 ` [FR] Side-by-side images during export (was: [BUG] Org-mode Side-by-Side Images [9.5.3 (release_9.5.3-3-gd54104)]) Ihor Radchenko
2023-02-14 7:58 ` Jean Louis
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.