找回密码
 快速注册
搜索
楼主: kuing

本论坛的 $\mathrm\LaTeX$ 公式的基本输入[2021-9-26更新]

[复制链接]

3149

主题

8386

回帖

6万

积分

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

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2022-7-18 08:31
More Math Into LaTeX C.2.2 Typesetting (top of page 507)
LaTeX reads the source file one line at a time. It converts the characters of each line into a token sequence. A token is either a character—together with an indication of what role the character plays—or a command. The argument of a command is the token following it unless a group enclosed in braces follows it, in which case the contents of the group becomes the argument.

An example of this behavior can be seen when you specify an exponent. LaTeX looks for the next token as the exponent unless a group enclosed in braces follows the ^ symbol. This explains why \$2^3\$ and \$2^\alpha\$ work, but \$2^\mathfrak{m}\$ does not. Indeed, 3 and \alpha each become a single token but \mathfrak{m} becomes more than one, four, in fact. Of course, if you always use braces, as in
\$2^{3}\$, \$2^{\alpha}\$, \$2^{\mathfrak{m}}\$
then you never have to think about tokens to type such expressions.

3149

主题

8386

回帖

6万

积分

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

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2022-10-6 19:12
MathJax v4.0.0-alpha.1 has pre-released
github.com/mathjax/MathJax-src/releases
This is the first alpha release of a major update to MathJax, adding a number of new features and enhancements. As this includes significant changes that involve potentially breaking changes, in order to not have these changes affect existing web sites, this release increments the major version number so that sites using the mathjax@3 URLs will be protected from these changes until they update to version 4 explicitly. That is, this new release is an opt-in update.

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

 楼主| kuing 发表于 2022-10-8 03:08
hbghlyj 发表于 2022-10-6 19:12
MathJax v4.0.0-alpha.1 has pre-released
https://github.com/mathjax/MathJax-src/releases
Thi ...

看到了期待已久的“Line-breaking Support”😃

3149

主题

8386

回帖

6万

积分

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

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2022-10-10 02:49
kuing 发表于 2013-6-13 17:11
...
中文尽量放公式外,若必须放入公式内,请用 \text{中文} 来输入。

补充:
尽管显示效果一样(MathJax ≥ v3.2), 但是生成的MathML不同: 第一个是<mtext>, 第二个是两个<mi>.
  1. $$a+\text{中文}+a$$
  2. $$a+中文+a$$
复制代码

$$a+\text{中文}+a$$
$$a+中文+a$$

Font is italic for unicode text
Chinese should be convert to <mi> not <mo>
output of expression (with unicode chars) overlaps with following text

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

 楼主| kuing 发表于 2022-10-10 04:59
hbghlyj 发表于 2022-10-10 02:49
补充:
尽管显示效果一样(MathJax ≥ v3.2), 但是生成的MathML不同: 第一个是, 第二个是两个.

在别的页面效果就不一定相同了,比如我自个用的本地草稿本里后者的中文就会变成斜体。
为什么论坛上效果会一样,我不清楚。

3149

主题

8386

回帖

6万

积分

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

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2022-10-10 20:21
kuing 发表于 2022-10-9 21:59
在别的页面效果就不一定相同了,比如我自个用的本地草稿本里后者的中文就会变成斜体。
为什么论坛上效果 ...
可能是本地草稿本MathJax不是latest version?

论坛上version: "3.2.2"直体.
demo version: "3.2.2"直体.
在Github上version: "3.2.0"斜体,见Font is italic for unicode text

3149

主题

8386

回帖

6万

积分

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

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2022-10-10 20:26
kuing 发表于 2022-10-9 21:59
在别的页面效果就不一定相同了,比如我自个用的本地草稿本里后者的中文就会变成斜体。
为什么论坛上效果 ...

找到了 Add ability for TeX input to force normal variant for CJK input.
是3.2.1版本

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

 楼主| kuing 发表于 2022-10-10 20:47
hbghlyj 发表于 2022-10-10 20:21
可能是本地草稿本MathJax不是latest version?

论坛上version: "3.2.2"直体.

圆奶乳齿,我本地草稿本是用之前下载下来的 mathjax,这样不依赖网络,看了下确实是 3.2.0 版本。

3149

主题

8386

回帖

6万

积分

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

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2022-10-22 22:13
双竖线的四种输入方法:
\|


\Vert

\begin{gathered}\|\\
∥\\
‖\\
\Vert\\
\end{gathered}

3149

主题

8386

回帖

6万

积分

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

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2022-10-25 22:29

补充

kuing 发表于 2013-6-13 17:08
环境

环境是指 \begin{...} ... \end{...} 这样的代码,环境在真 LaTeX 中不一定要用来打公式,但这里我们 ...

\tag* 可以加不带括号的标签
  1. $$1\tag*{1}$$
复制代码

$$1\tag*{1}$$
竖直虚线分隔 :
水平虚线分隔 \hdashline
\begin{array}{c:cc}1&1&1\\\hdashline1&1&1\\1&1&1\end{array}

3149

主题

8386

回帖

6万

积分

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

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2022-10-25 22:32
运算符:
  1. \DeclareMathOperator{Si}
  2. \DeclareMathOperator*{min}
复制代码

加星号生成<mo>就可以在displaystyle把上/下标显示正上/下方

分式:
  1. a+1 \above 1pt b
  2. a+1 \atop b
  3. a+1 \over b
  4. \genfrac(]{0pt}{2}{a+b}{c+d}
复制代码


  1. \mathop \mathbin \mathrel \mathpunct
复制代码

forces the argument to be treated in the 'operator/binary/relation/punctuation' class.

文字:
  1. \mbox{text}
  2. \text{text}
  3. \framebox[width][position]{text}
  4. \mathmakebox[width][position]{text}
复制代码

3149

主题

8386

回帖

6万

积分

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

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2022-12-28 06:57

中文语境添加LaTeX分隔符

按下面的规则,在中文语境应该能匹配大多数公式(可根据个人习惯修改)
  • 由,号-号_号\号(){}[]号和除了汉字或标点(^号在Unicode里不属于标点而_号\号属于)的任意字符组成
  • 首末不是,号和空白
  • 单独一个字母是公式, 多个字母不是公式(外文单词)

写成JS
  1. function add$(teststring){
  2. return teststring.replace(/(-|\(|\)|\{|\}|\[|\]|_|\\|,|[^\p{P}\p{sc=Han}])+/gu,match=>{
  3.   if(/^\p{L}$/u.test(match))return '$'+match+'$';
  4.   if(match.length==1||/^[\s|\p{L}]+$/u.test(match))return match;
  5.   return match.replace(/^(\s*)(\S*)(\s*)$/,(m,p1,p2,p3)=>p1+p2.replace(/^(,?)(.*?)(,?)$/,'$1$$$2$$$3')+p3)})
  6. }
复制代码

例1
  1. add$(String.raw`公式可含,号,如 1,2,\cdots,n,上标 11^2,a的11倍是11a.如 1+1=2, 保留首末逗号与空白.`)
复制代码
输出
  1. 公式可含,号,如 $1,2,\cdots,n$,上标 $11^2$,$a$的$11$倍是$11a$.如 $1+1=2$, 保留首末逗号与空白.
复制代码

例2
  1. add$(String.raw`曲线\Gamma当t\in\mathbb{(-2\pi,2\pi)}的Wolfram Mathematica绘图代码:`)
复制代码

输出
  1. 曲线$\Gamma$当$t\in\mathbb{(-2\pi,2\pi)}$的Wolfram Mathematica绘图代码:
复制代码

3149

主题

8386

回帖

6万

积分

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

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2023-1-17 08:30

如何在标签使用 ′ 号

\tag是文本模式, 像\text里面一样
如果写成\tag{1'}就会显示为右单引号(又见55#)\[\tag{1'}\]
如果用&prime;符号写成\tag{1′}就会显示为\[\tag{1′}\]这是因为MathML pseudoscript把撇号&prime;双撇号&Prime;等降低
只好在\tag里面嵌套一个数学环境, 写成\tag{$1'$}\[\tag{$1'$}\]

3149

主题

8386

回帖

6万

积分

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

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2023-1-17 08:37
星号&ast; 即* 在数学模式下, 变成降低的星号&lowast; 即∗
关于连续*号之间的空白:
1$*$1
1$**$1
1$***$1
1$****$1
1$*****$1
1$******$1
1$*******$1
1$********$1
对于连续1个或2个星号, 没有空白
对于连续2n-1(n≥2)个星号, 全都有空白
对于连续2n(n≥2)个星号, 前2n-1个之间有空白

3149

主题

8386

回帖

6万

积分

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

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2023-1-17 08:56
三个比较像的字符
&apos;是ascii中的撇号(apostrophe)用于英语的缩写词、名词所有格、复数
&rsquo;是右单引号
&prime;是数学中的撇号
在数学模式下MathJax把&apos;替换为&prime;
右单引号在英语中也用作撇号,见HTML entity usage notes
The single close quote character is also used in English as the apostrophe.

三个比较像的字符
-是ascii中的连字号(hyphen)
−是减号&minus;
–是连接号&endash;
在数学模式下MathJax把-替换为减号&minus;
HTML entity usage notes
The en dash is used between two quantities or dates to suggest a range, and is indistinguishable from a proper minus sign (&minus;/&#8722;). However, it should always be distinguished from a hyphen (&#45;), which is used to separate the parts of an ad hoc compound word.

因为ascii中的字符容易用键盘输入

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

 楼主| kuing 发表于 2023-2-26 23:36
hbghlyj 发表于 2023-2-26 19:52
\abs宽度不足, 箭头突出了一段


是 mathjax 3 的 \overrightarrow 的问题,对比:
$iii$ vs $i\overrightarrow{i}i$
得到
$iii$ vs $i\overrightarrow{i}i$
可以看到现在的 \overrightarrow 纯粹就加箭头而完全没考虑箭头自身的宽度。
我记得 mathjax 2.7 是没这问题的。

更奇的是,刚刚发现,左箭头以及双向箭头竟然都是正常的!
$i\overleftarrow{i}i$ and $i\overleftrightarrow{i}i$
得到
$i\overleftarrow{i}i$ and $i\overleftrightarrow{i}i$

3149

主题

8386

回帖

6万

积分

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

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2023-3-9 21:35
kuing 发表于 2023-2-26 16:36
是 mathjax 3 的 \overrightarrow 的问题,对比:

得到

dpvc commented Mar 8, 2023

Thanks for the report. I will look into the issue (there is a related issue that I'm already working on).

3149

主题

8386

回帖

6万

积分

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

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2023-3-14 02:09

互链

上下标:$x^n$, $x^{123}$, $x_n$, $x_{123}$, $C_n^m$, $C_{100}^{50}$        x^n, x^{123}, x_n, x_{123}, C_n^m, C_{100}^{50}

1#的表格在一个CSDN博客列为参考资料
最开始使用的话,会显得比较慢,习惯就好了. 其实,最主要的还是要熟悉常见的LaTex代码,给大家推荐一个我最开始学习LaTex的Kuing论坛去发帖子,很快就会学会基本的数学公式. 这些会了,在其它支持LaTex都可以轻松发帖.

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

 楼主| kuing 发表于 2023-3-14 02:35
hbghlyj 发表于 2023-3-14 02:09
1#的表格在一个CSDN博客列为参考资料

页面有点乱……
N年前的了,看链接里最后的论坛地址,那时我的论坛还是 5d6d 的。
最初的表格,比较简洁,没那么多细节废话。

3149

主题

8386

回帖

6万

积分

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

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2024-8-22 16:45
‚ 和 , 在很多字体下难以区分。STFANGSONG 仿宋
‚ 和 , 在很多字体下难以区分。STKAITI 楷体
‚ 和 , 在很多字体下难以区分。STSONG 宋体
‚ 和 , 在很多字体下难以区分。msyh 微软雅黑

前者是low-9 quotation mark 它们不同。
Screenshot 2024-08-22 at 16-56-44 本论坛的 $_mathrm_LaTeX$ 公式的基本输入 2021-9.png
但在MathJax 中有区別:
$\text{Test ‚}$
$\text{Test ,}$
不知为什么……

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

GMT+8, 2025-3-4 07:06

Powered by Discuz!

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