找回密码
 快速注册
搜索
查看: 72|回复: 10

在KaTeX中可以手工调整行内多行公式的纵向对齐

[复制链接]

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2022-12-24 01:53 |阅读模式
本帖最后由 hbghlyj 于 2022-12-24 17:35 编辑

Screenshot 2022-12-23 at 17-53-05 KaTeX – The fastest math typesetting library .png 这种“手工调整”在MathJax中好像不行, 测试:
另:此时$\begin{aligned}
        f'(z)&=\frac{\partial u}{\partial x}+i\frac{\partial v}{\partial x}\\
        &=\frac{\partial v}{\partial y}+i\frac{\partial v}{\partial x}\\
        &=\frac{\partial u}{\partial x}-i\frac{\partial u}{\partial y}\\
        &=\frac{\partial v}{\partial y}-i\frac{\partial u}{\partial y}\\[-77pt]
        \end{aligned}$
在amsmath中使用[t], [b]和默认的[c]来指定纵向对齐, 见amsmath doc
Like the array environment, these -ed variants also take an optional [t], [b] or the default [c] argument to specify vertical positioning. For maximum interoperability, do not insert a space or line break before the option. See also the note on page 10 regarding page breaking within the -ed environments.

730

主题

1万

回帖

9万

积分

积分
93613
QQ

显示全部楼层

kuing 发表于 2022-12-24 02:28


你根本没认真看代码,它之所以会与首行对齐,是因为它最后用了一个  \\\\[-77pt] !!完全是手工调上去的!!

PS、昨晚说你混排风格的缺点还忘了一点:引用时根本引用不了表格里的东西,你看我这回帖,引用了个空。
回帖标题也是,一个字都引用不了。
非常讨厌。

点评

哦哦这样啊。修改了  发表于 2022-12-24 03:07

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2022-12-24 02:54
kuing 发表于 2022-12-23 19:28
你根本没认真看代码,它之所以会与首行对齐,是因为它最后用了一个  \\\\[-77pt] !!完全是手工调上去的 ...

我们可以研究一下Discuz X的引用, 使其可以引用表格里的文字
(在一般的网页设计中, 表格还挺常用的)

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2022-12-24 02:59
udn.realityripple.com/docs/Mozilla/MathML_Project/mtable
developer.mozilla.org/en-US/docs/Web/MathML/Element/mtable
补充:
MathML的<mtable>有一个align属性指定表格相对于其环境的垂直对齐方式。
Specifies the vertical alignment of the table with respect to its environment. Possible values are:

        axis (default): The vertical center of the table aligns on the environment's axis (typically the minus sign).
        baseline: The vertical center of the table aligns on the environment's baseline.
        bottom: The bottom of the table aligns on the environments baseline.
        center: See baseline.
        top: The top of the table aligns on the environments baseline.

In addition, values of the align attribute can end with a rownumber (e.g. align="center 3"). This allows you to align the specified row of the table rather than the whole table. A negative Integer value counts rows from the bottom of the table.
此外,align 属性的值可以以行号结尾(例如 align="center 3")。 这允许您对齐表格的指定行而不是整个表格。 负整数值从表底部开始计算行数。
例如align="axis 3"可以使周围的文字与第三行的轴线对齐 Screenshot 2022-12-23 at 19-02-35 mtable - MathML MDN.png

730

主题

1万

回帖

9万

积分

积分
93613
QQ

显示全部楼层

kuing 发表于 2022-12-24 17:02
其实要在首行对齐非常简单:在 begin{aligned} 后面加 [t] 即可。
  1. 另外此时$\begin{aligned}[t]
  2.         f'(z)&=\frac{\partial u}{\partial x}+i\frac{\partial v}{\partial x}\\
  3.         &=\frac{\partial v}{\partial y}+i\frac{\partial v}{\partial x}\\
  4.         &=\frac{\partial u}{\partial x}-i\frac{\partial u}{\partial y}\\
  5.         &=\frac{\partial v}{\partial y}-i\frac{\partial u}{\partial y}
  6.         \end{aligned}$
复制代码
效果:
另外此时$\begin{aligned}[t]
        f'(z)&=\frac{\partial u}{\partial x}+i\frac{\partial v}{\partial x}\\
        &=\frac{\partial v}{\partial y}+i\frac{\partial v}{\partial x}\\
        &=\frac{\partial u}{\partial x}-i\frac{\partial u}{\partial y}\\
        &=\frac{\partial v}{\partial y}-i\frac{\partial u}{\partial y}
        \end{aligned}$

除了 [t] 你猜还有啥?又会在哪对齐?

点评

[强]  发表于 2022-12-24 20:32
已放到1楼的显眼位置  发表于 2022-12-24 20:56

730

主题

1万

回帖

9万

积分

积分
93613
QQ

显示全部楼层

kuing 发表于 2022-12-24 17:35
hbghlyj 发表于 2022-12-24 03:06
请问这样为什么就会把整个表格顶上去呢, 它不是设置了最后一行的高度是-77pt吗, 我没有懂
另外, ...


他在最后放一个 -77pt 的负向距离,是想将后面三行所占的位置给抵消掉。
-77 这个数他肯定是手工不断调试了 N 次才出来的,看起来对齐,但必定不是绝对精确的。

在真 LaTeX 里用如下代码看看效果:
  1. \documentclass{article}
  2. \usepackage{amsmath}
  3. \begin{document}
  4. \fboxsep=0pt
  5. test: \fbox{$\begin{aligned}
  6.         f'(z)&=\frac{\partial u}{\partial x}+i\frac{\partial v}{\partial x}\\
  7.         &=\frac{\partial v}{\partial y}+i\frac{\partial v}{\partial x}\\
  8.         &=\frac{\partial u}{\partial x}-i\frac{\partial u}{\partial y}\\
  9.         &=\frac{\partial v}{\partial y}-i\frac{\partial u}{\partial y}\\[-77pt]
  10.         \end{aligned}$}
  11. test test test test test test test test test
  12. \end{document}
复制代码


至于在 MathJax 里为啥不行,我懒得理,与 LaTeX 的差别 MathJax 一向大于 KaTeX。

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2022-12-24 20:36
kuing 发表于 2022-12-24 10:02
其实要在首行对齐非常简单:在 begin{aligned} 后面加 [t] 即可。
效果:
另外此时$\begin{aligned}[t]


补充: Screenshot 2022-12-24 at 12-46-02 编辑 “用户 Hbghlyj” - 香蕉空间.png
KaTeX 不支持在 begin{aligned} 后面加 [t]

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2022-12-24 20:48
kuing 发表于 2022-12-23 19:28
PS、昨晚说你混排风格的缺点还忘了一点...

现在貌似除了放入[table]然后设置[td=30]之外, 就没有办法缩小图片
建议加入[attachimg=200,20]1234[/attachimg]这样的语法, 指定图片的宽高

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2022-12-24 21:57
LaTeX中如何使周围的文字与一个4行的表格的第3行的轴线对齐呢, 无需手动调整 (像4#那样)

手机版|悠闲数学娱乐论坛(第3版)

GMT+8, 2025-3-4 15:34

Powered by Discuz!

× 快速回复 返回顶部 返回列表