数学公式中latex的粗体问题
数学公式需要用粗体来表示向量,那么哪些用直立粗体,哪些用斜体粗体呢,其对应的latex转义符号又通常是什么呢?
在数学公式中,通常将**向量(vectors)和张量/矩阵(tensors/matrices)**表示为粗体。根据您给出的公式(这看起来像是刚体动力学中的欧拉方程),我们可以这样处理:
I
: 转动惯量张量 (Inertia tensor),应该加粗。通常用直立粗体。w
: 角速度矢量 (Angular velocity vector),应该加粗。通常用斜体粗体。r_i
: 位置矢量 (Position vector from axis to force application point),应该加粗。通常用斜体粗体。f_i
: 力矢量 (Force vector),应该加粗。通常用斜体粗体。t
(时间),n_c
(数量),i
(索引) 是标量,通常不加粗。d
是微分算子,不加粗。
在 LaTeX 中:
你需要使用 amsmath
宏包 (通常会自动加载或建议加载) 或者 bm
宏包。
\mathbf{}
: 用于直立粗体 (upright bold),适合矩阵和张量。\boldsymbol{}
: (来自amsmath
或amsbsy
) 用于斜体粗体 (italic bold),适合向量。\bm{}
: (来自bm
宏包) 是\boldsymbol{}
的更强大版本,通常效果更好,尤其是对于希腊字母。
使用 amsmath
的 \mathbf
和 \boldsymbol
:
\documentclass{article}
\usepackage{amsmath} % 或者 amsbsy\begin{document}
\[
\frac{d}{dt}(\mathbf{I}\boldsymbol{w}) = \sum_{i=1}^{n_c} \boldsymbol{r}_i \times \boldsymbol{f}_i
\]
\end{document}
如果 w
通常用 \omega
(欧米伽) 表示角速度,那么:
\documentclass{article}
\usepackage{amsmath}\begin{document}
\[
\frac{d}{dt}(\mathbf{I}\boldsymbol{\omega}) = \sum_{i=1}^{n_c} \boldsymbol{r}_i \times \boldsymbol{f}_i
\]
\end{document}
(如果你的 w
就是字母 w
而不是 \omega
,则坚持用 \boldsymbol{w}
)
使用 bm
宏包的 \bm
(推荐,效果更好,但 \mathbf{I}
仍然是矩阵的常见表示法):
\documentclass{article}
\usepackage{amsmath}
\usepackage{bm}\begin{document}
\[
\frac{d}{dt}(\mathbf{I}\bm{w}) = \sum_{i=1}^{n_c} \bm{r}_i \times \bm{f}_i
\]
或者,如果I也用bm处理(会变成粗斜体,可能不符合矩阵的习惯表示法):
\[
\frac{d}{dt}(\bm{I}\bm{w}) = \sum_{i=1}^{n_c} \bm{r}_i \times \bm{f}_i
\]
通常对于张量 I,`\mathbf{I}` (直立粗体) 是更常见的约定。
\end{document}
总结 LaTeX (推荐使用 amsmath
的方式):
\frac{d}{dt}(\mathbf{I}\boldsymbol{w}) = \sum_{i=1}^{n_c} \boldsymbol{r}_i \times \boldsymbol{f}_i
如果你的角速度用 \omega
表示:
\frac{d}{dt}(\mathbf{I}\boldsymbol{\omega}) = \sum_{i=1}^{n_c} \boldsymbol{r}_i \times \boldsymbol{f}_i
在 MathML 中:
你可以使用 mathvariant
属性:
mathvariant="bold"
对应 LaTeX 的\mathbf
(直立粗体)mathvariant="bold-italic"
对应 LaTeX 的\boldsymbol
(斜体粗体)
<math xmlns="http://www.w3.org/1998/Math/MathML"><mfrac><mi>d</mi><mrow><mi>d</mi><mi>t</mi></mrow></mfrac><mrow><mo>(</mo><mrow><mi mathvariant="bold">I</mi> <!-- Inertia Tensor --><mi mathvariant="bold-italic">w</mi> <!-- Angular velocity vector --></mrow><mo>)</mo></mrow><mo>=</mo><munderover><mo>∑</mo><mrow><mi>i</mi><mo>=</mo><mn>1</mn></mrow><msub><mi>n</mi><mi>c</mi></msub></munderover><mrow><msub><mi mathvariant="bold-italic">r</mi> <!-- Position vector --><mi>i</mi></msub><mo>×</mo><msub><mi mathvariant="bold-italic">f</mi> <!-- Force vector --><mi>i</mi></msub></mrow>
</math>
如果角速度用 ω
(希腊字母 omega):
<math xmlns="http://www.w3.org/1998/Math/MathML"><mfrac><mi>d</mi><mrow><mi>d</mi><mi>t</mi></mrow></mfrac><mrow><mo>(</mo><mrow><mi mathvariant="bold">I</mi><mi mathvariant="bold-italic">ω</mi> <!-- Angular velocity vector omega --></mrow><mo>)</mo></mrow><mo>=</mo><munderover><mo>∑</mo><mrow><mi>i</mi><mo>=</mo><mn>1</mn></mrow><msub><mi>n</mi><mi>c</mi></msub></munderover><mrow><msub><mi mathvariant="bold-italic">r</mi><mi>i</mi></msub><mo>×</mo><msub><mi mathvariant="bold-italic">f</mi><mi>i</mi></msub></mrow>
</math>
选择哪种方式取决于你将在哪里使用这个公式。如果你是在编写 LaTeX 文档,就用 LaTeX 的方法。如果你是在网页上展示数学公式并希望有良好的语义化和可访问性,MathML 是一个好选择 (通常与 MathJax 或 KaTeX 结合使用,它们可以解析 LaTeX 并渲染为 MathML 或 SVG/HTML+CSS)。