mathjax - 你如何在 mathjax 中将矩阵与负号对齐?

标签 mathjax

如果你只是使用这样的东西:

\(
    \left[
        \begin{matrix}
            0 &  1 & 5 & 2 \\
            1 & -7 & 1 & 0 \\
            0 &  0 & 1 & 3
        \end{matrix}
    \right]
\)

负号不对齐。

enter image description here

所以我一直在做的是通过并添加一个 \phantom{-} 来抵消差异:

\(
    \left[
        \begin{matrix}
            0 &  \phantom{-}1 & 5 & 2 \\
            1 &            -7 & 1 & 0 \\
            0 &  \phantom{-}0 & 1 & 3
        \end{matrix}
    \right]
\)

enter image description here

这适用于那一列,但现在列之间的宽度不同,除非第一列之后的每一列都至少有一个带负号的数字。所以我通过给他们一个 \phantom{-} 来解决这个问题:

\(
    \left[
        \begin{matrix}
            0 &  \phantom{-}1 & \phantom{-}5 & \phantom{-}2 \\
            1 &            -7 & \phantom{-}1 & \phantom{-}0 \\
            0 &  \phantom{-}0 & \phantom{-}1 & \phantom{-}3
        \end{matrix}
    \right]
\)

enter image description here

这在我看来是正确的,但我这样做的方式非常乏味。有更好的方法吗?

也许我应该编写自己的脚本来自动执行所有这些操作。这对我来说似乎很理想:

<matrix>
    0  1 5 2;
    1 -7 1 0;
    0  0 1 3
</matrix>

最佳答案

这可能更像您正在寻找的:

<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.3/latest.js?config=TeX-AMS_HTML"></script>

\(
\left[
    \begin{matrix}
        0 & \hfil     1 & 5 & 2 \\
        1 & \ \llap{-}7 & 1 & 0 \\
        0 & \hfil     0 & 1 & 3
    \end{matrix}
\right]
\)

关于mathjax - 你如何在 mathjax 中将矩阵与负号对齐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49343800/

相关文章:

plone - 安装快速安装程序产品时选择配置文件 (Plone 4)

Javascript - MathJax - 禁用某些表达式

accessibility - 覆盖 mathjax 可访问性蓝框功能

java - 在android中显示数学方程

css - 使用 `position` CSS 属性播放时 Mathjax 字体大小会缩小

joomla - 如何使用 mathjax 响应式制作公式

JavaScript Mathjax

javascript - XSLT 和 MathJax

reactjs - React 自动渲染 Math Latex

rstudio - 针织/ Markdown : how to render math equations in vignettes built by CRAN?