如何在Sphinx中添加乳胶物理包

2024-09-26 17:54:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我想在狮身人面像中给出一个量子公式。 乳胶代码:

\ket{\psi}=\frac{1}{\sqrt{2}}(\ket{00}+\ket{11})

它看起来像是乳胶的“物理”包装。 如何在Sphinx中添加此包

我试图通过添加两行来修改Sphinx的conf.py。但它不起作用

# -- Options for LaTeX output -------------------------------------------------
latex_engine = 'xelatex'
latex_elements = {'preamble':r'\usepackage{physics}'}

斯芬克斯的输出: The output of Sphinx

复制该问题:

我只是在conf.py和index.rst上做了非常简单的更改

conf.py:

# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
import sphinx_rtd_theme


# -- Project information -----------------------------------------------------

project = 'aaa'
copyright = 'bbb'
author = 'ccc'

# The full version, including alpha/beta/rc tags
release = '2021'


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.todo']

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []

# -- Options for LaTeX output -------------------------------------------------
latex_engine = 'xelatex'
latex_elements = {'preamble':r'\usepackage{physics}'}

# -- Options for TODO output -------------------------------------------------
todo_include_todos = True

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'


# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

index.rst:

.. toctree::
   :maxdepth: 2
   :caption: Contents:

Contents
=======================
:math:`\ket{\psi}=\frac{1}{\sqrt{2}}(\ket{00}+\ket{11})`

然后,我运行了make html,得到了以下页面: index.html


Tags: thetopathforoutputherehtmldocumentation
1条回答
网友
1楼 · 发布于 2024-09-26 17:54:08

溶液

在conf.py中添加以下行:

mathjax_path = "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"

这确保使用MathJax 3

更多详情

如果您在RST文档中使用math,并且没有在conf.py中为HTML输出指定渲染器,那么将使用MathJax

Sphinx(版本3.4.3)中^{}的默认值是https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML(MathJax 2)

使用MathJax 2,我得到了与您相同的错误输出。我在https://www.mathjax.org/#gettingstarted找到了工作URL

相关问题 更多 >

    热门问题