Execute substitution before parsing $..$ delimited LaTeX
See original GitHub issueIs your feature request related to a problem? Please describe.
I am using the JupyterBook to create an open problem bank for physics and I am wondering if it is possible for the substitution to happen before the latex processing? Would there be any problematic effects of this change?
What I would like to do is something like this:
${{ params.value }}$
but the problem with this is that the latex parsing happens before myst substitution.
Here’s the result after building the book:

The markdown code for that is in this dropdown, and in this repo.
---
substitutions:
params:
value: 23.5
---
# Substitutions in Markdown Files
## Trial 1 (ideal)
Here is a sentence that uses a subsitution value $ {{ params.value }} \textrm{mm} $ that does NOT show correctly.
## Trial 2 (workaround)
Here is a sentence that uses a subsitution value {{ params.value }} $\textrm{mm}$ that does show correctly.
## Trial 3 (Manual way ; what it should look like)
Here is a sentence that uses a substitution value $23.5$ $\textrm{mm}$ that does show perfectly.
Describe the solution you’d like
Perform the myst-substitution at an earlier step in the pipeline.
Describe alternatives you’ve considered
I have (above) but unfortunately they’re not ideal because the numbers/symbols/sentences don’t get formatted correctly. It may be possible in this case, but more generally.
Additional context
I can dig around the code and try playing with it if someone points me roughly in the right direction!
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
@firasm Are you looking for
text
substitutions orvalues
coming fromcode variables
?Seems like there are two layers here:
myst
text / substitutionsmarkdown
(or nestedLaTeX
) coming from variables incode
.If the second, which I suspect you are looking for given
params.value
, will be a way off. We just discussed this in the latest team meeting but it isn’t immediately obvious how to support this is a language agnostic way. There is some discussion about this: https://discourse.jupyter.org/t/inline-variable-insertion-in-markdown/10525/37@firasm didn’t we run into something similar to this with the markdown links? (e.g. so we couldn’t do
[text]({{ myvar }})
?). I wonder if this is the same issue as that.I think that the next steps should be to diagnose what is actually going on in the Sphinx transformation pipeline. Then we can figure out if it’s feasible to move one to the other.