# How to set width for subfigures inside a table in a org-mode file?

I'd like to use subfigures in org-mode files. In MS Word, this could be easily done by inserting the subfigures of a figure into a table with invisible borders. Then the size of each subfigure can be adjusted as you like.

Is there a way to use subfigures like this in Org-mode?

I tried to set size with e.g. #+ATTR_ORG: :width 400, and it only works on a single figure.

So, this works with the intended figure size:

#+CAPTION: Test Figure
#+NAME: fig:test0
#+ATTR_ORG: :width 400
[[file:build/test.png]]


But when put into a table, the specified figure size (width) is ignored. (And the actual size of the sub-figure is used, which is way too large).

#+CAPTION: Test Figure
#+NAME: fig:test
#+ATTR_ORG: :width 400
| [[file:build/test.png]] | [[file:build/test.png]] |


I have (setq org-image-actual-width nil) in my init.el. And this is under Emacs 26, Ubuntu 20.04, and Org mode version 9.3.7 (9.3.7-8-g3ed035-elpaplus). I am interested in exporting the org file to multiple targets including ODT. (So, I am looking for a generic solution.)

If the above usage is wrong, what is the correct usage to get properly sized subfigures?

-- Update --

This blog about extending org link syntax seems relevant. I guess I am looking for an extended way of specifying the image size as part of the link, with something like this:

[[file:build/test.png :width 300]]


as in

#+CAPTION: Test Figure
#+NAME: fig:test
| [[file:build/test.png :width 300]] | [[file:build/test.png :width 300]] |


Is this doable in org?

• I don't think there is any facility in Org mode to do that for every export backend. You can probably do it for LaTeX/PDF and HTML with a back-end-specific macro, but it is not going to be simple or pretty. – NickD Aug 18 '20 at 13:11

If you can live without captions on subfigures this seem to work:

#+CAPTION: Two subfigures
#+NAME:   fig:twofigures
\begin{figure}
\centering
\begin{subfigure}
\centering
\includegraphics[width=0.47\textwidth]{image}
\end{subfigure}
\begin{subfigure}
\centering
\includegraphics[width=0.47\textwidth]{image}
\end{subfigure}
\end{figure}

Reference to Figure [[fig:twofigures]].