mystmd
mystmd copied to clipboard
Improve references when exporting to PDFs
Proposal
MyST Website ouptut
Currently, it is possible to link sections and chapters in MyST websites. In the example I provided, we have a simple book structure where we defined a chapter in a folder and sections in dedicated pages. With MyST Website, we are able to link any word to
- an other section : the Asia section refers to the Asia page in the example below,
- to a numbered subsection : we linked the Jaguar displaying the section number (1 here)
- to a non-numbered subsection : for example, I linked to the Lions section using
[](#lion-section)and to the pandas one using[pandas](#panda-section).
We then generate the book using the plain_book template.
Default Latex output
The default output has several issues:
- the link between sections (different myst webpage) results in a hyperref non existing page,
- the non-numbered section have no links anymore,
I will first discuss animal coming from \href{/ch1-asia}{Asia} (go there
to have information about pandas !). We will also detail animals
from \href{/ch1-africa}{Africa}, especially Lions. We will then describe
the \href{/ch1-southamerica}{the South America region} with Jaguars
in Section~\ref{jaguar-section}.
Proposed output latex
- MyST pages could be labeled either with a default label (page name) or by a frontmatter keyword
labelfor example. - we could take benefit of the hyperref package to link section in the pdf,
I will first discuss animal coming from \href{/ch1-asia}{Asia} (go there
to have information about \hyperref[panda-section]{pandas} !). We will
also detail animals from \href{/ch1-africa}{Africa}, especially
\hyperref[lion-section]{Lions}. We will then describe the
\href{/ch1-southamerica}{the South America region} with Jaguars
in Section~\ref{jaguar-section}.
Files to repeat the example
index.md ch1_southamerica.md ch1_asia.md ch1_africa.md ch1_0intro.md
Table of content _toc.yml
format: jb-book
root: index
chapters:
- file: ch1_0intro
sections:
- file: ch1_asia
- file: ch1_africa
- file: ch1_southamerica
Note : on the ch1_africa, I did not defined the title in the front matter but in the main document in order to add a cross-reference label but the \label{label-africa} in the tex document.
---
short_title: Africa
---
(label-africa)=
# Africa
Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:
Thanks @QuantumVictor, this is also an issue for our typst export when there is a cross-reference outside of the current article (or articles) -- are you exporting a single page here, or a multi-article document?
Hi @rowanc1 , I just provided my MyST files of the example by re-editing the comment (sorry, I posted too early my issue...)