How to show math equations in general github's markdown(not github's blog)

后端 未结 10 1500
Happy的楠姐
Happy的楠姐 2020-11-29 14:36

After investigating, I\'ve found mathjax can do this. But when I write some example in my markdown file, it doesn\'t show the correct equations:

I have added this in

相关标签:
10条回答
  • 2020-11-29 15:24

    There is good solution for your problem - use TeXify github plugin (mentioned by Tom Hale answer - but I developed his answer in given link below) - more details about this github plugin and explanation why this is good approach you can find in that answer.

    0 讨论(0)
  • 2020-11-29 15:25

    It ’s 2020 now, let me summarize the progress of the mathematical formula rendering support of source code repository hosts.

    GitHub & Bitbucket

    GitHub and Bitbucket still do not support the rendering of mathematical formulas, whether it is the default delimiters or other.

    Bitbucket Cloud / BCLOUD-11192 -- Add LaTeX Support in MarkDown Documents (BB-12552)

    GitHub / markup -- Rendering math equations

    GitHub / markup -- Support latex

    GitHub Community Forum -- [FEATURE REQUEST] LaTeX Math in Markdown

    talk.commonmark.org -- Can math formula added to the markdown

    GitHub has hardly made any substantial progress in recent years.

    GitLab

    GitLab is already supported, but not the most common way. It uses its own delimiter.

    This math is inline $`a^2+b^2=c^2`$.
    
    This is on a separate line
    
    ```math
    a^2+b^2=c^2
    ```
    

    GitLab Flavored Markdown -- Math

    Who supports the universal delimiters?

    A Markdown parser used by Hugo

    Other ways to render

    • Use web api to render according to A hack for showing LaTeX formulas in GitHub markdown, you can even write jupyter notebook.

    • readme2tex

    0 讨论(0)
  • 2020-11-29 15:29

    I use the below mentioned process to convert equations to markdown. This works very well for me. Its very simple!!

    Let's say, I want to represent matrix multiplication equation

    Step 1:

    Get the script for your formulae from here - https://csrgxtu.github.io/2015/03/20/Writing-Mathematic-Fomulars-in-Markdown/

    My example: I wanted to represent Z(i,j)=X(i,k) * Y(k, j); k=1 to n into a summation formulae.



    Referencing the website, the script needed was => Z_i_j=\sum_{k=1}^{10} X_i_k * Y_k_j

    Step 2:

    Use URL encoder - https://www.urlencoder.org/ to convert the script to a valid url

    My example:

    Step 3:

    Use this website to generate the image by copy-pasting the output from Step 2 in the "eq" request parameter - http://www.sciweavers.org/tex2img.php?eq=<b><i>paste-output-here</i></b>&bc=White&fc=Black&im=jpg&fs=12&ff=arev&edit=

    - My example:
    http://www.sciweavers.org/tex2img.php?eq=Z_i_j=\sum_{k=1}^{10}%20X_i_k%20*%20Y_k_j&bc=White&fc=Black&im=jpg&fs=12&ff=arev&edit=

    Step 4:

    Reference image using markdown syntax - ![alt text](enter url here)

    - Copy this in your markdown and you are good to go:

    ![Z(i,j)=X(i,k) * Y(k, j); k=1 to n](http://www.sciweavers.org/tex2img.php?eq=Z_i_j%3D%5Csum_%7Bi%3D1%7D%5E%7B10%7D%20X_i_k%20%2A%20Y_k_j&bc=White&fc=Black&im=jpg&fs=12&ff=arev&edit=)

    Image below is the output of markdown. Hurray!!


    0 讨论(0)
  • 2020-11-29 15:31

    While GitHub won't interpret the MathJax formulas, you can automatically generate a new Markdown document with the formulae replaced by images.

    I suggest you look at the GitHub app TeXify:

    GitHub App that looks in your pushes for files with extension *.tex.md and renders it's TeX expressions as SVG images

    How it works (from the source repository):

    Whenever you push TeXify will run and seach for *.tex.md files in your last commit. For each one of those it'll run readme2tex which will take LaTeX expressions enclosed between dollar signs, convert it to plain SVG images, and then save the output into a .md extension file (That means that a file named README.tex.md will be processed and the output will be saved as README.md). After that, the output file and the new SVG images are then commited and pushed back to your repo.

    0 讨论(0)
提交回复
热议问题