question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Execute substitution before parsing $..$ delimited LaTeX

See original GitHub issue

Is 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:

Screen Shot 2021-06-25 at 8 02 47 PM

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:open
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mmckycommented, Sep 6, 2021

@firasm Are you looking for text substitutions or values coming from code variables?

Seems like there are two layers here:

  1. myst text / substitutions
  2. variables in markdown (or nested LaTeX) coming from variables in code.

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

1reaction
choldgrafcommented, Sep 4, 2021

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to go about creating custom parser in Latex - TeX
The question is, how to go about parsing that 1:1-1:2-2:2 as a single option. In another language you could parse it by doing:...
Read more >
The stringstrings Package - CTAN
Abstract. The stringstrings package provides a large and sundry array of routines for the manipulation of strings. The routines are developed not only...
Read more >
The etoolbox Package
This command may be used as a drop-in replacement for \setlength. 2.5 Additional Document Hooks. LaTeX provides two hooks which defer the execution...
Read more >
Bash Reference Manual - GNU.org
A shell allows execution of GNU commands, both synchronously and ... As noted above, the regular expression parser will interpret any ...
Read more >
User manual - TeXstudio
TeXstudio provides general commands for translating latex. The default settings use "pdflatex" and the internal pdf viewer. Other commands and viewer can be ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found