Skip to content

如何避免公式、图表等块元素的下一行缩进?

如何避免公式、图表等块元素的下一行缩进?

问题

在段落中加入行间数学公式,总会在后面加入一个新段落,导致出现段落首行缩进。

typst
#lorem(10), for example,
$ integral x + y = z $
shows that the integral of $x + y$ is $z$.
Typst compiled image

我们希望在创建行间数学公式,且公式后没有空行时,不出现新段落和首行缩进。

解决办法

以下以公式为例,但方法也适用于 tight list 和 figure。

相关 issue:Paragraph should be able to contain tight lists and block-level equations · #3206

基础情况

#box() 将行间数学公式包住,且不能有空行。

typst
#set par(first-line-indent: (amount: 2em, all: true))

#lorem(10), for example,
#box[$ integral x + y = z $] 
shows that the integral of $x + y$ is $z$.

#lorem(20)
Typst compiled image

若启用两端对齐

如果你启用了justify两端对齐,那么还需在box之前人为换行,以取消box前一行的调整。

typst
#set par(justify: true, first-line-indent: (amount: 2em, all: true))

= Bad

#lorem(10), for example, 
#box[$ integral x + y = z $]
shows that the integral of $x + y$ is $z$.

= Good

#lorem(10), for example, \ 
#box[$ integral x + y = z $]
shows that the integral of $x + y$ is $z$.
Typst compiled image

若公式无编号

若公式无编号,那么还需用width: 100%指定box占满宽度。

typst
#set par(first-line-indent: (amount: 2em, all: true))

= Bad

#lorem(10), for example,
#box[$ integral x + y = z $] 
shows that the integral of $x + y$ is $z$.

= Good

#lorem(10), for example,
#box(width: 100%)[$ integral x + y = z $] 
shows that the integral of $x + y$ is $z$.
Typst compiled image
What do you think?
  • 0
  • 0
  • 0
  • 0
  • 0
  • 0
Comments
  • Latest
  • Oldest
  • Hottest
Powered by Waline v3.5.1

基于 MIT 许可发布