微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Sphinx Latex在数组中使用cline

如何解决Sphinx Latex在数组中使用cline

我正在使用Sphinx(v3.2.1)和Latex生成矩阵方程,我想对数组使用cline,但是它不会按预期方式呈现:

.. math::
  :label: lp

  \left[
  \begin{array}{cc|c}
    a_{11} &a_{12} &b_1 \\
    a_{21} &a_{22} &b_2 \\
    a_{31} &a_{32} &b_3 \\ \cline{1-2}
    c_{1}  &c_{2}  &d \\
  \end{array}
  \right]

渲染为

enter image description here

我的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:
# http://www.sphinx-doc.org/en/master/config

# -- 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 os
import sys

sys.path.insert(1,os.path.abspath("../../"))
from trellis import __version__  # nopep8

import sphinx_rtd_theme  # nopep8

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

project = 'foo'
copyright = 'foo'
author = 'foo'

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


# -- 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.autodoc","sphinx.ext.doctest","sphinx.ext.intersphinx","sphinx.ext.todo","sphinx.ext.coverage","sphinx.ext.ifconfig","sphinx.ext.viewcode","sphinx.ext.githubpages","sphinx.ext.autosummary","sphinx.ext.napoleon","sphinx.ext.autosectionlabel","sphinx_rtd_theme","sphinx.ext.mathjax",]

intersphinx_mapping = {
    "python": ("https://docs.python.org/3",None),'numpy': ('http://docs.scipy.org/doc/numpy','scipy': ('http://docs.scipy.org/doc/scipy/reference',}

autodoc_default_options = {
    'members': None
}

napoleon_google_docstring = False
napoleon_include_init_with_doc = True
napoleon_include_private_with_doc = True
napoleon_include_special_with_doc = True
napoleon_use_admonition_for_examples = True
napoleon_use_admonition_for_notes = True
napoleon_use_admonition_for_references = True
napoleon_use_rtype = False

latex_elements = {
    "preamble": r'''\usepackage{amsmath}'''
}

# 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 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_static_path = ['_static']

# These paths are either relative to html_static_path
# or fully qualified paths (eg. https://...)
html_css_files = ['css/custom.css']

解决方法

所以我偶然发现了这个问题,因为我有一个非常相似的问题。我不确定您是否确实设法解决了它,因为它是不久前解决的,但这是我的工作:我只是使用了 \hline 而不是 \cline。

.. math::

  \left[
  \begin{array}{cc|c}
    a_{11} &a_{12} &b_1 \\
    a_{21} &a_{22} &b_2 \\
    a_{31} &a_{32} &b_3 \\ 
    \hline
    c_{1}  &c_{2}  &d \\
  \end{array}
  \right]

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。