How to remake this outline in Typst?

Hi!

To be honest I am really struggling to make this kind of outline in Typst:

I am sure it should be simple enough but the best I have is:

  #set heading(numbering: "1.1")

  #show outline.entry.where(
  level: 1
  ): it => {
    v(12pt, weak: true)
    strong(it)
  }

  #outline(indent: auto)
  
  = Introduction
  = Background
  == History
  == State of the Art
  = Analysis
  == Setup
  === Testing
  ==== How four looks

Which gives:

So I am missing the horizontal line below contents, same font size and colouring etc… the examples on the web are not helping me right now, hope someone here might know

Kind regards

To underline the outline’s title, you can wrap it inside a box with a bottom border like so:

#outline(
  indent: auto,
  title: box(
    stroke: (bottom: black),
    inset: (
      bottom: 0.4em,
      right: 4cm
    ),
    text(size: 1.5em)[Contents]
  )
)

Regarding the same font size and coloring, I think you might want to use a show-set rule like this:

#show outline: set text(font: "Public Sans", size: 12pt, fill: black)

EDIT: Result with both of these changes

1 Like

Thank you!

I was able to modify it enough to represent what I want and get it to work. I ended up using a context {} block, but I like your solution too.

To control the “.” spacing I did fill: box(repeat(text(fill: black, "."), gap:0.8em, justify: true))

Kind regards

note that the repeat function doesn’t align the dots below each other. If you want that, I recommend outrageous which does support that out of the box. That package is very useful in general to replicate LaTeX-style outlines.

(PS: I added outline to your post. If the outlines you’re trying to remake are LaTeX ones, consider adding latex-migration as well)

Thanks for adding that.

I did see that library and wish I could find a native way to do the “.” spread as pretty.

Unfortunately the licensing term for that package is outrageous:

Any derived work if I understand correctly must be disclosed in its full source - I am surprised if one can find it in @preview unless I have a major misunderstanding.

Kind regards

The good thing is that this particular piece of code was adapted from an MIT-licensed package: typst-plugins/outex/src/outex.typ at b13b0e1bc30beba65ff19d029e2dad61239a2819 · EpicEricEE/typst-plugins · GitHub so you can simply take that function, properly attribute it, and not bother with outrageous.

Regarding GPL – disclaimer, I’m not a lawyer – there was some discussion on Discord beginning here, in the course of which I also found the following SE post:

Regarding which I wrote

The accepted answer is of the opinion that a PDF file is considered “object code” that resulted from compiling LaTeX Typst source code, and if some of that source code is GPL, that means the whole derived work needs to be GPL licensed. Many other users agree, but the discussion under the accepted answer also has doubts that this is the correct interpretation: another interpretation is that the “compilation” is actually interpreting the source files, and the PDF is the output of the interpreted code, not a translated form of the compiled code.

I think it’s fair to say that the open source SE community (and the FSF, whose opinion is referenced by the answer) probably has a bias towards the former interpretation; I personally agree more with the latter camp (even though user PhillipPirrip is not convincing to me, Max Xiong makes a good case for that interpretation - no pun intended).

* The two discrepancies are that the post is about LaTeX, and that the code in question is a template that iiuc includes a tex file that would be changed directly; it’s not only about using a library.

– SillyFreak on Discord, 2024-06-02T16:00:00Z

So I don’t think it’s clear-cut, but I understand the hesitance.

The repeat function has in fact gained this capability in v0.12, as you can now set a gap between the repeated elements, and whether to justify them (i.e. whether the gap can be increased to completely fill the available width). If you combine this with a right-align, and a constant width of all page numbers (which is still a bit annoying to achieve), this should make the dot alignment possible.

The API and behavior should be the exact same as in the outex code piece you linked.

2 Likes