将 html 中四开文档的矩阵中的数字与减号对齐

问题描述 投票:0回答:2

我想在 HTML 格式的四开文档的矩阵中将数字与减号对齐,类似于以下示例:

$$\begin{bmatrix}
   3  & 4 \\
   -2 & 0 \\
   1  & 2 
\end{bmatrix}$$

一种可能的解决方案是使用

\phantom{-}
:

$$\begin{bmatrix}
   \phantom{-}3 & 4 \\
             -2 & 0 \\
   \phantom{-}1 & 2 
\end{bmatrix}$$

但是,当矩阵有很多数字时,这不是很有效。我知道在 LaTeX 中,

mathtools
包可以达到预期的结果:

\documentclass{article}
\usepackage{mathtools}

\begin{document}

\[
\begin{bmatrix*}[r]
 3  & 4 \\
 -2 & 0 \\
 1  & 2 
\end{bmatrix*}
\]

\end{document}

是否可以在 Quarto HTML 文档中使用

mathtools
LaTeX 包?或者,如果没有,是否还有
mathtools
的其他替代方案可供考虑,请记住 Quarto 使用 MathJax 来渲染方程?

mathjax quarto
2个回答
0
投票

您期待这个输出吗? (四开版 v.1.3.433)

---
format: html
---

$$\begin{bmatrix}
   3  & 4 \\
   -2 & 0 \\
   1  & 2 
\end{bmatrix}$$

您可以使用 YAML 中的

html-math-method
参数定义不同的数学渲染方法。


0
投票

加载数学工具.html

<script>
  window.MathJax = {
      loader: {load: ['[tex]/mathtools']},
      tex: {packages: {'[+]': ['mathtools']}}
  };
</script>
---
title: "mathtools in html"
format: html
# include-in-header: load-mathtools.html
--- 

## Quarto

$$
\begin{bmatrix*}[r]
   3  & 4 \\
   -2 & 0 \\
   1  & 2 
\end{bmatrix*}
$$

© www.soinside.com 2019 - 2024. All rights reserved.