Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Tables/Figures/Equations etc. to be numbered in pandoc export #27

Merged
merged 8 commits into from
Jul 6, 2017
Merged

Allow Tables/Figures/Equations etc. to be numbered in pandoc export #27

merged 8 commits into from
Jul 6, 2017

Conversation

lixinchin
Copy link

Fixes #12

This works around a longstanding set of issues in pandoc, which doesn't support automatic numbering of Figures/Tables/Equations etc.

e.g.,
jgm/pandoc#2328
jgm/pandoc#615
jgm/pandoc#2851
jgm/pandoc#2077

These patches override the exporter to add appropriate numbered captions to Tables, Figures and source code Listings, as well as equation numbers to LaTeX math environments. The patches also implement correct numbered referencing when defining org-mode links to numbered items like Tables, Figures, Listings and Equations.

This functionality and behaviour should more closely mimic the standard org-mode exporters.

Lixin Chin and others added 8 commits December 9, 2016 11:39
Works around a bug in pandoc (present in at least up to and including
pandoc 1.18), where captions for Tables/Figures/Equations/etc. are not
numbered, unlike in other org-mode exporters.

This adds a function `org-pandoc-set-caption-title' to add a numbered
label (`Table %d', `Figure %d' etc.) to the caption.

Additionally, pandoc doesn't seem to pick up on #+LABEL: specifiers for
link targets to Tables/Figures/etc., so this function additionally adds
a manual target for any hyperlinks.

Overrides the table export function to add this caption processing
before sending the table to pandoc.
Overrides the exporter for standalone figures (as determined using the
same function as used in org-mode's standard html exporter) to add a
numbered label ("Figure %d:") before the caption text. This numbered
label is the same as used by org-mode's standard exporters, and will be
passed through org-mode's standard language translations.
Overrides the exporter for source code blocks to add the org-mode
standard numbered label ("Listing %d:") before any caption text. As with
the Table and Figure caption labels, this is passed through org-mode's
standard language translators to convert the label to the local language.
Overrides the exporter for LaTeX equation environments to add an
equation number to the environments that should have one. The equation
number is typeset as "(%d)", offset from the main equation by a \qquad
spacing, in a similar manner to
`pandoc-crossref' (https://github.com/lierdakil/pandoc-crossref).
When referring to a Table, Figure, Listing, Equation or other numbered
item, then the link description should contain that number.

This allows the pandoc backend to include automatically numbered
references to Figures, Tables, etc., similarly to the other standard
org-mode backends.
If the first `element' in a caption is, e.g., a latex-fragment, or bold,
or italic or similar, then simply setting the `cl-caaar' of the caption
to pre-pend a target for pandoc links doesn't work.

Instead, it's more robust to insert an entirely new element into the
`caar' of the caption that just contains the appropriate link target,
and reference name if needed.
@kawabata kawabata merged commit 7c9c5a2 into kawabata:master Jul 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Referencing figures and tables
2 participants