Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Katex in '.md' files #639

Open
Justaphysicsnerd opened this issue Apr 26, 2020 · 22 comments
Open

Support Katex in '.md' files #639

Justaphysicsnerd opened this issue Apr 26, 2020 · 22 comments

Comments

@Justaphysicsnerd
Copy link

Is your feature request related to a problem? Please describe.
I'm always frustrated whenever I open any markdown file, it has lot of lines written in KATEX. We all know that how complicated katex can be in its code form. So when i open my markdown files the katex is still in its code form.

Describe the solution you'd like
Improve the markdown file viewer i.e. add KATEX support to it.

Describe alternatives you've considered
If you don't want to make that permanent, maybe make plugins for KATEX, MathJAX etc.

Additional context
Please

@xupefei
Copy link
Member

xupefei commented May 1, 2020

One question since I haven’t tried to write LaTeX maths in Markdown: which of KATEX and MathJAX is more popular (and more worthy to support)?

@Justaphysicsnerd
Copy link
Author

Justaphysicsnerd commented May 2, 2020 via email

@xupefei
Copy link
Member

xupefei commented May 16, 2020

Fixed!

@Justaphysicsnerd
Copy link
Author

Justaphysicsnerd commented May 16, 2020 via email

@xupefei
Copy link
Member

xupefei commented May 16, 2020

The new version will be released very soon, and meanwhile, you can get it here: https://ci.appveyor.com/project/xupefei/quicklook/builds/32922024/artifacts

I added MathJax support. You have to connect to the Internet to see equations (MathJax must download some assets to render equations).

@Justaphysicsnerd
Copy link
Author

Justaphysicsnerd commented May 16, 2020 via email

@Justaphysicsnerd
Copy link
Author

Justaphysicsnerd commented May 17, 2020 via email

@xupefei
Copy link
Member

xupefei commented May 17, 2020

I can't see your attached image.

@xupefei xupefei reopened this May 17, 2020
@Justaphysicsnerd
Copy link
Author

Justaphysicsnerd commented May 17, 2020 via email

@xupefei
Copy link
Member

xupefei commented May 17, 2020

You should post images by using your web browser and go to github.com.

@Justaphysicsnerd
Copy link
Author

image

@Justaphysicsnerd
Copy link
Author

it doesn't work, i have installed the latest version. Sorry for the late reply

@xupefei
Copy link
Member

xupefei commented May 22, 2020

Could you upload the MD file here so I can test?

@Justaphysicsnerd
Copy link
Author

Justaphysicsnerd commented May 22, 2020

Github doesn't support uploading markdown files so i am just gonna copy the content of the file
To Convert all the indeterminate forms into the form of $\displaystyle{\frac{0}{0} \text{or} \frac{\infty}{\infty}}$
1)

$\displaystyle{ 0 * \frac{1}{0} ~~\text{or}~~ \frac{1}{\infty}*\infty }$
For example :
$\displaystyle{ \lim_{x \to \frac{\pi}{2}} \sec x (x-\frac{\pi}{2}) }$
$\displaystyle{\Rightarrow \lim_{x \to \frac{\pi}{2}} \frac{x-\frac{\pi}{2}}{\cos x} }$
$\displaystyle{\Rightarrow -\lim_{x \to \frac{\pi}{2}} \frac{(\frac{\pi}{2} - x)}{\sin(\frac{\pi}{2}-x)} }$
$\displaystyle{\Rightarrow \boxed{-1}}$
$$
\begin{cases}
\text{If the function is trignometric :} &\text{convert it in} \sin and \cos ~~\text{For example :} \boxed{\displaystyle{\lim_{x\to\frac{\pi}{2}}(\sec x - \tan x) = \lim_{x\to\frac{\pi}{2}} \frac{1-\sin x}{\cos x} = \lim_{x\to\frac{\pi}{2}} \frac{1-\sin^{2}x}{\cos x(1+\sin x)} =\lim_{x\to\frac{\pi}{2}} \frac{\cos x}{1+\sin x} = 0 }} \\
\text{For any other function :} &\begin{cases} \text{use rationalization ~For example :}\boxed{\displaystyle{\lim_{x\to\infty}(\sqrt{x^{2}-3x+2} - \sqrt{x^{2} + 4x + 2}) = \frac{-7x}{(\sqrt{x^{2}-3x+2} + \sqrt{x^{2} + 4x + 2})} = \frac{-7}{\sqrt{1-\frac{3}{x}+\frac{2}{x^2}} + \sqrt{1 +\frac{4}{x}+\frac{2}{x^{2}} }} = \frac{-7}{2} }} \\
                                               \text{put} ~x~ = \frac{1}{h}
\end{cases}
\end{cases}
$$

@Justaphysicsnerd
Copy link
Author

the function text is somehow striken out

@Justaphysicsnerd
Copy link
Author

in github

@xupefei
Copy link
Member

xupefei commented May 23, 2020

Thanks. I will test soon.

@xupefei
Copy link
Member

xupefei commented May 29, 2020

I managed to test MathJax and found it does not work in QuickLook. I don't know why this happens, since the same webpage can actually show equations in IE and I have set QL WebBrowser's compatibility version to 11.

I think this issue can't be fixed unless we replace the system WebBrowser (IE) with CefSharp (Chrome). Anyone can help here?

HTML for test: md2html.zip

@Justaphysicsnerd
Copy link
Author

Maybe try something like katex ? I am sorry if I am wrong, I am just a student.

@Chaphasilor
Copy link

Could KaTeX-support be added as well? Currently it's only partially working:


image

Source:

### Terminology

- For the training samples, each sample is assigned a class $y \in \mathcal{Y} \triangleq \{y_1, ..., y_N\}\,$
- The mean vector for a class $y_i$ is $\boldsymbol{\mu}(y=y_i) \equiv \boldsymbol{\mu}_{y_i}\,$
- The covariance matrix of class $y_i$ is denoted by $\bold{\Sigma}(y=y_i) \equiv \bold{\Sigma}_{y_i}\,$

### Quadratic Discriminant Analysis

Distinguishes between two classes by evaluating
$$
Q(\bold{x}) = \frac{1}{2} \left[ (\bold{x} - \hat{\boldsymbol{\mu}}_2)^T \hat{\bold{\Sigma}}_2^{-1} (\bold{x} - \hat{\boldsymbol{\mu}}_2) - (\bold{x} - \hat{\boldsymbol{\mu}}_1) \hat{\bold{\Sigma}}_1^{-1} (\bold{x} - \hat{\boldsymbol{\mu}}_1) \right] + \frac{1}{2}\log \left( \frac{\left| \hat{\bold{\Sigma}}_2 \right|}{\left| \hat{\bold{\Sigma}}_2 \right|} \right).
$$

- $\bold{x} \in \Reals^p$: a sample from the test data set
- $\hat{\boldsymbol{\mu}}_1, \hat{\boldsymbol{\mu}}_2 \in \Reals^p$ and $\hat{\bold{\Sigma}}_1, \hat{\bold{\Sigma}}_2 \in \Reals^{p \times p}$: location and covariance estimates given the two populations of training data

  • Inline math ($...$) isn't supported at all, neither are numbered equations ($$...$$ (1))
  • Some commands aren't supported in "display" mode ($$...$$):
    • \boldsymbol{} is working, but \bold{} isn't
    • Line breaks (\\ or \ \\) aren't working (causing things like \begin{cases} to not work either, as they require line breaks)
    • Some symbols like \infin () or \rarr () aren't working
  • Sometimes, even display mode ($$...$$) isn't working for some reason, here is an example:
    # $l_p$-periodogram PSD estimate
    
    $$
    \hat{S}_{yy}(e^{j\omega}) = \frac{N}{4} \left| \boldsymbol{\hat{\beta}}_{l_p}(\omega) \right|^2
    $$

@MrPancakes39
Copy link

@Chaphasilor I can't help much but,

Instead of using \bold:

$$
Q(\bold{x}) = \frac{1}{2} \left[ (\bold{x} - \hat{\boldsymbol{\mu}}_2)^T \hat{\bold{\Sigma}}_2^{-1} (\bold{x} - \hat{\boldsymbol{\mu}}_2) - (\bold{x} - \hat{\boldsymbol{\mu}}_1) \hat{\bold{\Sigma}}_1^{-1} (\bold{x} - \hat{\boldsymbol{\mu}}_1) \right] + \frac{1}{2}\log \left( \frac{\left| \hat{\bold{\Sigma}}_2 \right|}{\left| \hat{\bold{\Sigma}}_2 \right|} \right).
$$

Using \boldsymbol seems to work for MathJax:

$$
Q(\boldsymbol{x}) = \frac{1}{2} \left[ (\boldsymbol{x} - \hat{\boldsymbol{\mu}}_2)^T \hat{\boldsymbol{\Sigma}}_2^{-1} (\boldsymbol{x} - \hat{\boldsymbol{\mu}}_2) - (\boldsymbol{x} - \hat{\boldsymbol{\mu}}_1) \hat{\boldsymbol{\Sigma}}_1^{-1} (\boldsymbol{x} - \hat{\boldsymbol{\mu}}_1) \right] + \frac{1}{2}\log \left( \frac{\left| \hat{\boldsymbol{\Sigma}}_2 \right|}{\left| \hat{\boldsymbol{\Sigma}}_2 \right|} \right).
$$

Since QuickLook currently uses MathJax and not KaTeX

@Chaphasilor
Copy link

@MrPancakes39 yeah, I already noted that in my comment. The bahavior of \bold{} and \boldsymbol{} is slightly different however, so it isn't a drop-in replacements.
And of course, as I pointed out there are many other problems with KaTeX :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants