kisonecat / tikzjax

TikZJax is TikZ running under WebAssembly in the browser
LaTeX Project Public License v1.3c
437 stars 36 forks source link

Uppercase Math Symbols Incorrect #9

Open yrrapt opened 3 years ago

yrrapt commented 3 years ago

There seems to be an issue with uppercase math symbols. Where different symbols are rendered than are expected.

This doesn't seem to happen with the lower case variants. What could causing this and how could I fix it?

Thanks in advance

pieffebi commented 3 years ago

Hi, I think this is related to other problems with the math mode, discussed in #1 and #7. I believe the problem is ultimately in the dvi2html component. The following simple code \begin{document} $\alpha, \gamma, \Gamma, \Delta, -\Sigma$ \end{document} in the left panel of the dvi2html demo page produces image

The uppercase Greek letters and the minus sign (and other symbols) are not rendered correctly.

Apologies for the almost duplicate post. I already replied to #7, but I just noticed that yrrap's post is the most recent in the list, and thought that perhaps kisonecat is not following older issues, which date back to more than 6 months ago.

I really hope that this bug is fixed. This project is potentially awesome Many thanks to kisonecat for his work

yrrapt commented 3 years ago

@pieffebi I agree, the project is so close to being a perfect for me but with the math symbols not working correctly I can't really use it.

I tried to see if I could fix it by using the web2js to regenerate LaTeX core but could not getting it working. I'm a complete noob with modern web tools.

@kisonecat do you have any hints on how we could solve this issue?

kisonecat commented 3 years ago

Could you try https://tex.rossprogram.org/ which is using the new version of web2js and dvi2html?

As you noticed, the character encoding was definitely incorrect, but I think the new version deployed on https://tex.rossprogram.org/ has fixed this. Unfortunately I haven't ported the improvements from https://tex.rossprogram.org/ back into tikzjax yet -- this is mainly because https://tex.rossprogram.org/ actually supports \usepackage, and I'm not entirely sure how to handle that in tikzjax. (Presumably people would want to have a common preamble for the whole page? Or maybe it really should be per figure?)

pieffebi commented 3 years ago

@kisonecat First of all, thanks a lot, really, for your work and your time.

I tried https://tex.rossprogram.org/ with this MWE I had prepared for TikZJax. It seems to me that everything works fine or, at least, whatever used to go wrong now does work correctly. I'll try some more things.

Actually, when I inspect the minus sign in the rendering of https://tex.rossprogram.org/ I find an upside down exclamation mark, as I expected from my kind of handwaving arguments in this stack overflow post (I'm not really sure I understand how to read the character tables).

When you say "encoding", do you mean something like "ISO-8859-1" instead of "UTF-8"? I think I tried playing with that, and nothing seemed to cure the problem. But it was probably late at night and I might have done something wrong.

I'm not entirely sure how to handle that in tikzjax. (Presumably people would want to have a common preamble for the whole page? Or maybe it really should be per figure?)

About this... I am currently working with a friend and colleague teacher on website where students can brush on several subjects by answering multiple choice questions. We already use MathJaX for mathematical formulas. I would like to use TikZJax to draw figures "on the fly". I actually already used it in a bunch of physics problems, and I like it a lot. I was just preparing to use it systematically when I bumped in the symbol mismatch issue.

Since I need it only for the figures, I guess it would be convenient for me to declare the packages I need per individual figure. For instance, I imagine I might need circuitkz at some point, but not in every single figure (e.g. not in a mechanics problem). So it's probably a tradeoff between speed/memory and the number of loaded packages...

I hope I'm making some sense here.

Thanks again for your work! Francesco

kisonecat commented 3 years ago

There are multiple encoding issues sadly. On the TeX side, there are UTF-8 issues (since TikZJax is built on an old version of TeX which doesn't support UTF-8), but then there are problems on the dvi2html side too, with how the fonts are encoded. If you ask tex.rossprogram.org to render $-x$ do you see −x?

I think tying the packages to individual figures is better, in that it makes it easier to copy and paste from one .html file to another.

pieffebi commented 3 years ago

If you ask tex.rossprogram.org to render $-x$ do you see −x?

Yes, minus symbols do render correctly in tex.rossprogram.org. I have tried both \[-x\] and $-x$. The latter works also inside the tikzpicture environment. All the minuses that are rendered as \times in my MWE are perfectly OK in rossprogram.

project-eutopia commented 3 years ago

Here is another example (pulled from Tikz docs https://www.bu.edu/math/files/2013/08/tikzpgfmanual.pdf) that renders incorrectly:

\begin{tikzpicture}[domain=0:4]
  \draw[very thin,color=gray] (-0.1,-1.1) grid (3.9,3.9);
  \draw[->] (-0.2,0) -- (4.2,0) node[right] {$x$};
  \draw[->] (0,-1.2) -- (0,4.2) node[above] {$f(x)$};
  \draw[color=red] plot (\x,\x) node[right] {$f(x) =x$};
  \draw[color=blue] plot (\x,{sin(\x r)}) node[right] {$f(x) = \sin x$};
  \draw[color=orange] plot (\x,{0.05*exp(\x)}) node[right] {$f(x) = \frac{1}{20} \mathrm e^x$};
\end{tikzpicture}

This can be seen by pasting this content into the document section of https://people.math.osu.edu/fowler.291/latex/. There should be something like "1/20 e^x", but for some reason only the "1" renders in place, and the "20", "e", "/", and "x" are in some other random locations. Is this related, or should it be a separate issue?

pieffebi commented 2 years ago

I have just noticed something related to this. I sometimes use the demo page to check out something quickly. I noticed that in that page all greek symbols seem to go wrong, and latin symbols are not italic, as they should. In my website I use tikzjax in combination with mathjax, and things are slightly better: latin symbols are italic and a lot of greek letters display correctly. However, some things still go wrong. For instance, the math formula (-\theta\Gamma) renders as (\times\theta\Theta) with mathjax, and as (\pounds\mu\pounds) in the demo page.

I hope this helps. I am willing to try and help with this problem, but I am not sure how to go about it. Maybe, if it is not too complex, I could do something useful, if instructed on how to do that.

Thanks again for this great tool

Francesco

UlyssesZh commented 1 year ago

The symbol $\times$ is also incorrectly rendered as $\div$.