No Description

eDgar 630499f4f4 Deprecated: subcaption → subfig 2 years ago
LICENSE a15b67f4f4 license 3 years ago
README.org 630499f4f4 Deprecated: subcaption → subfig 2 years ago
ox-latex-subfigure.el 07e5f99eb1 add sub-headings to installation instructions; upd8 svgpath doc 2 years ago
transmission.svg 502d79b825 include an SVG, upd8 examples 3 years ago

README.org

Deprecated

This package has been deprecated, because subcaption is deprecated. You can find the alternative to use subfig here: https://www.notabug.org/broncodev/ox-latex-subfig

Presentation

This package allows to have \LaTeX subfigures as tables in your Org documents (https://orgmode.org). In this way, it is possible to have figures side by side with a subcaption. You can read this text more comfortably with Emacs, just donwload README.org (https://www.notabug.org/broncodev/ox-latex-subfigure/src/master/README.org).

How

Installation

Get the code

To install, you can clone this repository using the Linux terminal:

torsocks git clone https://www.notabug.org/broncodev/ox-latex-subfigure

That will create an ox-latex-subfigure sub-directory where you typed that command. Then, you can add one of these 2 into your Emacs init file (usually =.emacs= or init.el=; you can find it in the Emac's =user-init-file variable):

Load into Emacs

  1. Autoload with (require 'package)

#+begin_src emacs-lisp (with-eval-after-load "ox" (add-to-list 'load-path "/path/to/ox-latex-subfigure/") (require 'ox-latex-subfigure) ;; ;; If you want the caption above the figure ;; (add-to-list 'org-latex-caption-above 'subfigure) ) #+end_src

  1. Autoload with use-package.el (https://github.com/jwiegley/use-package)

#+BEGIN_SRC emacs-lisp ;; Add use-package to `load-path' (add-to-list 'load-path "/path/to/use-package") ;; Load `use-package' (require 'use-package) ;; Enable (use-package ox-latex-subfigure :init (setq org-latex-prefer-user-labels t) :load-path "/path/to/ox-latex-subfigure/" :after "ox" :config (require 'ox-latex-subfigure) ;; ;; If you want the caption above the figure ;; (add-to-list 'org-latex-caption-above 'subfigure) ) #+END_SRC

Add needed packages into your Org file

In your Org file, you'll need to load the subcaption package. This is included in many GNU/Linux distibutions.

Install TeX Live

pacman -S texlive-core

sudo apt-get install texlive-generic-extra

SVG support (optional)

If you are going to use svg files, you will need the \LaTeX svg package. You can get it with the texlive-latexextra in some distributions

pacman -S texlive-latexextra

,#+LATEX_HEADER: \usepackage{svg} ,#+LATEX_HEADER: \svgpath{{my/path1}{my/figures/path}}

Use

There is a transmission.svg included in this repository, which comes from the transmission-gtk package (http://www.transmissionbt.com/). If you convert that file to png (with ImageMagick: convert transmission.svg transmission.png), the examples below will show an image. You can also replace transmission.png and transmission.svg with something that you prefer.

Basic (default options)

With this code, you'll have a main caption, and 2 subfigures side by side, each with its own subcaption. The right-side picture will have an Org reference which produces a LaTeX \label.


  ,#+LATEX_HEADER: \usepackage{subcaption}
  ,#+NAME: fig:hello
  ,#+CAPTION: Use figure/subfigure instead of tabular, remember to set =:environment=
  ,#+ATTR_LATEX: :environment subfigure :width 0.4\textwidth :align c
  | [[transmission.png]] | <<fig:hello_subfigure>> tttttt |
  | zzzzz                      | [[transmission.png]]     |

Ordinary linking works as usual src_org[:eval never :exports code]{fig:hello}; internal org-mode linking also works src_org[:eval never :exports code]{fig:hello_subfigure} if one has =org-latex-prefer-user-labels= set to t.


  \begin{figure}[!htb]
  \centering
  \begin{subfigure}[c]{0.4\textwidth}
  \includegraphics[width=.9\linewidth]{/Users/link/Desktop/figure_1.png}
  \caption{zzzzz}
  \end{subfigure}
  \begin{subfigure}[c]{0.4\textwidth}
  \includegraphics[width=.9\linewidth]{/Users/link/Desktop/figure_1.png}
  \caption{\label{fig:hello_subfigure} tttttt}
  \end{subfigure}
  \caption{\label{fig:hello}
  Use figure/subfigure instead of tabular, remember to set \texttt{:environment}}
  \end{figure}

Passing options to includesvg or includegraphics

It is possible to use SVG and pass options to includegraphics and includesvg (from \LaTeX svg package). For example, this code:


  ,#+CAPTION: Plot.
  ,#+ATTR_LATEX: :environment subfigure :width 0.475\textwidth :align c
  | [[file:transmission.svg]] |
  | <<fig-0104>>                                   |
  | keepaspectratio,height=\textheight,width=0.98\linewidth             |

  See fig. [[fig-0104]]

would produce this:


  \begin{figure}[htbp]
    \begin{subfigure}[c]{0.475\textwidth}\centering
      \includesvg[keepaspectratio,height=\textheight,width=0.98\linewidth]{transmission}
      \caption{\label{fig-0104}}
    \end{subfigure}
    \caption{Plot.}
    \centering
  \end{figure}

  See fig. \ref{fig-0104}

Alignment and width of the each cell

The width can be specified for each column in the :width attribute as comma-separated arguments, and the align as individual characters in the :align attribute


  ,#+CAPTION: Use figure/subfigure instead of tabular, remember to set =:environment=
  ,#+ATTR_LATEX: :environment subfigure :width 0.475\linewidth,0.3\linewidth :align lc
  | <<fig-0104>>       | <<fig_1>>          |
  | [[file:transmission.svg]] | [[file:transmission.svg]] |
  | keepaspectratio    |                    |

with the following result:


  \begin{figure}[htbp]
  \centering
  \begin{subfigure}[l]{0.475\linewidth}\centering
  \includesvg[keepaspectratio]{myfigure1}
  \caption{\label{fig-0104}}
  \end{subfigure}
  \begin{subfigure}[c]{0.3\linewidth}\centering
  \includesvg[]{myfigure2}
  \caption{\label{fig_1}}
  \end{subfigure}
  \caption{\label{fig:hello}
  Use figure/subfigure instead of tabular, remember to set \texttt{:environment}}
  \end{figure}

Subcaptions only

It is possible to keep the picture without a main caption, with subcaptions alone


  ,#+LATEX_HEADER: \usepackage{subcaption}
  ,#+NAME: fig:hello
  ,#+ATTR_LATEX: :environment subfigure :align c :width 0.4\textwidth
  | [[file:transmission.svg]] | [[file:transmission.svg]] |
  | a                     | b                     |

Known bugs

Not having a caption


  ,#+LATEX_HEADER: \usepackage{subcaption}
  ,#+NAME: fig:hello
  ,#+ATTR_LATEX: :environment subfigure :align c
  | [[file:transmission.svg]] | [[file:transmission.svg]] |

Empty subcaptions

Using a label without subcaption


  ,#+LATEX_HEADER: \usepackage{subcaption}
  ,#+NAME: fig:hello
  ,#+CAPTION: Using a label without subcaption
  ,#+ATTR_LATEX: :environment subfigure :align c
  | <<fig-0104>>       | <<fig_1>>          |
  | [[file:transmission.svg]] | [[file:transmission.svg]] |

Trying to add individual options when there is no subcaption


  ,#+LATEX_HEADER: \usepackage{subcaption}
  ,#+NAME: fig:hello
  ,#+CAPTION: Trying to add individual options when there is no subcaption
  ,#+ATTR_LATEX: :environment subfigure :width 0.475\linewidth,0.3\linewidth :align lc
  | <<fig-0104>>       | <<fig_1>>          |
  | [[file:transmission.svg]] | [[file:transmission.svg]] |

Even if you try to have the label below without subcaption


  ,#+LATEX_HEADER: \usepackage{subcaption}
  ,#+NAME: fig:hello
  ,#+CAPTION: Even if you try to have the label below without subcaption
  ,#+ATTR_LATEX: :environment subfigure :width 0.475\linewidth,0.3\linewidth :align lc
  | [[file:transmission.svg]] | [[file:transmission.svg]] |
  | <<fig-0104>>       | <<fig_1>>          |

Trying to have an empty subcaption with @@latex: @@ (you can try a period =.=, if you want; that works)


  ,#+LATEX_HEADER: \usepackage{subcaption}
  ,#+NAME: fig:hello
  ,#+CAPTION: Trying to have an empty subcaption with =@@latex: @@=
  ,#+ATTR_LATEX: :environment subfigure :align c
  | <<fig-0104>> @@latex: @@ | <<fig_1>> @@latex: @@ |
  | [[file:transmission.svg]]       | [[file:transmission.svg]]    |

Row ordering

Using the last row for the link of the figure


  ,#+LATEX_HEADER: \usepackage{subcaption}
  ,#+NAME: fig:hello
  ,#+CAPTION: Using the last row for the link of the figure
  ,#+ATTR_LATEX: :environment subfigure :width 0.475\linewidth,0.3\linewidth :align lc
  | <<fig-0104>>       | <<fig_1>>          |
  | keepaspectratio    |                    |
  | [[file:transmission.svg]] | [[file:transmission.svg]] |

Individual options for only some subfigures

,#+LATEX_HEADER: \usepackage{subcaption} ,#+NAME: fig:hello ,#+CAPTION: Use figure/subfigure instead of tabular, remember to set =:environment= ,#+ATTR_LATEX: :environment subfigure :align c | keepaspectratio | | | transmission.svg | transmission.svg | | <> | <> |

Note how the \label{fig-0104} is used as an argument to =\includesvg=:

\begin{figure}[htbp] \begin{subfigure}[c]{.9\textwidth}\centering \includesvg[\label{fig-0104}]{transmission} \caption{keepaspectratio} \end{subfigure} \begin{subfigure}[c]{.9\textwidth}\centering \includesvg[\label{fig_1}]{transmission} \caption{} \end{subfigure} \caption{\label{fig:hello}Use figure/subfigure instead of tabular, remember to set \texttt{:environment}} \centering \end{figure}

Contributions

conao3, a.k.a linktohack
creator
@eoma
org-mode 9 compatibility
  • eDgar ::
  • SVG support
  • Individual options for each subfigure (width etc)
  • Different widths
  • Different aligns
  • License

    GNU GENERAL PUBLIC LICENSE Version 3 (GPL v.3)