How do I create a blank line above a "Gentle Clues" tip?

Based on this code (thank you @bluss), I get the tip style that I want:

#import "@preview/gentle-clues:1.2.0" as gentle-clues-pkg: *
#let tip(..args, body) = gentle-clues-pkg.tip(..args, {
  set par(first-line-indent: 0pt,
  spacing: 1em,
 )
  body
})

#set par(
  first-line-indent: 1em,
  spacing: 0.65em,
  justify: true,
)

#lorem(20)

#lorem(20)

#tip(title: "my tips", icon: none)[#lorem(20)

#lorem(20)] 

However, the “tip” follows immediately on from the preceding paragraph using the spacing set for the document:

How can I create a 1em blank line between the main text and the tip?

:slight_smile:
Mark

Since content-block’s block.above is explicitly set to 0pt, I think it is safe to use block set rule:

#import "@preview/gentle-clues:1.2.0" as gentle-clues-pkg: *

#let tip(..args, body) = {
  set block(above: 1em)
  gentle-clues-pkg.tip(..args, {
    set par(first-line-indent: 0pt, spacing: 1em)
    body
  })
}

#set par(first-line-indent: 1em, spacing: 0.65em, justify: true)

#lorem(20)

#lorem(20)

#tip(title: "my tips", icon: none)[
  #lorem(20)

  #lorem(20)
]

Since header-block is the first element inside the outer block, changing its block.above won’t change anything.


But at this point you can just write

#let tip(..args) = {
  set block(above: 1em)
  set par(first-line-indent: 0pt, spacing: 1em)
  gentle-clues-pkg.tip(..args)
}

Works beautifully, thank you, though visually it turns out that 1.35em looks better.

I’m such a novice coder that I don’t know where to start for such things, and so have no idea about where or how content-block’s block.above is defined, for instance. In general, the documentation assumes more understanding than I have.

When you say, “But at this point you can just write…”, is this as a result of the launch of Typstyle 0.13.4?

:slight_smile:
Mark

1 Like

Go to Search — Typst: Universe, find the package, in the “About” section go to the linked repository and look at the code. Or locally, open cache dir and find the package. Or find it directly in packages/packages/preview at main · typst/packages · GitHub. Then navigate to what you use. I just hit gd under the tip function call in Neovim when Tinymist is running and after a few indirections I found the clue() function that has the described internal parts.

No, Typstyle can’t modify your code. There is no difference if set rules are inside the code block for tip() or outside of it, so you can move them together and by that time body just a part of ..args sink, so might as well remove it, it will still be passed as a part of ..args spread. It is probably something that comes with experience, and I definitely have plenty of it by now. I don’t even code that much in other languages as much as I use Typst. The more you see other people’s code, the more chances you will find something new, that you can use to simplify some code.