Remark.jl icon indicating copy to clipboard operation
Remark.jl copied to clipboard

Math rendering

Open dpsanders opened this issue 6 years ago • 9 comments

Very nice package, thanks!

I'm having some trouble with rendering of math -- it doesn't seem to be rendering nicely. E.g. \begin{align} blocks don't work at all. Is there some option I need to use for this?

dpsanders avatar Sep 30 '19 17:09 dpsanders

You're welcome!

There may be two separate issues. If things "look bad" it may be a problem with KaTeX fonts which is fixed on master. Just updating to Remark#master (and maybe deleting the "build" folder, to make sure things get redone properly) should fix it. I'll try to tag a release soonish.

Concerning multiline environment, see also #16. If you are using the default option of running Documenter on the output (to include julia code), your best bet is something like:

```math
\begin{aligned}
e^{i\pi} + 1 &= 0 \\\\
\sum_{n=0}^\infty \alpha^n &= \frac{1}{1-\alpha}
\end{aligned}
``` % Documenter syntax for math block

It seems weird but can be explained as follows:

  • Documenter needs to know it's a math block to not mess with it
  • Remark plus KaTeX needs \\\\ instead of \\ for escaping reasons (I may report a bug at Remark.js though, one shouldn't need to do this, maybe there is an option to fix it and as soon as I have time I can investigate)
  • the KaTeX environment is already an equation environment, so you cannot do an align block but you can do aligned.

Hope that helps, sorry if it's a bit confused!

I'll keep this issue open because, even if things stay as they are, this could be better documented.

piever avatar Sep 30 '19 20:09 piever

With master the math rendering looks great, thanks!

It would really be great to get everything working just as is. I'm using Weave syntax; it feels like between Weave.jl and Remark.jl it should be possible to automate the transformations necessary for everything to just work!

~What about inline math by the way?~ Inline math works fine, it's mainly the align blocks that are the issue now.

Thanks!

dpsanders avatar Oct 02 '19 04:10 dpsanders

In case anyone else is running into this now too, I'll add that you need to escape underscores too!

ericphanson avatar Jul 14 '20 01:07 ericphanson

I'm actually having considerable trouble with math rendering. It seems like the parsing is completely off at times. Small pieces of my expression can render correctly, but when I type the whole thing it fails.

expression:

$$W_T = \sum_{t=0}^T C_t \prod_{s=t+1}^T R_s$$

These work

$$\sum_{t=0}^T C_t$$ 

$$\prod_{s=t+1}^T R_s$$

but in combination they fail.

tbeason avatar Aug 09 '20 17:08 tbeason

Try escaping the underscores, that’s what helped for me.

ericphanson avatar Aug 09 '20 18:08 ericphanson

I did try and that did not help. I also tried putting it in a math environment.

tbeason avatar Aug 09 '20 18:08 tbeason

Ah. Update: I had missed escaping some underscores. It does work now.

This is obviously not the ideal solution though as it prevents copy-paste from LaTeX (and is prone to error I guess!).

tbeason avatar Aug 09 '20 20:08 tbeason

Having to escape underscore in LaTeX is definitely not ideal. OTOH, there is not much that can be done for that here. That is an upstream issue in Remark.js https://github.com/gnab/remark/issues/336.

piever avatar Aug 10 '20 09:08 piever

This issue doesn't seem to be properly fixed yet. Can it be solved by Julia? We have LaTeXStrings.jl, since Remark.jl can plot using Plots, could we show these math bits using Julia like that?

It would be a nice workaround for the time being.

danilo-bc avatar Nov 04 '21 18:11 danilo-bc