* Sub-figures in Org Mode
@ 2021-10-22 23:27 Jason Ross
2021-10-23 0:00 ` Juan Manuel Macías
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Jason Ross @ 2021-10-22 23:27 UTC (permalink / raw)
To: emacs-orgmode
Are there any workarounds people use to create subfigures in Org Mode
when exporting to LaTeX? Example output:
#+begin_example latex
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\begin{subfigure}{.5\textwidth}
\centering
\includegraphics[width=.8\linewidth]{image1}
\caption{1a}
\label{fig:sfig1}
\end{subfigure}%
\begin{subfigure}{.5\textwidth}
\centering
\includegraphics[width=.8\linewidth]{image2}
\caption{1b}
\label{fig:sfig2}
\end{subfigure}
\caption{plots of....}
\label{fig:fig}
\end{figure}
\end{document}
#+end_example
Based on how ox-latex.el handles images I don't see how this would be
possible but the people on this list are a lot smarter than I am so
maybe one of you has found a way.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Sub-figures in Org Mode
2021-10-22 23:27 Sub-figures in Org Mode Jason Ross
@ 2021-10-23 0:00 ` Juan Manuel Macías
2021-10-26 17:46 ` Jason Ross
2021-10-25 10:44 ` Eric S Fraga
2021-10-25 10:48 ` Eric S Fraga
2 siblings, 1 reply; 6+ messages in thread
From: Juan Manuel Macías @ 2021-10-23 0:00 UTC (permalink / raw)
To: Jason Ross; +Cc: orgmode
Hi Jason,
Jason Ross <jasonross1024@gmail.com> writes:
> Are there any workarounds people use to create subfigures in Org Mode
> when exporting to LaTeX? Example output:
In this thread I explain a procedure to export images as subfigures
using org links: https://list.orgmode.org/87mty1an66.fsf@posteo.net/
Best regards,
Juan Manuel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Sub-figures in Org Mode
2021-10-22 23:27 Sub-figures in Org Mode Jason Ross
2021-10-23 0:00 ` Juan Manuel Macías
@ 2021-10-25 10:44 ` Eric S Fraga
2021-10-25 10:48 ` Eric S Fraga
2 siblings, 0 replies; 6+ messages in thread
From: Eric S Fraga @ 2021-10-25 10:44 UTC (permalink / raw)
To: Jason Ross; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 477 bytes --]
On Friday, 22 Oct 2021 at 16:27, Jason Ross wrote:
> Are there any workarounds people use to create subfigures in Org Mode
> when exporting to LaTeX? Example output:
The attached should do the job? At least, it seems to export to your
sample LaTeX. I cannot compile as for some reason subcaption conflicts
with my standard org to LaTeX setup.
--
: Eric S Fraga via Emacs 28.0.60, Org release_9.5-163-g4eab5b
: Latest paper written in org: https://arxiv.org/abs/2106.05096
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: t.org --]
[-- Type: text/x-org, Size: 609 bytes --]
#+latex_header: \usepackage[demo]{graphicx}
#+latex_header: \usepackage{subcaption}
* Question
Are there any workarounds people use to create subfigures in Org Mode
when exporting to LaTeX? Example output:
* Attempt
#+name: fig:fig
#+caption: plots of....
#+begin_figure
#+name: fig:sfig1
#+caption: 1a
#+attr_latex: :options {0.5\textwidth}
#+begin_subfigure
#+attr_latex: :width 0.8\linewidth
[[~/s/test/mip.png]]
#+end_subfigure
#+name: fig:sfig2
#+attr_latex: :options {0.5\textwidth}
#+caption: 1a
#+begin_subfigure
#+attr_latex: :width 0.8\linewidth
[[~/s/test/mip.png]]
#+end_subfigure
#+end_figure
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Sub-figures in Org Mode
2021-10-22 23:27 Sub-figures in Org Mode Jason Ross
2021-10-23 0:00 ` Juan Manuel Macías
2021-10-25 10:44 ` Eric S Fraga
@ 2021-10-25 10:48 ` Eric S Fraga
2 siblings, 0 replies; 6+ messages in thread
From: Eric S Fraga @ 2021-10-25 10:48 UTC (permalink / raw)
To: Jason Ross; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 183 bytes --]
Updated example attached: forgot the subcaptions...
--
: Eric S Fraga via Emacs 28.0.60, Org release_9.5-163-g4eab5b
: Latest paper written in org: https://arxiv.org/abs/2106.05096
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: t.org --]
[-- Type: text/x-org, Size: 659 bytes --]
#+latex_header: \usepackage[demo]{graphicx}
#+latex_header: \usepackage{subcaption}
* Question
Are there any workarounds people use to create subfigures in Org Mode
when exporting to LaTeX? Example output:
* Attempt
#+name: fig:fig
#+caption: plots of....
#+begin_figure
#+name: fig:sfig1
#+attr_latex: :caption \subcaption{1a}
#+attr_latex: :options {0.5\textwidth}
#+begin_subfigure
#+attr_latex: :width 0.8\linewidth
[[~/s/test/mip.png]]
#+end_subfigure
#+name: fig:sfig2
#+attr_latex: :options {0.5\textwidth}
#+attr_latex: :caption \subcaption{1b}
#+begin_subfigure
#+attr_latex: :width 0.8\linewidth
[[~/s/test/mip.png]]
#+end_subfigure
#+end_figure
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Sub-figures in Org Mode
2021-10-23 0:00 ` Juan Manuel Macías
@ 2021-10-26 17:46 ` Jason Ross
2021-10-30 14:28 ` Juan Manuel Macías
0 siblings, 1 reply; 6+ messages in thread
From: Jason Ross @ 2021-10-26 17:46 UTC (permalink / raw)
To: Juan Manuel Macías; +Cc: orgmode
Hi Juan,
On 10/22/21 5:00 PM, Juan Manuel Macías wrote:
> Hi Jason,
>
> Jason Ross <jasonross1024@gmail.com> writes:
>
>> Are there any workarounds people use to create subfigures in Org Mode
>> when exporting to LaTeX? Example output:
>
> In this thread I explain a procedure to export images as subfigures
> using org links: https://list.orgmode.org/87mty1an66.fsf@posteo.net/
>
> Best regards,
>
> Juan Manuel
>
Those are some really clever solutions. I hadn't considered using a
dsl for figure options.
I'm looking at declaring a "figure" block the way you are, but
`org-element-map'ing over the links inside the block and processing them
with the "normal" link-handling machinery. That way, image options work
the same way in a subfigure as they do normally.
Here's what I'm messing with for the ConTeXt backend (this relies
on some changes to figure handling I haven't pushed yet):
#+begin_src elisp
(defun org-context--special-block-figure (orig-fun special-block
contents info)
(let ((type (org-element-property :type special-block)))
(if (string= "figure" (downcase type))
(let* ((attr (org-export-read-attribute :attr_context
special-block))
(links (org-element-map special-block 'link #'identity))
(placefigure-options
(org-context--format-arguments
(org-context--get-placefigure-options special-block
info)))
(captionp
(mapcan
(lambda (link)
(let* ((parent (org-export-get-parent-element link))
(caption (org-string-nw-p
(org-context--caption/label-string parent info))))
(and caption (list caption))))
links))
(image-codes
(mapconcat
(lambda (link)
(let ((figure-string
(org-context--get-link-figure-string link info)))
(if captionp
(let ((caption
(org-string-nw-p
(org-context--caption/label-string
(org-export-get-parent-element link)
info))))
(format "{%s}\n{%s}"
figure-string (or caption "")))
(format "{%s}" figure-string)))
)
links
"\n"))
(dimensions
(let* ((rows (plist-get attr :rows))
(cols (plist-get attr :cols))
(nlinks (length links)))
(if
(and rows cols)
(cons (string-to-number rows) (string-to-number
cols))
(cons 1 nlinks))))
combination-options)
(if captionp
(push (cons "alternative" "text") combination-options)
(push (cons "alternative" "label") combination-options))
(push (cons "nx" (format "%s" (cdr dimensions)))
combination-options)
(push (cons "ny" (format "%s" (car dimensions)))
combination-options)
(message (format "%S" combination-options))
(format "\\startplacefigure[%s]
\\startcombination[%s]
%s
\\stopcombination
\\stopplacefigure"
placefigure-options
(org-context--format-arguments combination-options)
image-codes))
(funcall orig-fun special-block contents info))))
(advice-add 'org-context-special-block :around
#'org-context--special-block-figure)
#+end_src
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Sub-figures in Org Mode
2021-10-26 17:46 ` Jason Ross
@ 2021-10-30 14:28 ` Juan Manuel Macías
0 siblings, 0 replies; 6+ messages in thread
From: Juan Manuel Macías @ 2021-10-30 14:28 UTC (permalink / raw)
To: Jason Ross; +Cc: orgmode
Hi Jason, sorry for the late reply.
Jason Ross writes:
> I'm looking at declaring a "figure" block the way you are, but
> `org-element-map'ing over the links inside the block and processing them
> with the "normal" link-handling machinery. That way, image options work
> the same way in a subfigure as they do normally.
I really like your idea, and it's more consistent with the Org syntax,
since (as you say) the images behave like images and it is not necessary
to enter the options via marks within the link description, which is somewhat
hacky. I think your idea could also be adapted to LaTeX (and HTML)
backends...
Best regards,
Juan Manuel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-10-30 14:29 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-22 23:27 Sub-figures in Org Mode Jason Ross
2021-10-23 0:00 ` Juan Manuel Macías
2021-10-26 17:46 ` Jason Ross
2021-10-30 14:28 ` Juan Manuel Macías
2021-10-25 10:44 ` Eric S Fraga
2021-10-25 10:48 ` Eric S Fraga
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.