How to balance columns?

noob question:

I’m trying to create a document (my CV) having some sections in 2-column mode, and others in 1-column. My issue is that I don’t know how to control the behaviour of the columns function to balance the content, so it is not “vertically justified” (if that’s a thing).

Please ignore the ghastly styling, which I’m still learning how to control right now. I’m getting the following difference between my old LaTeX-based resume, and my new Typst one:

This is what I got by default from LaTeX:

The Typst source uses a couple of functions to create a 2-col section:

#let interlude_section(title, content) = {[
= #smallcaps[#title]
#columns(2)[#content]
]}

#let interlude(title, orgname, location, dates, summary) = {
	[
	== #text(blue)[#title]
	#emph([#orgname #location #dates])\
	#par(justify: true)[#summary]
	]
}

Hey @Andrew_Matthews, welcome to the forum! I’ve changed your question post’s title to better fit our guidelines: How to post in the Questions category

For future posts, make sure your title is a question you’d ask to a friend about Typst. :wink:

1 Like

There is an open issue requesting this feature: Balancing the contents of multiple columns to the same vertical space · Issue #466 · typst/typst · GitHub

As well as a draft pull request with a WIP implementation of it: Column balancing by Caellian · Pull Request #5115 · typst/typst · GitHub

So, for the moment, you can’t do this automatically.

Your best bet for now, at least unless someone has a more sophisticated workaround, will be manual adjustment of the columns height:

Example:
#block(height: 4cm, columns(2, lorem(60)))

More sample text

Thanks. That makes sense. When is that WIP expected to be released?

(Since I’m asking anyway) Is there currently support for keeping all elements of a block together (i.e. like the title and summary of a job, so that the whole thing overflows from one col to another if it doesn’t fit).

Are there alternate ways to tackle the issue? For example, with Typst, is it possible to implement the equivalent of CSS floating blocks that can be stacked in 2 column mode by setting their width appropriately?

There is no ETA; this is an unofficial effort being led by a community member.

You seem to be looking for #block(sticky: true)[the title] (noting that = headings already have this property by default): Block Function – Typst Documentation

You can use a two-column grid instead: Grid Function – Typst Documentation

1 Like

The approach whereby I hard-code the vertical height of the columns is somewhat brittle because I cannot predict how much space I will need. I’m generating the Typst out of data from elsewhere (in this case a simple C# templating app):

image

Is there a way to compute the space I need based on the content I’m trying to work with?

You can take a look at Measure Function – Typst Documentation, that should be what you’re looking for.

1 Like