org-special-block-extras: The block and link types

Ξ
- 1. Boxed Text —Calling out super duper info
- 2. Folded Details —Let the user see stuff only if they're interested
- 3. Nice Keystroke Renditions: kbd:C-h_t
- 4. Remark —Inline footnotes, viz HTML tooltips and LaTeX notes in the margin
- 5. Glossaries —Define a term once, cite it with
doc:𝒳 - 6. Parallel ---Place ideas side-by-side, possibly with a separator
- 7. Aligned equations ---
#+begin_align, cited byeqref:𝒳 - 8.
latex-definitionsfor hiding LaTeX declarations in HTML - 9. Graphs ---Org lists, drawn by Graphviz
- 10. Switches for every block:
:when,:let,:folded, … - 11. Callouts —Note, tip, important, warning, caution
- 12. Colours ---
red:𝒳,[[color:#ff0066][𝒳]], and#+begin_red - 13. Quotations, cited ---
#+begin_quote KEY - 14. Highlights —Colour the background, not the text
- 15. Page-wide CSS with
style - 16. Markdown export —What survives GitHub, and how to change it
- 17. PDF export —The LaTeX packages our blocks need, loaded for us
⭐ The code lives at github.com/alhassy/org-special-block-extras —star it, or discuss it there!
1. Boxed Text —Calling out super duper info
﴾What You Write﴿
It can be useful to draw attention to some important text by enclosing it in a [[doc:org-block/box][box]]. #+begin_box Uses of callout boxes Such boxes often callout tips, warnings, cautionary info or emphasises core information. #+end_box
﴾What You Get﴿
It can be useful to draw attention to some important text by
enclosing it in a boxEnclose text in a box, possibly with a TITLE.
By default, the box’s BACKGROUND-COLOR is green for HTML and red for LaTeX;
for LaTeX, there are also FRAME-COLOR and TITLE-BACKGROUND-COLOR.
SHADOW is an alternate style of boxing: It shows the contents in a centred
box with a shadow colour being the given non-nil value of SHADOW.
If SHADOW is a hexadecimal colour, it should be a string enclosed in double quotes.
More accurately, the following are all valid uses:
#+begin_box title :shadow t
#+begin_box title :shadow inset
#+begin_box title :shadow "pink"
#+begin_box title :shadow pink
#+begin_box title :shadow (cyan pink orange yellow)
#+begin_box title :shadow (cyan "inset pink" orange)
#+begin_box title :shadow (:left cyan :right pink :deep-right orange :deep-left yellow)
Notice that prefixing colours with ‘inset’ causes the colour to be within the box,
rather than spread, with blur, around the box. The use of ‘inset’ swaps left and right.
The HTML export uses a padded div, whereas the LaTeX export
requires the tcolorbox package; Markdown, sans colours, gets a quote opening with TITLE in bold.
Regarding the Lisp function:
+ BACKEND refers to the current export backend.
+ RAW-CONTENTS refers to the text as the user wrote it, sans its least indentation.
⇒ You may mention CONTENTS to refer to the ‘org parsed’ version of user text.
⇒ CONTENTS and RAW-CONTENTS are identical whenever key CONTENTS-OCCUR-AS-LINK-DESCRIPTION is non-nil.
For example, upon LaTeX export, the Org special block
#+begin_box
Hello, world
#+end_box
is rewritten to the result of the call
(org-block/box ‘latex "Hello, world").
Uses of callout boxes
Such boxes often callout tips, warnings, cautionary info or emphasises core information.
﴾How It’s Implemented﴿
2. Folded Details —Let the user see stuff only if they're interested
﴾What You Write﴿
Sometimes there is a remark or a code snippet that is useful to have, but not relevant to the discussion at hand and so we want to /fold away such [[doc:org-block/details][details]]/. #+begin_details Example use cases + ‘Conversation-style’ articles, where the author asks the reader questions whose answers are “folded away” so the reader can think about the exercise before seeing the answer. + Hiding boring but important code snippets, such as a list of import declarations or a tedious implementation. #+end_details Full syntax ~#+begin_details "title" :background-color "cyan" :title-color "green"~.
﴾What You Get﴿
Sometimes there is a remark or a code snippet that is useful to
have, but not relevant to the discussion at hand and so we want to
fold away such detailsEnclose contents in a folded up box, for HTML.
For LaTeX, this is just a boring, but centered, box.
By default, the TITLE of such blocks is “Details”,
its TITLE-COLOR is green, and BACKGROUND-COLOR is “#e5f5e5”.
In HTML, we show folded, details, regions with a nice greenish colour.
Regarding the Lisp function:
+ BACKEND refers to the current export backend.
+ RAW-CONTENTS refers to the text as the user wrote it, sans its least indentation.
⇒ You may mention CONTENTS to refer to the ‘org parsed’ version of user text.
⇒ CONTENTS and RAW-CONTENTS are identical whenever key CONTENTS-OCCUR-AS-LINK-DESCRIPTION is non-nil.
For example, upon LaTeX export, the Org special block
#+begin_details
Hello, world
#+end_details
is rewritten to the result of the call
(org-block/details ‘latex "Hello, world").
Example use cases
- ‘Conversation-style’ articles, where the author asks the reader questions whose answers are “folded away” so the reader can think about the exercise before seeing the answer.
- Hiding boring but important code snippets, such as a list of import declarations or a tedious implementation.
Full syntax #+begin_details "title" :background-color "cyan" :title-color "green".
﴾How It’s Implemented﴿
Src blocks fold too: the header argument :folded t exports a src block, exactly as Org
otherwise would, inside a details block titled by its language; :folded "TITLE" picks
the title.
#+begin_src emacs-lisp :folded "How is it done?" (org-defblock details …) #+end_src
A page with many folded blocks may offer a button to unfold them all at once:
[[toggle-details:][Show me everything]] is that button; pressed again, it folds them
all. Without a description, it reads “Unfold all details”.
3. Nice Keystroke Renditions: C-h t
Anyone who writes about Emacs will likely want to mention keystrokes in an
aesthetically pleasing way, such as C-u 80 - to insert 80 dashes,
or C-c C-e h o to export an Org-mode file to HTML,
or the useful M-s h .M-s h . ∷ highlight-symbol-at-point
Highlight each instance of the symbol at point.
Uses the next face from ‘hi-lock-face-defaults’ without prompting,
unless you use a prefix argument.
Uses ‘find-tag-default-as-symbol-regexp’ to retrieve the symbol at point.
If REGEXP contains upper case characters (excluding those preceded by ‘\’)
and ‘search-upper-case’ is non-nil, the matching is case-sensitive.
This uses Font lock mode if it is enabled; otherwise it uses overlays,
in which case the highlighting will not update as you type. The Font
Lock mode is considered "enabled" in a buffer if its ‘major-mode’
causes ‘font-lock-specified-p’ to return non-nil, which means
the major mode specifies support for Font Lock.
.
kbd:𝒳will show a tooltip defining 𝒳, as an Emacs Lisp function, if possible. For example,kbd:C-h_tis C-h t; and likewise<kbd:M-s h .>is M-s h.M-s h. ∷ highlight-symbol-at-point Highlight each instance of the symbol at point. Uses the next face from ‘hi-lock-face-defaults’ without prompting, unless you use a prefix argument. Uses ‘find-tag-default-as-symbol-regexp’ to retrieve the symbol at point. If REGEXP contains upper case characters (excluding those preceded by ‘\’) and ‘search-upper-case’ is non-nil, the matching is case-sensitive. This uses Font lock mode if it is enabled; otherwise it uses overlays, in which case the highlighting will not update as you type. The Font Lock mode is considered "enabled" in a buffer if its ‘major-mode’ causes ‘font-lock-specified-p’ to return non-nil, which means the major mode specifies support for Font Lock.
(we need to use<...>since punctuation is not picked up as part of link labels). In contrast,kbd:noperenders as nope without a tooltip (nor a red border).You can also supply explicit tooltip description:
[[kbd:key sequence][description]]will show as key sequencekey sequence ∷ description
; i.e., the key sequence in nice key font along with a tooltip explaining it.- In Emacs itself, each of these displays as 〔C-x C-s〕: the
kbd:markup becomes the brackets and each_a space. Only the markup is displayed differently, so the keys stay editable as ever. Moreover, clicking one runs its keys —after asking, aselisp:links do— so readers may try them on the spot.
4. Remark —Inline footnotes, viz HTML tooltips and LaTeX notes in the margin
Sometimes you want to remark on detailsEnclose contents in a folded up box, for HTML.
For LaTeX, this is just a boring, but centered, box.
By default, the TITLE of such blocks is “Details”,
its TITLE-COLOR is green, and BACKGROUND-COLOR is “#e5f5e5”.
In HTML, we show folded, details, regions with a nice greenish colour.
Regarding the Lisp function:
+ BACKEND refers to the current export backend.
+ RAW-CONTENTS refers to the text as the user wrote it, sans its least indentation.
⇒ You may mention CONTENTS to refer to the ‘org parsed’ version of user text.
⇒ CONTENTS and RAW-CONTENTS are identical whenever key CONTENTS-OCCUR-AS-LINK-DESCRIPTION is non-nil.
For example, upon LaTeX export, the Org special block
#+begin_details
Hello, world
#+end_details
is rewritten to the result of the call
(org-block/details ‘latex "Hello, world") without drawing too much
attention, and so a tooltip via remarkFormat CONTENTS as a first-class editor comment according to BACKEND.
The CONTENTS string has an optional switch: If it contains a line
with having only ‘#+replacewith:’, then the text preceding this
clause should be replaced by the text after it; i.e., this is
what the EDITOR (the person editing) intends and so we format the
replacement instruction (to the author) as such.
In Emacs, as links, editor remarks are shown with a bold red; but
the exported COLOR of a remark is black by default and it is not
STRONG ---i.e., bold---. There is an optional SIGNOFF message
that is appended to the remark.
Remarks are hidden from the export when ‘org-hide-editor-comments’ is
non-nil. For just one file, write “#+bind: org-hide-editor-comments t”
in it; that needs ‘org-export-allow-bind-keywords’ set to t, which we
leave to you, since #+bind lets a document set any variable.
In Markdown, a remark block is GitHub’s “> [!NOTE]” alert, titled EDITOR; as a link, it stays HTML.
Regarding the Lisp function:
+ BACKEND refers to the current export backend.
+ RAW-CONTENTS refers to the text as the user wrote it, sans its least indentation.
⇒ You may mention CONTENTS to refer to the ‘org parsed’ version of user text.
⇒ CONTENTS and RAW-CONTENTS are identical whenever key CONTENTS-OCCUR-AS-LINK-DESCRIPTION is non-nil.
For example, upon LaTeX export, the Org special block
#+begin_remark
Hello, world
#+end_remark
is rewritten to the result of the call
(org-block/remark ‘latex "Hello, world") suffices.
﴾What You Write﴿
It can be annoying to make readers jump to the bottom of the page to
read a footnote. Instead, I prefer to write an /inline [[doc:org-block/tooltip][remark]]/
containing, say, references or additional explanation.
/[[tooltip:Allah][The God of Abraham; known as Elohim in the Bible]] does not burden a
soul beyond what it can bear./ --- Quran 2:286
Or, without specifying an explicit label:
/Allah[[tooltip:][The God of Abraham; known as Elohim in the Bible]] does not
burden a soul beyond what it can bear./ --- Quran 2:286 ﴾What You Get﴿
It can be annoying to make readers jump to the bottom of the page to
read a footnote. Instead, I prefer to write an inline remarkShow CONTENTS, as Org, in a tooltip on MARKER; hovered on a desktop, tapped on a phone.
In LaTeX, MARKER is followed by CONTENTS as a margin note, numbered as footnotes are, as the margin block’s are;
in beamer, whose slides have no margins, as a footnote.
Regarding the Lisp function:
+ BACKEND refers to the current export backend.
+ RAW-CONTENTS refers to the text as the user wrote it, sans its least indentation.
⇒ You may mention CONTENTS to refer to the ‘org parsed’ version of user text.
⇒ CONTENTS and RAW-CONTENTS are identical whenever key CONTENTS-OCCUR-AS-LINK-DESCRIPTION is non-nil.
For example, upon LaTeX export, the Org special block
#+begin_tooltip
Hello, world
#+end_tooltip
is rewritten to the result of the call
(org-block/tooltip ‘latex "Hello, world")
containing, say, references or additional explanation.
Allah
The God of Abraham; known as Elohim in the Bible
Or, without specifying an explicit label:
Allah°
The God of Abraham; known as Elohim in the Bible
﴾How It’s Implemented﴿
A tooltip opens when its word is hovered with a mouse, or tapped on a phone; it closes when we
leave both, tap elsewhere, or press Escape. Its text is Org, exported as Org, so it may hold
links —clickable, since moving into the tooltip keeps it open— and any other markup; an
Elisp docstring is shown just as it is written. The machinery is tooltips.js, about eighty
lines with no dependencies, in the look of tooltips.css; both are inlined into each exported
page, which so fetches nothing for them.
Org's own footnotes are such remarks too: in HTML, each footnote's number is a tooltip of its
definition, the footnotes section staying below, for print; in LaTeX, each is a margin note, as
the marginProduce an HTML tooltip or a LaTeX margin note.
The ‘margin’ block is intended for “one-off” (mostly optional) remarks.
It is essentially “inline footnotes”.
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 specific.
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 border.
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
minipage.
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’.
Regarding the Lisp function:
+ BACKEND refers to the current export backend.
+ RAW-CONTENTS refers to the text as the user wrote it, sans its least indentation.
⇒ You may mention CONTENTS to refer to the ‘org parsed’ version of user text.
⇒ CONTENTS and RAW-CONTENTS are identical whenever key CONTENTS-OCCUR-AS-LINK-DESCRIPTION is non-nil.
For example, upon LaTeX export, the Org special block
#+begin_margin
Hello, world
#+end_margin
is rewritten to the result of the call
(org-block/margin ‘latex "Hello, world") block's are, numbered as footnotes are. All three of Org's spellings serve: an
anonymous [fn::…], a named [fn:NAME] defined elsewhere, and a named inline [fn:NAME: …], which
later [fn:NAME] references share.
﴾What You Write﴿
The Quran was revealed over 23 years[fn::From 610 to 632 CE, in Mecca then Medina.], and the Torah[fn:torah] and the Gospel[fn:injil: /Injil/, given to Jesus.] are honoured in it as earlier scriptures; the Gospel[fn:injil] is named in it a dozen times. [fn:torah] /Tawrat/, given to Moses; see [[https://en.wikipedia.org/wiki/Tawrat][Tawrat]].
﴾What You Get﴿
The Quran was revealed over 23 years1From 610 to 632 CE, in Mecca then Medina., and the
Torah2
Tawrat, given to Moses; see Tawrat.
﴾How It’s Implemented﴿
5. Glossaries —Define a term once, cite it with doc:𝒳
A doc:𝒳 link shows the documentation of 𝒳 as a tooltip in HTML, and as a glossary
reference in LaTeX. Here 𝒳 is an Emacs Lisp function or variable, a word in the English
dictionary —via WordNet's wn, should we have it— or, best of all, a term of our own.
﴾What You Write﴿
The ~doc~ link type can be used to show tooltips for Emacs Lisp commands such as
doc:thread-last
However, it can also be used for your own definitions/glossary.
First define a term as follows, which does not render anything in the resulting HTML.
#+begin_documentation Category Theory :label cat
A theory of typed composition; e.g., typed monoids.
#+end_documentation
Then you can refer to it using the given :label, if any:
doc:cat
Or else refer to it with underscores in lieu of spaces:
doc:Category_Theory
Either approach renders the name of the term, not the way its referenced.
If you want to change what's rendered, provide a description:
[[doc:cat][abstract nonsense]]
Finally, if ~doc~ gets a label that is not an Emacs Lisp command, variable, nor a user-defined
definition via #+begin_documentation, then we try to look up its definition via the dictionary:
doc:happiness ﴾What You Get﴿
The doc link type can be used to show tooltips for Emacs Lisp commands such as
thread-lastThread FORMS elements as the last argument of their successor.
Example:
(thread-last
5
(+ 20)
(/ 25)
-
(+ 40))
Is equivalent to:
(+ 40 (- (/ 25 (+ 20 5))))
Note how the single ‘-’ got converted into a list before
threading.
(fn &rest FORMS)
However, it can also be used for your own definitions/glossary. First define a term as follows, which does not render anything in the resulting HTML.
Then you can refer to it using the given :label, if any:
Category Theory
A theory of typed composition; e.g., typed monoids.
Or else refer to it with underscores in lieu of spaces:
Category Theory
A theory of typed composition; e.g., typed monoids.
Either approach renders the name of the term, not the way its referenced. If you want to change what's rendered, provide a description:
abstract nonsense
A theory of typed composition; e.g., typed monoids.
Finally, if doc gets a label that is not an Emacs Lisp command, variable, nor a
user-defined
definition via #+begindocumentation, then we try to look up its definition via the
dictionary:
happinessOverview of noun happiness
The noun happiness has 2 senses (first 2 from tagged texts)
1. (4) happiness, felicity -- (state of well-being characterized by emotions ranging from contentment to intense joy)
2. (2) happiness -- (emotions experienced when in a state of well-being)
Synonyms/Hypernyms (Ordered by Estimated Frequency) of noun happiness
2 senses of happiness
Sense 1
happiness, felicity
=> emotional state, spirit
Sense 2
happiness
=> feeling
﴾How It’s Implemented﴿
Our own terms are data in an Org file: an entry is either a documentation block, which
exports nothing, or a heading tagged :documentation:, which exports as an ordinary
section. The heading's title is the term's name, its :DOC_KEYS: property lists the labels
by which we cite it, and its own text is the definition. Either way, the name with
underscores in lieu of spaces is a label too; e.g., doc:Category_Theory. Moreover,
show:GLOSSARY lists every term the page cites, wherever it sits.
﴾What You Write﴿
Our glossary, listing every term this page cites ---even those cited further below:
show:GLOSSARY
* Category Theory :documentation:
:PROPERTIES:
:DOC_KEYS: cat
:END:
A theory of typed composition; e.g., typed monoids.
* Using our terms
A glossary entry may instead be a block, which exports nothing:
#+begin_documentation Monoid :label mon
A set with an associative binary operation that has a unit.
#+end_documentation
Then, doc:cat studies [[doc:mon][monoids]] and their kin. ﴾What You Get﴿
Our glossary, listing every term this page cites —even those cited further below:
Monoid
A set with an associative binary operation that has a unit.
A theory of typed composition; e.g., typed monoids.
Category Theory  documentation
A theory of typed composition; e.g., typed monoids.
Using our terms
A glossary entry may instead be a block, which exports nothing:
Then, Category Theory
A theory of typed composition; e.g., typed monoids.
A set with an associative binary operation that has a unit.
﴾How It’s Implemented﴿
Terms we cite across many files go in a library: a list of Org files in
org-docs-libraries, whose entries —blocks and headings alike— every doc:𝒳 link may
cite. The files are read, not exported, so loading them is quick; M-x
org-docs-load-libraries reloads them after an edit, and M-x org-docs-insert inserts a
doc:𝒳 link by searching all the terms we have.
A radio target is a term too: in A <<<monoid>>> is a set with an associative operation
and a unit., the target names the term and its paragraph defines it; so doc:monoid
cites it, in the same file or, from a library, in any other.
Finally, a package's whole API makes a glossary of its own: the package-docs block
exports a table of the public functions, macros, and variables that a feature defines,
each name a doc:𝒳 link whose tooltip is its documentation.
#+begin_package-docs org-deflink #+end_package-docs
6. Parallel ---Place ideas side-by-side, possibly with a separator
﴾What You Write﴿
Reduce the amount of whitespace noise in your articles by using the [[doc:org-block/parallel][parallel]] block to place ideas side-by-side ---with up to 𝓃-many columns. ---------------------------------------------------------------------- #+begin_parallel 2 *“Soft Columns”:* Writing ~#+begin_parallel 𝓃 :bar BAR~ will produce 𝒏-many parallel columns, possibly separated by solid rules, or a “bar”. /This style allows text to freely move between columns, depending on the size of the browser, which may dynamically shrink and grow./ The value ~BAR~ can either be ~t~, ~nil~, or any (backend)-valid colour specification; such as ~red~ or ~green~. #+end_parallel ---------------------------------------------------------------------- #+begin_parallel 25% 50% 25% :bar green *“Hard Columns”:* Alternatively, /for non-uniform column widths, 𝓃 may instead be a specification of the widths of the columns./ #+columnbreak: However, this extra flexibility comes at an additional cost: The contents of the block must now contain /𝓃-1/ lines consisting of ~#+columnbreak:~, when the specification determines 𝓃-many columns. #+columnbreak: Goodbye (“God-be-with-ye”) to the right! #+end_parallel # In the Soft Columns style above, any ‘#+columnbreak:’ are merely ignored. In summary, articles can get lengthy when vertical whitespace is wasted on thin lines; instead, one could save space by using /[[doc:org-block/parallel][parallel]] columns of text/.
﴾What You Get﴿
Reduce the amount of whitespace noise in your articles by using the
parallelPlace ideas side-by-side, possibly with a separator.
There are COLS many columns, and they may be separated by solid
vertical rules if BAR is a non-nil (colour) value.
+ COLS is either a number or a sequence of the shape: 10% 20% 30%.
+ BAR is either ‘t’, ‘nil’, or a colour such as ‘red’ or ‘blue’.
----------------------------------------------------------------------
“Soft Columns”: Writing “#+begin_parallel 𝓃 :bar t” will produce
𝒏-many parallel columns, possibly separated by solid rules, or a
“bar”. This style allows text to freely move between columns,
depending on the size of the browser, which may dynamically
shrink and grow. BAR can either be ‘t’, ‘nil’, or
any (backend)-valid colour specification; such as ‘red’ or
‘green’.
“Hard Columns”: Alternatively, for non-uniform column widths,
COLS may instead be a specification of the widths of the
columns. However, this extra flexibility comes at an additional
cost: The contents of the block must now contain 𝒏-1 lines
consisting of ‘#+columnbreak:’, when the specification determines
𝒏 columns, as shown in the following example.
#+begin_parallel 20% 60% 20% :bar green
Hello, to the left!
#+columnbreak:
A super duper wide middle margin!
#+columnbreak:
Goodbye (“God-be-with-ye”) to the right!
#+end_parallel
The specification is 𝒏 measurements denoting widths; which may be
in any HTML recognisable units; e.g., “5em 20px 30%” is valid.
I personally advise only the use of percentage measurements.
In the Soft Columns style above, any ‘#+columnbreak:’ are merely ignored.
With LaTeX export, the use of ‘#+columnbreak:’ is used to request a column break.
Regarding the Lisp function:
+ BACKEND refers to the current export backend.
+ RAW-CONTENTS refers to the text as the user wrote it, sans its least indentation.
⇒ You may mention CONTENTS to refer to the ‘org parsed’ version of user text.
⇒ CONTENTS and RAW-CONTENTS are identical whenever key CONTENTS-OCCUR-AS-LINK-DESCRIPTION is non-nil.
For example, upon LaTeX export, the Org special block
#+begin_parallel
Hello, world
#+end_parallel
is rewritten to the result of the call
(org-block/parallel ‘latex "Hello, world") block to place ideas
side-by-side —with up to 𝓃-many columns.
“Soft Columns”: Writing #+begin_parallel 𝓃 :bar BAR will produce
𝒏-many parallel columns, possibly separated by solid rules, or a
“bar”. This style allows text to freely move between columns,
depending on the size of the browser, which may dynamically shrink
and grow. The value BAR can either be t, nil, or any
(backend)-valid colour specification; such as red or green.
“Hard Columns”: Alternatively, for non-uniform column widths, 𝓃 may instead be a specification of the widths of the columns.
#+columnbreak:, when the specification determines 𝓃-many columns.
In summary, articles can get lengthy when vertical whitespace is
wasted on thin lines; instead, one could save space by using
parallelPlace ideas side-by-side, possibly with a separator.
There are COLS many columns, and they may be separated by solid
vertical rules if BAR is a non-nil (colour) value.
+ COLS is either a number or a sequence of the shape: 10% 20% 30%.
+ BAR is either ‘t’, ‘nil’, or a colour such as ‘red’ or ‘blue’.
----------------------------------------------------------------------
“Soft Columns”: Writing “#+begin_parallel 𝓃 :bar t” will produce
𝒏-many parallel columns, possibly separated by solid rules, or a
“bar”. This style allows text to freely move between columns,
depending on the size of the browser, which may dynamically
shrink and grow. BAR can either be ‘t’, ‘nil’, or
any (backend)-valid colour specification; such as ‘red’ or
‘green’.
“Hard Columns”: Alternatively, for non-uniform column widths,
COLS may instead be a specification of the widths of the
columns. However, this extra flexibility comes at an additional
cost: The contents of the block must now contain 𝒏-1 lines
consisting of ‘#+columnbreak:’, when the specification determines
𝒏 columns, as shown in the following example.
#+begin_parallel 20% 60% 20% :bar green
Hello, to the left!
#+columnbreak:
A super duper wide middle margin!
#+columnbreak:
Goodbye (“God-be-with-ye”) to the right!
#+end_parallel
The specification is 𝒏 measurements denoting widths; which may be
in any HTML recognisable units; e.g., “5em 20px 30%” is valid.
I personally advise only the use of percentage measurements.
In the Soft Columns style above, any ‘#+columnbreak:’ are merely ignored.
With LaTeX export, the use of ‘#+columnbreak:’ is used to request a column break.
Regarding the Lisp function:
+ BACKEND refers to the current export backend.
+ RAW-CONTENTS refers to the text as the user wrote it, sans its least indentation.
⇒ You may mention CONTENTS to refer to the ‘org parsed’ version of user text.
⇒ CONTENTS and RAW-CONTENTS are identical whenever key CONTENTS-OCCUR-AS-LINK-DESCRIPTION is non-nil.
For example, upon LaTeX export, the Org special block
#+begin_parallel
Hello, world
#+end_parallel
is rewritten to the result of the call
(org-block/parallel ‘latex "Hello, world") columns of text.
﴾How It’s Implemented﴿
7. Aligned equations ---#+begin_align, cited by eqref:𝒳
An alignEquations aligned at each &, numbered when NUMBERED; a line may end in a coloured tag, “:tag-blue: Name”.
#+begin_align :let (-> "\\Rightarrow" == "\\equiv")
p -> q &== \neg p \lor q :tag-blue: Implication
p \land q &== p == q == p \lor q :tag-orange: Golden Rule
#+end_align
Then [[eqref:Golden Rule]] refers to the second line, as (Golden Rule) in orange; following that
link in Emacs visits the line.
+ The contents are LaTeX, not Org markup; as in LaTeX, a line sans a tag ends in \\.
+ “:tag-COLOUR: NAME” ≈ “\tag{$\color{COLOUR}{\text{NAME}}$} \label{NAME} \\”, for any xcolor COLOUR.
+ Shorthands, such as -> above, come from the :let switch, which every block has; :let NAME shares them, from
the table #+name: NAME or the variable NAME.
+ In Markdown, the equations are a fenced math block.
Regarding the Lisp function:
+ BACKEND refers to the current export backend.
+ RAW-CONTENTS refers to the text as the user wrote it, sans its least indentation.
⇒ You may mention CONTENTS to refer to the ‘org parsed’ version of user text.
⇒ CONTENTS and RAW-CONTENTS are identical whenever key CONTENTS-OCCUR-AS-LINK-DESCRIPTION is non-nil.
For example, upon LaTeX export, the Org special block
#+begin_align
Hello, world
#+end_align
is rewritten to the result of the call
(org-block/align ‘latex "Hello, world") block's contents are LaTeX, aligned at each &; as in LaTeX, a line ends in
\\, unless it ends in a tag :tag-COLOUR: NAME, which is NAME in that colour and is what
[[eqref:NAME]] cites. Following such a link in Emacs visits the line; failing that, any
\tag{…NAME…}. An align :numbered t numbers its untagged lines too. Since the contents are
LaTeX, shorthands are welcome: the :let switch gives them, as below.
﴾What You Write﴿
An ~align~ block lines equations up at each =&=; a line may end in a coloured tag, to which an =eqref:= link refers. Shorthands, such as =->= below, come from the =:let= switch every block has. #+begin_align :let (-> "\\Rightarrow" == "\\equiv") p -> q &== \neg p \lor q :tag-blue: Implication p \land q &== p == q == p \lor q :tag-orange: Golden Rule #+end_align By [[eqref:Golden Rule]], conjunction is defined by equivalence and disjunction.
﴾What You Get﴿
An align block lines equations up at each &; a line may end in a
coloured tag, to which an
eqref: link refers. Shorthands, such as -> below, come from the
:let switch every block has.
By \eqref{Golden Rule}, conjunction is defined by equivalence and disjunction.
﴾How It’s Implemented﴿
To share shorthands among many blocks, name them once, in a table that need not itself export:
#+begin_align :let logic p -> q &== \neg p \lor q #+end_align * Shorthands :noexport: #+name: logic | Variable | Value | |----------+-------------| | -> | \Rightarrow | | == | \equiv |
The rows above the rule are a header, and are skipped. A Lisp variable serves too, across
documents: (setq logic '(-> "\\Rightarrow")) and then :let logic.
8. latex-definitions for hiding LaTeX declarations in HTML
To present mathematical formulae in HTML export, we may use
LaTeX-style commands such as {\color{red} x} by enclosing them in
$-symbols to obtain \({\color{red}x}\). This is known as the MathJax
tool —Emacs' default HTML export includes it. (Unfortunately,
MathJax does not directly support arbitrary HTML elements to occur
within the $-delimiters.)
It is common to declare LaTeX definitions for convenience, but such
declarations occur within $-delimiters and thereby produce
undesirable extra whitespace. See the superflous vertical whitespace
in the Result side below.
Source
Hello, in this blog post I'd like to talk about quantifiers.
# First, I'll define some helpers that I use multiple times...
$$
\def\Plus{\color{teal}\bigoplus}
\def\plus{\;\color{teal}\oplus\;}
\def\f#1{{\color{brown}f}{\color{violet}(#1)}}
\def\xstart{\color{red} a}
\def\xend{\color{cyan} b}
$$
Anyhow, let's talk about quantifiers...
$$
\Plus_{{\color{violet} x} = \xstart}^{\xend} \f{x}
\; = \;
\f{{\xstart}} \plus \f{a+1} \plus \f{a+2} \plus \cdots \plus \f{{\xend}}
$$
The above “quantification” means [[teal:Loop sequentially with]]
[[brown:loop-bodies f(x)]] [[teal:fused using ⊕]], using [[violet:x as the
name of the current element]], [[red:starting at a]] and [[cyan:ending at b]].Result
Hello, in this blog post I'd like to talk about quantifiers.
\[ \def\Plus{\color{teal}\bigoplus} \def\plus{\;\color{teal}\oplus\;} \def\f#1{{\color{brown}f}{\color{violet}(#1)}} \def\xstart{\color{red} a} \def\xend{\color{cyan} b} \]
Anyhow, let's talk about quantifiers… \[ \Plus_{{\color{violet} x} = \xstart}^{\xend} \f{x} \; = \; \f{{\xstart}} \plus \f{a+1} \plus \f{a+2} \plus \cdots \plus \f{{\xend}} \]
The above “quantification” means Loop sequentially with loop-bodies f(x) fused using ⊕, using x as the name of the current element, starting at a and ending at b.
As such, we declare the latex-definitionsDeclare but do not display the CONTENTS according to the BACKEND.
In LaTeX, they are declarations, so they go to the preamble, as #+latex_header: lines; within a beamer frame, which
is read into a definition of its own, a macro’s #1 would otherwise be an error.
Regarding the Lisp function:
+ BACKEND refers to the current export backend.
+ RAW-CONTENTS refers to the text as the user wrote it, sans its least indentation.
⇒ You may mention CONTENTS to refer to the ‘org parsed’ version of user text.
⇒ CONTENTS and RAW-CONTENTS are identical whenever key CONTENTS-OCCUR-AS-LINK-DESCRIPTION is non-nil.
For example, upon LaTeX export, the Org special block
#+begin_latex-definitions
Hello, world
#+end_latex-definitions
is rewritten to the result of the call
(org-block/latex-definitions ‘latex "Hello, world") block type which avoids
displaying such extra whitespace in the resulting HTML.
﴾What You Write﴿
Hello, in this blog post I'd like to talk about quantifiers.
# First, I'll define some helpers that I use multiple times...
#+begin_latex-definitions
\def\Plus{\color{teal}\bigoplus}
\def\plus{\;\color{teal}\oplus\;}
\def\f#1{{\color{brown}f}{\color{violet}(#1)}}
\def\xstart{\color{red} a}
\def\xend{\color{cyan} b}
#+end_latex-definitions
Anyhow, let's talk about quantifiers...
$$
\Plus_{{\color{violet} x} = \xstart}^{\xend} \f{x}
\; = \;
\f{{\xstart}} \plus \f{a+1} \plus \f{a+2} \plus \cdots \plus \f{{\xend}}
$$
The above “quantification” means [[teal:Loop sequentially with]]
[[brown:loop-bodies f(x)]] [[teal:fused using ⊕]], using [[violet:x as the
name of the current element]], [[red:starting at a]] and [[cyan:ending at b]]. ﴾What You Get﴿
Hello, in this blog post I'd like to talk about quantifiers.
Anyhow, let's talk about quantifiers… \[ \Plus_{{\color{violet} x} = \xstart}^{\xend} \f{x} \; = \; \f{{\xstart}} \plus \f{a+1} \plus \f{a+2} \plus \cdots \plus \f{{\xend}} \]
The above “quantification” means Loop sequentially with loop-bodies f(x) fused using ⊕, using x as the name of the current element, starting at a and ending at b.
﴾How It’s Implemented﴿
9. Graphs ---Org lists, drawn by Graphviz
﴾What You Write﴿
Org lists are already trees, so the ~graph~ block draws them with Graphviz: nesting makes an edge, and a two-column table styles the item above it. #+begin_graph :file lambda-calculus.png #+graph: | rankdir | LR | #+node: | shape | box | + λ-calculus | shape | ellipse | + encodes :: Church encodings + <> Combinators + S K I + Lisp + borrows :: [[combinators]] | :edge.style | dotted | #+end_graph Press =C-c C-c= inside the block to render it to a PNG; =C-u C-c C-c= shows the dot source instead.
﴾What You Get﴿
Org lists are already trees, so the graph block draws them with Graphviz:
nesting makes an edge, and a two-column table styles the item above it.
Press C-c C-c inside the block to render it to a PNG; C-u C-c C-c shows the dot source instead.
﴾How It’s Implemented﴿
The graphRender an Org list + tables as a Graphviz dot graph.
MAIN-ARG is the graph’s title, its label.
The header’s other keys are graph attributes, such as :rankdir LR; :node.KEY and :edge.KEY set node and edge defaults;
:directed nil makes an undirected graph; :wrap N fills labels to N characters a line; :unflatten N staggers
wide rows of leaves over N ranks; and :unknown-tags random-templates gives an unknown tag a made-up template,
rather than erring. Pass :file foo.png on the
#+begin_graph line to fix the output filename; else a #+name: foo line above the block makes it foo.png, and the graph
a figure that [[foo]] reaches and #+caption: captions; otherwise the name is graph-HASH.png, HASH being that of the
dot source, so re-exporting an unchanged graph rewrites one file rather than adding another.
For HTML export: if :svg t is set, embeds an inline <svg> element (tooltips
are preserved as <title> attributes and appear on hover in browsers).
Otherwise, renders to an inline base64 PNG.
For Markdown, it writes the image file and links it, as for a named graph.
For other backends it emits a #+begin_src dot block. In HTML, a node’s [[*Section]] link leads to that section.
Within the block body:
#+graph: table ↦ global graph[ ] attributes
#+node: table ↦ default node[ ] attributes
#+edge: table ↦ default edge[ ] attributes
#+rank: n1 n2 ↦ { rank=same; n1; n2 } for nodes without a common parent; ids may be [[links]]
Under an item, #+graph:, #+node:, #+edge:, and #+rank: reach its whole subtree, as Org’s inherited properties do.
#+begin_cluster TITLE :KEY V … #+end_cluster ↦ subgraph cluster_TITLE { … }; nests, and may sit in an item
:NAME: … :END: ↦ a drawer of any name, folding such directives away
- :T: :: MEANING ↦ at the top, a legend entry: a sample of template T, captioned MEANING
A #+name: table outside any graph is a template every graph in the buffer may use; the graph’s own wins.
A section tagged :graph: exports as a graph of its text, its :PROPERTIES: drawer serving as the header line.
Each list item declares a node. Nesting encodes edges (parent → child); ordered children, 1. 2. 3., share a rank
in the order written. An item’s text may hold a <<target>>, its id; [[TARGET]] or [[TARGET][LABEL]] links, extra arcs;
and *bold*, /italic/, _underline_, +strike+, =code=, or ~pre~, which make its label an HTML-like one.
A description tag, ‘+ L :: CHILD’, labels the arc into CHILD; trailing ‘:T:’ tags splice #+name: templates;
an inline footnote, [fn::NOTE], is the node’s tooltip, as is a note: a paragraph past the item’s first, or a
#+begin_note block ---with ‘#+begin_note :edge’, the arc’s---, shown beneath the label instead under :notes inline;
a web, file, or [[*Section]] link, its URL; an [[file:IMAGE.png]], its image;
a checkbox, [X], [-], or [ ], applies the template checked, partial, or unchecked, when one exists; and a ‘\\’
breaks the label’s line ---in a table value or #+record: cell, too.
Org’s {{{macros}}} expand, by the buffer’s #+macro: lines.
A two-column inline table on a list item supplies node attributes.
| key | val | ↦ a Graphviz attribute of the node; values are quoted for you.
| :id | alias | ↦ cross-reference name for this node.
| :edge.KEY | val | ↦ attribute of the arc from the parent; a parallel arc is a second child item.
| :edge[T].KEY | val | ↦ attribute of this item’s arc to T, from a [[T]] link; "rec::port" reaches a record’s port.
| :inherit | T₁ T₂ | ↦ inherit the #+name: templates’ rows; explicit rows win. Also :edge.:inherit, and :T₁:T₂: tags:
after an item, its node’s; after a reference, or a description term, its arc’s.
A child item that is a lone [[T]] link is a reference to T: an arc to it, styled by the child’s :edge.KEY rows.
| :children-rank | same | ↦ constrain immediate children to the same rank;
also accepts min, max, source, sink.
| shape | cluster | ↦ make this node an inline subgraph cluster_ID { … }.
#+record: table ↦ the node’s <TABLE> label, as laid out: a cell’s <<p>> is port p, its [[T]] an arc from there;
^ or an empty cell spans, a <l>/<c>/<r> row aligns, and hlines rule.
Example:
#+begin_graph :rankdir LR
+ A
+ calls :: B
+ returns :: C
#+end_graph
Regarding the Lisp function:
+ BACKEND refers to the current export backend.
+ RAW-CONTENTS refers to the text as the user wrote it, sans its least indentation.
⇒ You may mention CONTENTS to refer to the ‘org parsed’ version of user text.
⇒ CONTENTS and RAW-CONTENTS are identical whenever key CONTENTS-OCCUR-AS-LINK-DESCRIPTION is non-nil.
For example, upon LaTeX export, the Org special block
#+begin_graph
Hello, world
#+end_graph
is rewritten to the result of the call
(org-block/graph ‘latex "Hello, world") block is opt-in, so we load it separately with
(require 'org-graph-block). Rendering needs the dot executable from Graphviz:
HTML export embeds a PNG —or an inline SVG, with tooltips intact, via :svg t— whereas
other backends receive the dot source. Inside the block, #+graph:, #+node: and #+edge:
tables set Graphviz's defaults; C-h o org-block/graph documents every option.
10. Switches for every block: :when, :let, :folded, …
Just as every src block understands :exports and :results, every block understands these
header arguments —ours, those made with org-defblock, Org's own src, example, quote, verse,
and center blocks, and any #+begin_𝒳 at all, no declaration needed:
| Switch | Effect upon export |
|---|---|
:noexport t |
Nothing at all; e.g., notes to self |
:when FORM |
Nothing at all, unless the Lisp FORM is non-nil; it may mention backend |
:let (VAR VAL …) |
Each whole-word VAR, or operator such as ->, in the contents becomes its value, beforehand |
:let NAME |
Likewise, for the VAR and VAL of each row of the table #+name: NAME, else of the variable NAME |
:ignore t |
The contents, as plain Org; i.e., the block's own behaviour is bypassed |
:boxed TITLE |
The result, within a boxEnclose text in a box, possibly with a TITLE.
By default, the box’s BACKGROUND-COLOR is green for HTML and red for LaTeX;
for LaTeX, there are also FRAME-COLOR and TITLE-BACKGROUND-COLOR.
SHADOW is an alternate style of boxing: It shows the contents in a centred
box with a shadow colour being the given non-nil value of SHADOW.
If SHADOW is a hexadecimal colour, it should be a string enclosed in double quotes.
More accurately, the following are all valid uses:
#+begin_box title :shadow t
#+begin_box title :shadow inset
#+begin_box title :shadow "pink"
#+begin_box title :shadow pink
#+begin_box title :shadow (cyan pink orange yellow)
#+begin_box title :shadow (cyan "inset pink" orange)
#+begin_box title :shadow (:left cyan :right pink :deep-right orange :deep-left yellow)
Notice that prefixing colours with ‘inset’ causes the colour to be within the box,
rather than spread, with blur, around the box. The use of ‘inset’ swaps left and right.
The HTML export uses a padded div, whereas the LaTeX export
requires the tcolorbox package; Markdown, sans colours, gets a quote opening with TITLE in bold.
Regarding the Lisp function:
+ BACKEND refers to the current export backend.
+ RAW-CONTENTS refers to the text as the user wrote it, sans its least indentation.
⇒ You may mention CONTENTS to refer to the ‘org parsed’ version of user text.
⇒ CONTENTS and RAW-CONTENTS are identical whenever key CONTENTS-OCCUR-AS-LINK-DESCRIPTION is non-nil.
For example, upon LaTeX export, the Org special block
#+begin_box
Hello, world
#+end_box
is rewritten to the result of the call
(org-block/box ‘latex "Hello, world") titled TITLE; t for untitled |
:folded TITLE |
The result, folded within detailsEnclose contents in a folded up box, for HTML.
For LaTeX, this is just a boring, but centered, box.
By default, the TITLE of such blocks is “Details”,
its TITLE-COLOR is green, and BACKGROUND-COLOR is “#e5f5e5”.
In HTML, we show folded, details, regions with a nice greenish colour.
Regarding the Lisp function:
+ BACKEND refers to the current export backend.
+ RAW-CONTENTS refers to the text as the user wrote it, sans its least indentation.
⇒ You may mention CONTENTS to refer to the ‘org parsed’ version of user text.
⇒ CONTENTS and RAW-CONTENTS are identical whenever key CONTENTS-OCCUR-AS-LINK-DESCRIPTION is non-nil.
For example, upon LaTeX export, the Org special block
#+begin_details
Hello, world
#+end_details
is rewritten to the result of the call
(org-block/details ‘latex "Hello, world") titled TITLE; t for the block's name |
:verbatim t |
The block as written, sans its switches, shown as Org source |
:verbatim demo |
That source beside what it exports to, as with org-demoOutput the CONTENTS of the block as both parsed Org and unparsed.
Label the source text by SOURCE and the result text by RESULT
finally, the source-result fragments can be shown in a STYLE
that is either “parallel” (default) or “sequential”.
SEP is the separator; e.g., a rule ‘<hr>’.
In Markdown, the source is a fenced org block above its result, each under its label in bold.
Regarding the Lisp function:
+ BACKEND refers to the current export backend.
+ RAW-CONTENTS refers to the text as the user wrote it, sans its least indentation.
⇒ You may mention CONTENTS to refer to the ‘org parsed’ version of user text.
⇒ CONTENTS and RAW-CONTENTS are identical whenever key CONTENTS-OCCUR-AS-LINK-DESCRIPTION is non-nil.
For example, upon LaTeX export, the Org special block
#+begin_org-demo
Hello, world
#+end_org-demo
is rewritten to the result of the call
(org-block/org-demo ‘latex "Hello, world") |
﴾What You Write﴿
#+begin_box Exercise :let (N 7) What do the first N odd numbers sum to? #+end_box #+begin_box Answer :let (N 7 SUM (* N N)) :folded "Peek at the answer" The first N odd numbers sum to N × N, which is SUM. #+end_box #+begin_remark :noexport t Ask the class for a proof by induction next week. #+end_remark #+begin_parallel :when (eq backend 'html) :boxed "On the web only" Columns suit wide screens. #+columnbreak: Print gets one column. #+end_parallel
﴾What You Get﴿
Exercise
What do the first 7 odd numbers sum to?
Peek at the answer
Answer
The first 7 odd numbers sum to 7 × 7, which is 49.
On the web only
Columns suit wide screens.
Print gets one column.
﴾How It’s Implemented﴿
A src block's :folded t is titled by its language, and its code is still exported by Org,
as ever. Switches apply before Babel runs, so a src block's :let changes the code it runs,
:noexport keeps it from running at all, and :folded folds away its results too. Other
switches then apply to a :verbatim showing; e.g., :verbatim demo :folded t folds away a
block's source and result alike.
Moreover, :C-c_C-c ACTION gives a block an action in Emacs: pressing C-c C-c within it
calls ACTION when it names a function, else evaluates it as a Lisp form; see C-c C-c for
your own blocks.
Switches are inherited as a src block's header-args are; e.g., :header-args:red: :let (N 3)
in a heading's drawer gives every red block of its subtree that :let.
A block that declares a keyword of the same name keeps it for itself; e.g., a block with
its own folded argument receives :folded as usual. Since :when, :let and :C-c_C-c
run Lisp written in the document, Emacs asks once before running each distinct form;
org-defblock-evaluate-switches may instead allow them freely, or never.
11. Callouts —Note, tip, important, warning, caution
Five blocks, after GitHub's alerts, call out a paragraph with a coloured rule down its left under a titled heading; the title defaults to the block's name.
﴾What You Write﴿
#+begin_tip =C-h k= followed by any key tells us what that key does. #+end_tip #+begin_warning Mind the gap =C-x C-c= quits Emacs, unsaved buffers and all ---it asks first, though. #+end_warning
﴾What You Get﴿
💡 Tip
C-h k followed by any key tells us what that key does.
⚠️ Mind the gap
C-x C-c quits Emacs, unsaved buffers and all —it asks first, though.
﴾How It’s Implemented﴿
The colours, icons, and intended uses live in org-callouts. Since a heading tagged
:note: is common enough to mean something else entirely, callouts claim neither tags nor
link types.
Exported to Markdown (ox-md or ox-gfm), a callout becomes GitHub's own alert,
> [!WARNING]; since alerts are untitled, a custom title becomes its bold first paragraph.
See Markdown export for what the other blocks become.
12. Colours ---red:𝒳, [[color:#ff0066][𝒳]], and #+begin_red
Each of the 19 colours that HTML and LaTeX's xcolor share —black, blue, brown, cyan, darkgray, gray,
green, lightgray, lime, magenta, olive, orange, pink, purple, red, teal, violet, white, and yellow— is a
block, a link, and a tag; color takes any other, by name or hex code. In Emacs, too, each such link
shows its text in its colour, as soon as org-special-block-extras-mode is on.
﴾What You Write﴿
#+begin_red Look at my text, it's red! #+end_red #+begin_pink Look at my text, it's pink! #+end_pink #+begin_color cyan Look at my text, it's cyan! #+end_color green:Look blue:Here orange:Buddo! [[color:#ff0066][Any hex colour]], [[color:navy][any colour's name]], and [[red:][a described red link]].
﴾What You Get﴿
Look at my text, it's red!
Look at my text, it's pink!
Look at my text, it's cyan!
Look Here Buddo!
Any hex colour, any colour's name, and a described red link.
﴾How It’s Implemented﴿
13. Quotations, cited ---#+begin_quote KEY
Org's own quote block, given a bibliography key, cites it, at its pages —the key given as the
main argument, or as :key:
#+begin_quote zermelo1908 :pages 20-22 Set theory is that branch of mathematics whose task is to investigate the fundamental notions of number, order, and function. #+end_quote
In LaTeX, and so in beamer, this is csquotes' \blockcquote[20-22]{zermelo1908}{…}, cited by
our bibliography —biblatex's \addbibresource, BibTeX's \bibliography, or org-cite—
which is ours to give; csquotes itself is loaded for us, unless we load it ourselves. In HTML, it is a <blockquote> closed by
“— zermelo1908, 20-22”; in Markdown, a quote closed likewise. A quote sans arguments is
Org's own, as ever.
The quoted text hugs its braces, \blockcquote[20-22]{zermelo1908}{Set theory …function.}, sans
the stray spaces LaTeX would read from its newlines; so does the contents of any block of ours
whose LaTeX wraps it in braces, say (format "\\textbf{%s}" contents).
As a link, a quote is inline: [[quote:zermelo1908][set theory is …]] is csquotes'
\textcquote{zermelo1908}{…}, and [[quote:][to be]] is just “to be”. A section tagged
:quote: is a quote of its text.
14. Highlights —Colour the background, not the text
Where red:𝒳 colours text, [[highlight:pink][𝒳]] colours its background; the colour
defaults to yellow, and the link shows so highlighted in Emacs too.
﴾What You Write﴿
Skimming readers see [[highlight:yellow][the one sentence that matters]], and [[highlight:pink][the one to reread]]. #+begin_highlight #e5f5e5 A whole paragraph, gently set apart. #+end_highlight
﴾What You Get﴿
Skimming readers see the one sentence that matters, and the one to reread.
A whole paragraph, gently set apart.
﴾How It’s Implemented﴿
For the reader who would rather pick the page's background colour themself,
[[palette:][Pick a background]] is a button that unfolds a palette of pale colours,
org-palette-colors; clicking one makes it the background —try it: .
15. Page-wide CSS with style
A style block is the page's CSS, taken verbatim; it exports to nothing but HTML.
#+begin_style
h2 { color: teal; }
#+end_style
16. Markdown export —What survives GitHub, and how to change it
Exporting to Markdown, with ox-md or ox-gfm, our blocks see backend as html, since md
derives from it; (org-export-markdown-p) tells the two apart. A Markdown renderer, such as
GitHub's, keeps only some HTML: it strips every style, class, <style>, and <font>, yet
keeps <details>, <kbd>, <mark>, <ins>, <abbr title>, <img>, and $$ maths.
- Work as-is
badge,melpa,kbd,details,solution,rename, andshowexport just as they do to HTML, and so render on GitHub —sans colours.- Markdown of their own
these blocks export to Markdown idioms, rather than HTML.
Block Markdown export note,tip, …GitHub's own alert, > [!TIP]; a custom title is a bold lineboxa quote, opening with its title in bold remarka > [!NOTE]alert, titled by its editorhighlight<mark>, which GitHub shows yellow, whatever the colourspoilernumbered blanks, with the answers folded away beneath tree$$…$$displays, as GitHub's maths knows no\[…\]org-demothe source as a code block, then its result doc,tooltip,kbd<abbr>with a plain-texttitle, as there is no tooltipsterlatex-definitionsnothing, lest its definitions show graphits image, written to its :file(elsegraph-HASH.png), linked- Plain HTML
- every other block emits the HTML it always does, which a given Markdown
renderer may not honour; e.g., on GitHub, colours ---
red:𝒳,#+begin_color— andparallel's columns are stripped, leaving plain, stacked text. Then there arestyle,palette,html-export-style, andtoggle-details, which are HTML-only by design: they dress the page itself, and Markdown has no say over the page.
Dislike how a block B exports to Markdown? Advise org-block/B on your own machine; its
result is Org, so the export makes of it whatever it does of any Org. By way of example,
boxes between horizontal rules:
(advice-add 'org-block/box :around
(lambda (box backend raw-contents &rest args)
"In Markdown, a box is its bold title and text, between rules; elsewhere, as before."
(if (org-export-markdown-p)
(format "-----\n*%s*\n\n%s\n-----" (car args) raw-contents)
(apply box backend raw-contents args))))
17. PDF export —The LaTeX packages our blocks need, loaded for us
Each block names the LaTeX packages it needs —a box, xcolor and tcolorbox; a cited quote,
csquotes— and a LaTeX export that uses the block, or its link, loads them just before
\begin{document}. So we declare none ourselves; a package we do load, options and all, is left be.
To see what a block needs, read the :latex-head of its definition, or evaluate
(get 'org-block/box 'org-latex-head) ⇒ ("xcolor" "tcolorbox").
A test, tests/org-pdf-export-tests.el, keeps this honest: it compiles every example of this manual to a
PDF, and to beamer slides, declaring no packages at all. It uses LuaLaTeX, which reads Unicode such
as 𝒳 and ⇒ as is; pdflatex instead needs a \newunicodechar for each such character. Slides have no
margins, so there our margin notes, tooltips, and Org's footnotes are beamer's own footnotes.
Life & Computing Science by Musa Al-hassy is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License