如何在`typst`中自定义图形标题

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

我想做这样的:

    [another text rather than table 1-1] some text to display.  
    [another text rather than table 1-2] some text to display.  
    [another text rather than table 2-1] some text to display.  
    [another text rather than table 2-2] some text to display.  

最大2个深度,第一个深度对应标题编号,下一个深度对应连续数字。

请帮忙。

我尝试使用此代码,但它不起作用。

    [1-1] only numbered 1, 2, 3, ...  
    1-2] numbered like 1-2, 2-2, ... 

enter image description here(https://i.stack.imgur.com/CT7fF.png)

figure caption typst
1个回答
0
投票

免责声明:此答案仅处理“其他文本而不是表格”部分。

有多种方法可以做到这一点,可以使用表格和图像来完成:

  1. 您可以为每个实例更改此文本(在打字员中称为

    supplement
    ),例如获得
    IMAGE 1: here comes text

     #figure(
       image("image.png"),
       caption: [here comes text],
       supplement: [IMAGE],
     ) <test_img>
    

    现在您还必须通过以下方式匹配引用:

    @test_img[IMAGE]
    (这会就地覆盖文档范围的补充)

  2. 您可以将其设为文档范围的内容。以图例为例:

     #show figure: it => block(width: 100%)[#align(center)[
         #it.body
         // #it.supplement // original
         #getSupplement(it) // replacing function
         #it.counter.display(it.numbering):
         #it.caption
     ]]
    

    功能

    getSupplement()
    根据您的规则替换补充。因为您必须区分
    image
    table
    ,所以可以执行以下操作,从而可以替换其中一个:

     #let getSupplement(it) = {
         // see in "View Example": https://typst.app/docs/reference/meta/ref/#parameters-supplement
         if it.func() == figure and it.kind == table {
             [MyTable]
         } else if it.func() == figure and it.kind == image {
             [MyImage]
         } else { // keep original
             it.supplement
         }
     }
    

    这将为您的桌子制作

    MyTable 1: here comes text
    。现在,您还必须在整个文档范围内更改
    ref
    部分:

     #set ref(supplement: it => {
         getSupplement(it)
     })
    

    警告:这(要点 2)似乎覆盖了自定义设置,而自定义设置可以通过要点 1 来完成。!

  3. 更改文本的语言,以便相应地使用正确的补充,即德语(但不确定哪些语言可用):

     #set text(lang: "de")
    
© www.soinside.com 2019 - 2024. All rights reserved.