限制大纲条目的长度

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

我的一些人物有很长的标题,导致轮廓丑陋。

有没有办法截断

outline.entry
文本,设置文本长度的最大宽度或在 N 个字符后触发换行符,以便
outline.entry
编译为:

我检查了并设法用

show outline.entry: set box(...)
修改了部分标题之后的部分,但我不知道如何访问
BoxElem
之前的内容。

layout typst
1个回答
0
投票

您确实可以构建自己的

outline.entry
显示规则。关键成分是
clip: true
,位于
it.body
周围的盒子上:

#show outline.entry: it => {
  style(styles => {
    let line-height = 1em
    // "columns" width determines how much of the caption should show
    grid(columns: (2fr, 1fr))[
      #box(it.body, height: line-height, clip: true)
    ][
      #box(width: 1fr, it.fill)
      #box(it.page)
    ]
  })
}
#outline(target: figure)

#figure(caption: [#lorem(150)])[
  A figure
]

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