Skip to content

Instantly share code, notes, and snippets.

@patrl
Created January 5, 2022 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patrl/91596a846fc6c52d831681665b26bc73 to your computer and use it in GitHub Desktop.
Save patrl/91596a846fc6c52d831681665b26bc73 to your computer and use it in GitHub Desktop.
Hack to make org special blocks work with gb4e
(defun patrl/org-latex-special-block (special-block contents info)
"Transcode a SPECIAL-BLOCK element from Org to LaTeX.
CONTENTS holds the contents of the block. INFO is a plist
holding contextual information."
(let ((type (org-element-property :type special-block))
(opt (org-export-read-attribute :attr_latex special-block :options))
(caption (org-latex--caption/label-string special-block info))
(caption-above-p (org-latex--caption-above-p special-block info)))
(if
(equal (format "%s" type) "exe")
(concat (format "\\begin{%s}%s\n" type (or opt ""))
(and caption-above-p caption)
"\\ex " contents
(and (not caption-above-p) caption)
(format "\\end{%s}" type))
(concat (format "\\begin{%s}%s\n" type (or opt ""))
(and caption-above-p caption)
contents
(and (not caption-above-p) caption)
(format "\\end{%s}" type)))))
(org-export-define-derived-backend 'patrl/latex 'latex
:translate-alist '((special-block . patrl/org-latex-special-block)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment