emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Fix caption format for custom latex src block


From: Matt Huszagh
Subject: [PATCH] Fix caption format for custom latex src block
Date: Wed, 29 Dec 2021 20:05:59 -0800

This patch fixes an issue in which captions for custom listing
environments are not converted correctly. To illustrate the issue,
take the following MWE.

file.org:
```
#+caption: Perform inter-sample interpolation.
#+begin_src python
import numpy as np
#+end_src
```

file.el:
```
;; Loading straight isn't necessary if you don't use it, just need to
;; load org.
(load "~/.config/emacs/straight/repos/straight.el/bootstrap.el")
(straight-use-package 'org)

(find-file "file.org")
(setq org-latex-listings 'minted)
(setq org-latex-custom-lang-environments
      '((python "\\begin{listing}
\\begin{minted}[%o]{python}
%s\\end{minted}
\\caption{%c}
\\label{%l}
\\end{listing}")))
(org-latex-export-to-latex)
```

Run the example with:
emacs -Q --batch -l file.el

Before the patch, you get:
```
[...]
\begin{listing}
\begin{minted}[]{python}
import numpy as np
\end{minted}
\caption{(((Perform inter-sample interpolation.)))}
\label{nil}
\end{listing}
[...]
```

After the patch, you get:
```
[...]
\begin{listing}
\begin{minted}[]{python}
import numpy as np
\end{minted}
\caption{Perform inter-sample interpolation.}
\label{nil}
\end{listing}
[...]
```

I'm not actually 100% confident that the patch is the optimal way to
do this. The API wasn't totally clear to me in this case. Any advice
here is appreciated.

Matt

Attachment: 0001-ox-latex.el-Fix-caption-format-for-custom-latex-src-.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]