Linking to PDF files from markdown in JB 2
Hello,
I'm excited to migrate to Jupyter Book 2! I just have one question I'm struggling with, which is how assets (PDF files mainly) are treated in JB2 compared to JB1.
I have a folder structure that looks something like this:
├── files
│ ├── Lecture10A-DataMining1.pdf
│ ├── Lecture10B-DataMining2.pdf
│ ├── Lecture10C-DataMining3.pdf
├── myst.yml
├── notes
│ ├── week02
│ │ ├── class2A.md
│ │ ├── class2B.md
my (new) toc.yml file looks something like:
- file: notes/week02/week02_summary.md
title: Week 2 - Algorithms
children:
- file: notes/week02/class2A.md
- file: notes/week02/class2B.md
In JB1, I could do something like this in my markdown files:
# Class Meeting 2A
Below are the slides from today's class embedded.
<div>
<iframe src="../../Lecture2A-Algorithms1_updated.pdf" width="100%" height="600px" frameBorder="0"> </iframe>
</div>
<a href="../../Lecture2A-Algorithms1_updated.pdf">Download the Slides from today></a>.
What is the recommended way of doing something similar in JB2 ? The same code above in JB2 doesn't correctly embed or link to the file correctly:
I have a feeling it's got something to do with the path I'm providing (though, I'm not sure). I also discovered I have this config in my JB1:
sphinx:
config:
html_show_copyright: false
html_extra_path: ['files']
Any ideas on how to get the same/similar behaviour in JB2?
Do you really want to embed them? Or create a download for specific pdf's on a page? For instance, i created a pdf download button in this book: https://freekpols.github.io/Mechanica/content/credits/ and per page you can also specify the download files using the frontmatter of that page.
Cool ! That's useful, but my files are actually PDFs of PowerPoint slides, I do both embed the files and have a link to download the files directly.
One day I will convert those slides to markdown version, but that day is not here yet unfortunately, so I do really want to embed them (vs. exporting them).
So the expected behaviour would be that the pdf is embedded in an iframe and scrollable on the specific page? (Next to the option to download...)
Not sure whether the include directive would work: https://mystmd.org/guide/embed
Note that mathpix can do the trick for you, converting the pdf / slides to md content.
Ah, I should have included what I was trying to achieve - here's a link to a live book (on JB1)
and a picture:
I will try the embed directive!
Or the iframe directive. Not behind to computer to find out. In jb1 book the pdf is not displaying on my mobile. Let me know when you have found a solution or you want me to try something.
Ok, I got something working:
Note that the iframe directive also works:
So it works, most difficult was locating the pdf file!
Ahh I tried that but of course it didn't work because I wasn't using the right file name.
I guess for now the only way to do this with sending human readable file names is to manually move the PDF files to the right location (basically reproducing the behaviour of the extra files configuration in JB1).