Skip to content

Instantly share code, notes, and snippets.

@josemazo
Last active February 21, 2023 02:09
Show Gist options
  • Save josemazo/36af7bb9c58b92c684bbd431f6c68ce9 to your computer and use it in GitHub Desktop.
Save josemazo/36af7bb9c58b92c684bbd431f6c68ce9 to your computer and use it in GitHub Desktop.
LaTeX within MkDocs

LaTeX within MkDocs

Needed Python packages:

$ pip install mkdocs python-markdown-math

mkdocs.yml file, with extra needed sections extra_javascript and markdown_extensions:

site_name: LaTeX within MkDocs
pages:
  - Home: index.md
theme: readthedocs
use_directory_urls: false
plugins:
  - search
extra_javascript:
  - https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-AMS-MML_HTMLorMML
markdown_extensions:
  - mdx_math

Example Markdown:

# MathJax Test Page

When \(a \ne 0\), there are two solutions to \(ax^2 + bx + c = 0\) and they are
$$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$

Screenshot:

screenshot

Source: StackOverflow

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