I've been using org-special-block-extras to insert special blocks in org-mode which I then export to PDF through LaTeX, things such as margin notes or colored blocks.

It used to work until recently (couple days ago) but now the special blocks are expanded incorrectly and it errors out.

Minimal example,

#+title: This is a title
#+author: ME

* Introduction

Next, writing in the margin.

#+begin_margin note
this is a margin note


This used to expand to a \marginpar such as shown into the docs :

(o-defblock margin
  (marker nil
          :display 'full
          :face '(:foreground "grey" :weight bold
          :underline "orange" :overline "orange"))
  (color "gray!80"
          counter "footnote"
          width "\\paperwidth - \\textwidth - \\oddsidemargin - 1in - 3ex")
          ;; Width: https://tex.stackexchange.com/a/101861/69371
  "Produce an HTML tooltip or a LaTeX margin note.

The ‘margin’ block is intended for “one-off” (mostly optional) remarks.

For notes that you want to use repeatedly, in multiple articles
or in multiple locations in the same article, consider using
‘documentation’ to declare them and ‘doc’ to invoke them.

For LaTeX, place ‘#+resize:’ to have the remainder of a block be
resized, for now 1.3 the margin width ---requires \\usepackage{adjustbox}.


WIDTH, COUNTER, and COLOR are LaTeX specfic.

When no label, marker, is used for a marginal note, we rely
on a COUNTER, such as ‘footnote’ (default) or ‘sidenote.’
Since HTML has no margin per se, we use “∘” as default marker:
Users hover over it to read the marginal note.

Marginal notes have their labels, markers, in black
and the notes themselves have COLOR being grey!80.
In Emacs, margin links appear grey with an orange tinted boarder.

Regarding LaTeX, since verbatim environments do not in general work well
as arguments to other commands, such as ‘\\marginpar’, we save the contents
of the special block in a ‘minipage’ within a LaTeX ‘box’; then we can unfold such
a box in the margin. Hence, ‘src’ blocks can appear within ‘margin’ blocks (•̀ᴗ•́)و

The WIDTH argument is the width of the margin; i.e., the width of the underlying

One could use \\maxsizebox{.25\\textwidth}{\\textheight}{ ... }
which only resizes the content if its natural size is larger than
the given 〈width〉 or 〈height〉.  We don't use this, since
maxsizebox does not natively allow linebreaks
(e.g., one would wrap contents in a tabular environment then use
‘\\\\’, two backslashes, to request a line break; but this
crashes if one wants to also use verbatim environments.)

In LaTeX, it may be useful to invoke ‘\\dotfill’."
  (-let [stepcounter (if marker "" (format "\\stepcounter{%s}" counter))]
    (pcase backend
       (setq marker (or marker (format "{\\the%s}" counter))) ;; "\\circ"
       (format "\\!\\!${}^{\\textnormal{%s}}$
               \\raggedright \\iffalse Otherwise default alignment is fully justified. \\fi
               \\setminted{fontsize=\\footnotesize, breaklines} \\iffalse HACK! \\fi
               {\\color{black}${}^{\\textnormal{%s}}$}\n\\normalfont\n %s
               (if (s-contains? "#+resize:" contents)
                    (s-replace "#+resize:"
                               "#+latex: \\maxsizebox{1.3\\textwidth}{\\textheight}{\\begin{tabular}{l}\n"
                               (s-trim contents))
                 (s-trim contents))
      (_ (setq marker (or marker "°"))
         (format "<abbr class=\"tooltip\" title=\"%s\">%s</abbr>&emsp13;"
                 (o-html-export-preserving-whitespace contents)
                 ; MA: FIXME: (org-export-string-as contents 'html :body-only-please)

But now, it simply expands to

this is a margin note

Since there is no such thing as a margin environment, LaTeX compilation fails.

Relevant information :

  • Emacs version : GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.34, cairo version 1.17.6) of 2022-06-03

  • Org version : Org mode version 9.5.3 (release_9.5.3-6-gef41f3 @ /usr/local/share/emacs/29.0.50/lisp/org/)

  • org-special-block-extras version : 20220326.1432

  • Are you turning on the minor mode in Org mode buffers? The simplest thing is to add (add-hook 'org-mode-hook #'org-special-block-extras-mode) to your init file - maybe you had it and it somehow got deleted?
    – NickD
    Jun 3 at 15:35
  • You can also do it manually (for testing) with C-u M-x org-special-block-extras-mode.
    – NickD
    Jun 3 at 15:41
  • Yes! I've got (org-mode-hook . org-special-block-extras-mode) in my use-package config and I can confirm the mode is on with C-h m. Jun 3 at 16:00
  • I cannot reproduce the problem then: I installed org-special-block-extras-mode from GitHub, I loaded the .el file manually and I turned on the minor mode manually on the Org mode file. I could then export it to PDF and got the marginal note.
    – NickD
    Jun 3 at 17:54
  • @NickD What's your Emacs version? Jun 3 at 18:33


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.