Tufte, marginnote, MathJax align #7679
-
DescriptionI'm using the Tufte-style book, and I wish to be able to put marginnotes onto equation lines in an align environment, vertically aligning to each line. If I'm only writing LaTeX then I can do something like this, but with Pandoc (targeting to MathJax + HTML and LaTeX -> PDF simultaneously) it seems to be quite hard. What I thought might be possible is, as in the title of this question, to have multiple equation(-like) environments, each corresponding to a line in the original align environment, that are still aligning to each other horizontally, but, as they're now separate environments, can be handled correctly by Pandoc and Quarto. Or perhaps is there a way to hack into MathJax's code (perhaps by a Pandoc filter) to implement something similar? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
Could you share a small self-contained "working" (reproducible) example to work with, i.e., a complete Quarto document or a Git repository? Thanks. What's the extension has to do with what you want? If you use HTML/LaTeX code, there is no obvious reason Pandoc/Quarto will complain. Take a look at the conditional contents feature in Quarto documentation. You can share a Quarto document using the following syntax, i.e., using more backticks than you have in your document (usually four ````qmd
---
title: "Reproducible Quarto Document"
format: html
---
This is a reproducible Quarto document using `format: html`.
It is written in Markdown and contains embedded R code.
When you run the code, it will produce a plot.
```{r}
plot(cars)
```
The end.
```` |
Beta Was this translation helpful? Give feedback.
-
Solve it (very ad-hoc though...)! Here are the step:
function lookupclassmath(e) {
if (e.classList.contains('math')) { return e } else { return lookupclassmath(e.parentElement) }
}
const almar = document.getElementsByClassName("almar")
const alref = document.getElementsByClassName("alref")
window.MathJax = {
startup : {
pageReady : () => {
return MathJax.startup.defaultPageReady().then(() => {
Array.from(almar).forEach((m, i) => {
const r = Array.from(alref).filter(e => e.id != '').find(e => e.id.match('\\d')[0] == m.id.match('\\d')[0])
m.style.top = (r.getBoundingClientRect().top - lookupclassmath(r).getBoundingClientRect().top) + 'px'
});
})
}
}
}
---
include-in-header:
text: |
<script src="alignmargin.js"></script>
---
<style>
.almar {
position: relative; /* or 'relative' depending on your layout */
}
</style>
\class{alref}{\cssId{alref1}{}}
[margin note]{#almar1 .aside .almar}
Note also that you will have to manually add vertical spacing inside the align environment when necessary, contrary to the LaTeX solution above. |
Beta Was this translation helpful? Give feedback.
Solve it (very ad-hoc though...)!
Here are the step:
alignmargin.js
.