TYPST: A new markup + page layout engine to take on LaTeX

Hello,

I’ve come back to working on this after a long break… the family were over from Australia!

I’ve been struggling to get my trial typst project working. Basically, I’ve been trying to reproduce a couple of examples from my recipe collection. In the RTF-based original, I use tabs to create the ingredients list, but of course, with MMD etc. tabs are not available, so I wanted to use a table without borders.

I am able to do it easily on Typst.com, but I kept getting error messages with the desktop version of Typst, whether I used the Raw Typst section type or the Raw Typst style.

I’ve finally narrowed the problem down: the desktop version of Typst not only chokes if you try to set column widths in terms of points rather than fractions, it also chokes on “stroke” assignment. Using fractions for columns is not really a problem, but the default strokes are heavy and cannot be changed.

So, for the moment I am stymied. I will try communicating with the developers to see if getting the desktop version to accept stroke assignment is anywhere on the roadmap.

But I’ll carry on experimenting and learning any new enhancements, like the lapreprint.typ.

:slight_smile:
Mark

Mark, go to the Typst discord server, there is a questions section and people are generally friendly and helpful there. Do you have a minimum test case that reproduces your problem (you can share a typst online doc)? The online and desktop versions should be close to identical (the underlying code is the same engine), so it is surprising that there is a difference…

Mark, I tried to change both stroke and columns in the local Typst and it works fine for me?

#table(
  columns: (70pt, 70pt, 70pt),
  stroke: none,
  inset: 10pt,
  align: horizon,
  [], [*Area*], [*Parameters*],
  [Cylinder],
  $ pi h (D^2 - d^2) / 4 $,
  [
    $h$: height \
    $D$: outer radius \
    $d$: inner radius
  ],
  [Tetrahedron],
  $ sqrt(2) / 12 a^3 $,
  [$a$: edge length]
)

EDIT: and we can set a default to not use a stroke for the whole document:

#set table(stroke: none)

Tested with pandoc table to typst with no stroke borders, all locally. This is the markdown

# Introduction

`#lorem(60)`{=typst}

`#set table(stroke: none)`{=typst}

+-----+------+-------+
| Sun | Moon | Stars |
+=====+======+=======+
| A   | B    | C     |
+-----+------+-------+
| D   | E    | F     |
+-----+------+-------+
: This is a Pandoc table

`#lorem(60)`{=typst}

Command:

pandoc -s -t typst -o Test.pdf Test.md

image

So this should be compatible with Scrivener compiler…

1 Like

Typst V0.11.0 was recently released. The changelog is massive:

The biggest change is to tables, a lot more flexibility, described in this nice guide:

Another major change, templates are now officially supported as packages, and a new web inteface for them:

As usual, install and update is trivial with homebrew: brew install typst

1 Like

I got a message that Typst had been updated and so immediately installed the new version. I’ve skimmed through the new documentation on Tables. Although, at a quick glance, it didn’t seem to be saying anything new in relation to what I was trying, the fact that many developments have been made may explain why I could create borderless tables easily on the web editor, but the same code didn’t work when I tried in Scrivener.

Sadly, I haven’t had time to spend on it since before Christmas, and with the migration of the website, I still have much to do on that before I can get back to Typst.

:slight_smile:
Mark

A really cool Pandoc 3.2 release means a nice way to generat Typst properties. This was contributed by the Typst guys as they want to take some HTML+CSS like:

<p>Here is some <span style="color:orange">orange text</span>.</p>

To generate the equivalent Typst properties:

Here is some #text(fill: orange)[orange text].

Documentation:


In another thread on making an index, I made a filter that supports a nice indexing engine for Typst (in-dexter), the output works well from Scrivener ⇨ Typst:

Styles in Scrivener:
Screenshot 2024-05-15 at 08.26.59

Index in Typst:

3 Likes

Typst V0.12 is out (well a release candidate), a huge release with at least two layout features that are IMO essential and make the layout engine almost feature complete:

  • Floating figure / table placement for multi-column documents.
  • Line numbering, essential for a lot of manuscript drafts.

There is a ton more in the changelog, and still quite a bit of work to go to generate tagged PDFs etc. but Typst is already incredibly useful for many tasks. They even managed to somehow speed it up, soooooo much faster than LaTeX…

3 Likes

Thanks for the update on Typst. It’s hard to keep up. When I started working in Quarto, I was initially excited by Typst support; however, my project relies very heavily on TikZ for causal diagrams. At the time, TikZ had not been ported over to Typst, so at that time I gave up and stuck with LaTeX as the backend. One day, I might revisit Typst. I think it has lots of potential.

Did you look at cetz, or the other packages that depend on it:

I’ve never been happy with programmatic figures (my field of neuroscience doesn’t fit well for this), so stick to hand-crafted SVG…

CeTZ has potential, but it’s pretty new and lacking some features. At least, it was lacking features when I checked around a year ago. I should give it another try sometime. This extension looks pretty useful for arrow diagrams: fletcher

Quarto has an extension to support TikZ, both directly in HTML and in PDFs. So that is a plus. I’m not sure whether CeTZ does too.

I hear you about drawing your own SVG. I like OmniGraffle and Affinity Designer for that. For my textbook, most figures are arrow diagrams, so programmatic figures are perfect, especially if I tweak the examples then I can easily update the figure (in TikZ code) without having to revise (draw) manually.

1 Like

The blog post announcing the changes for V0.12. From the discussion the cool bits are that the current changes for layout for floats should mean Typst will be well placed for layout of flowing text around shapes and images, which is one of those hard to do layout features that usually require a DTP app to handle properly…

4 Likes

Very encouraging! This goes a long way to making Typst a real contender for desktop publishing.

1 Like

Ian, do you have a new scrivener template for Typst which takes in the recent developments, or is the one you posted up above here still current?

I’ve had a year where many other matters, family and daily life issues have prevented me from continuing to work on Typst and I’d like to get back to it. But I’m pretty much going to have to go back to square one. So if you have a more recent update of the template that would speed the process, I’d be really grateful. If not, as I have to start again from the beginning, I’ll just build it up as I go along. from everything in this thread.

:slight_smile:
Mark

Hi Mark, I just checked the template from Oct 2023 and apart from some tiny details the compile is working, both the Pandoc>Typst and Pure Typst outputs. I continue to think the Pandoc>Typst route for Scrivener is more flexible.

Here are the tiny details:

  • For pandoc>typst, the gentle-clues package was updated to V1.0.0, pretty simple to edit the Pandoc+Typst meta-data file to #import "@preview/gentle-clues:1.0.0": info, success, warning, error
  • There is a deprecation warning that will need fixing before the next version, but it is minor and easy to change.
  • For pure typst compile, the post-processing command that runs typst now doesn’t support -v so that needs to be removed in compile format post-processing pane command.

Thanks Ian. Good to know. I tried compiling the Typst.scriv as pure Typst (when I finally got it opened… Scrivener kept telling me there was no .scrivproj file!… but it didn’t work and the log merely said: “unexpected argument -v found”. I hadn’t got round to seeing what happens if I delete it.

I loaded the lapreprint… file way back when along with your other lua scripts from this thread, but I’d better go and check that everything is in place still. I’ve upgraded the MBA to Sequoia; I’ve been holding off from upgrading the Mini until I’m sure I won’t have problems with other apps.

:slight_smile:
Mark

Nothing, I think it -v means verbose but was removed, it wasn’t important, only for logging…

For lapreprint I did update the template to stop warnings in V0.12, my latest version is always available here: dotpandoc/custom/lapreprint.typ at master · iandol/dotpandoc · GitHub – I so totally love this template for scientific preprints.

My most useful lua filter for typst typstFix.lua is working fine (note my template from Oct 2023 doesn’t use it IIRC).

For me Sequoia has been working great so far…

Thanks Ian. I’ve got a bit more experimenting and checking to do, and I’m away for this next week so it’ll have to wait till I get back.

At the moment, trying to compile your project, with pure Typst I’m having a problem with the bibliography, because when I put Core.bib where it says it wants it, it just gets deleted before being referenced and throws an error; Pandoc → Typst throws another error re gentle-clues even though I’ve updated it to 1.0.0, though I’ll have to check.

:slight_smile:
Mark

This is a Scrivener problem when compiling text, see @AmberV post from Nov 2023 – my workaround is to to use Finder’s “Get Info” and “Lock” the .bib file so Scrivener can’t delete it. @AmberV suggested this was fragile, but it works well enough for me in stopping Scrivener from wiping the files needed for compile.The other workaround solution is to copy files manually and running Typst yourself, but locking saves a bit of fussing…

1 Like

Hello. I’m considering working in Scrivener to output to Typst. Since the last post was more than six months ago, I wanted to ask if by chance there have been any changes to the starter Typst.scriv file kindly provided in this thread, in light of some updates to Typst in the meantime?

Right, the previous version was not compiling with Typst V0.13.1[1], so I made a couple of fixes and this one compiles for me (I only tested the markdown > typst compile format

V0.46: Typst.scriv.zip (318.3 KB)

The PDF generated by Pandoc+Typst direct from the Scrivener compiler: Typst.pdf.zip (162.0 KB)

NOTE: just a reminder this won’t compile as-is on your system, you will need to change paths in the post-processing panel for markdown and plain text typst outputs, provide the lua filters or remove them in the commandline etc. For plain text (Pure Typst compile) you need to fiddle with locking the bibliography file or accepting you use typst compile after Scrivener.


[1] for geeks, Typst made a pretty major breaking change replacing an older syntax with a #context command that is used when dynamic contents like figure numbers are needed. Context is more unified and an important part of Typst: Context – Typst Documentation

3 Likes