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

Is it possible to render math equations? #147

Open
adamryczkowski opened this issue Jun 28, 2023 · 2 comments
Open

Is it possible to render math equations? #147

adamryczkowski opened this issue Jun 28, 2023 · 2 comments

Comments

@adamryczkowski
Copy link

adamryczkowski commented Jun 28, 2023

How does one render math in mkdocs pdf? Is it actually supported? Here's my minimalistic attempt (after #75 ).

python -m venv venv
. venv/bin/activate
pip install mkdocs-with-pdf
mkdocs new test_math
cd test_math
echo "plugins:
  - with-pdf:
      render_js: true" >> mkdocs.yml 
echo "$$
a^2 + b^2 = c^2
$$
"" >> docs/index.html
mkdocs build

The output:

INFO     -  Cleaning site directory
INFO     -  Building documentation to directory: /home/Adama-docs/Adam/linux/tmp/mkdocs-with-pdf/samples/test_math/site
INFO     -  Number headings up to level 3.
INFO     -  Generate a table of contents up to heading level 2.
INFO     -  Generate a cover page with "default_cover.html.j2".
INFO     -  Converting <img> alignment(workaround).
INFO     -  Rendering on `Headless Chrome`(execute JS).
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
[0628/165909.566287:WARNING:sandbox_linux.cc(393)] InitializeSandbox() called with multiple threads in process gpu-process.
[0628/165909.573183:WARNING:bluez_dbus_manager.cc(247)] Floss manager not present, cannot set Floss enable/disable.
INFO     -  Rendering for PDF.
INFO     -  Output a PDF to "/home/Adama-docs/Adam/linux/tmp/mkdocs-with-pdf/samples/test_math/site/pdf/document.pdf".
INFO     -  Converting 1 articles to PDF took 0.3s
INFO     -  Documentation built in 0.29 seconds

The document.pdf is empty. Not a single character is displayed.

I use Ubuntu 22.04 64bit. Python 3.10.6.

@adamryczkowski
Copy link
Author

I've also tried adding

pip install mkdocs-material beautifulsoup4==4.9.3
echo "theme:
    name: 'material'
"" >> mkdocs.yml
mkdocs build

with the output:

INFO     -  Cleaning site directory
INFO     -  Building documentation to directory: /home/Adama-docs/Adam/linux/tmp/mkdocs-with-pdf/samples/test_math/site
INFO     -  Number headings up to level 3.
INFO     -  Generate a table of contents up to heading level 2.
INFO     -  Generate a cover page with "default_cover.html.j2".
INFO     -  Converting <img> alignment(workaround).
INFO     -  Rendering on `Headless Chrome`(execute JS).
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
[0628/170925.585340:WARNING:sandbox_linux.cc(393)] InitializeSandbox() called with multiple threads in process gpu-process.
[0628/170925.591491:WARNING:bluez_dbus_manager.cc(247)] Floss manager not present, cannot set Floss enable/disable.
INFO     -  Rendering for PDF.
INFO     -  Output a PDF to "/home/Adama-docs/Adam/linux/tmp/mkdocs-with-pdf/samples/test_math/site/pdf/document.pdf".
INFO     -  Converting 1 articles to PDF took 0.3s
INFO     -  Documentation built in 0.42 seconds

Still, the same empty document.

@akinmr
Copy link

akinmr commented Dec 29, 2023

I'm using markdown-katex for equations and it renders well in both HTML and PDF output.

mkdocs new test_math
cd test_math
echo 'markdown_extensions:
  - markdown_katex:
plugins:
  - with-pdf:' >> mkdocs.yml 
echo '```math
a^2 + b^2 = c^2
```" >> docs/index.html
mkdocs build

generates what you want.

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

No branches or pull requests

2 participants