Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying latex equation in gitlab wiki using the markdown editor

Tags:

I am interested in building a wiki for my scientific computing code on gitlab which needs me to write equations and render them in the wiki in gitlab.

How to do this.
I tried to paste the mathjax rendering script but it doesn't work.

Can KaTeX be used anyhow ?

$$   \partial_t \int_{\Omega} \mathbf{q} d \Omega =   \int_{\partial \Omega} \mathbf{f} (   \mathbf{q}) \cdot \mathbf{n}d \partial   \Omega - \int_{\Omega} hg \nabla z_b $$ 
like image 829
datapanda Avatar asked Feb 07 '16 22:02

datapanda


People also ask

Does GitLab support LaTeX?

GitHub supports Latex/MathJax since May 2022.

Does GitLab use markdown?

GitLab uses "GitLab Flavored Markdown" (GFM). It extends the standard Markdown in a few significant ways to add some useful functionality. It was inspired by GitHub Flavored Markdown. You can also use other rich text files in GitLab.

How do I write code in LaTeX markdown?

Markdown can be included in LaTeX documents by means of the markdown package. To use this, simply include \usepackage{markdown} in the preamble of your document.

How do I add an image to a GitLab reader?

To insert images to your markdown file, use the markup ![ ALT](/path/image.


2 Answers

GitLab supports KaTex from GitLab CE 8.15 using code backticks.

Documentation is here and the Relevant discussion are on merge request 8003.

Here is the current way to use equations in GitLab

Syntax Preview

like image 107
salmanulfarzy Avatar answered Sep 23 '22 13:09

salmanulfarzy


Update Feb. 2017: as documented in sfarzy's answer, this is now integrated (merge request 8003)


Original answer, Feb. 2016: Regarding Mathjax, there was a ticket requesting its integration in 2014 (also PR 5280)

If you have access to your own gitlab server, you could integrate Mathjax yourself (source Zhiyong Johnny Zhang)

Create the file /home/git/gitlab/app/views/layouts/_mathjax.html.haml, e.g.,

sudo -u git nano /home/git/gitlab/app/views/layouts/_mathjax.html.haml 

with the following content:

:javascript   (function() {     var ga = document.createElement('script');     ga.type = 'text/javascript';     ga.async = true;     ga.src = ('https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML');     var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);   })(); 

Then edit the file _head.html.haml and change to the following (the first line already existed and the second line was newly added:

= render 'layouts/piwik' if extra_config.has_key?('piwik_url') && extra_config.has_key?('piwik_site_id') = render 'layouts/mathjax' 

But if you want to publish it on gitlab.com, this integration is not yet active.

like image 25
VonC Avatar answered Sep 23 '22 13:09

VonC