Is there a good way to make circuits in Typst?

Hi, I’m very new to Typst and I’m a bit confused.

I ask this question because circuiteria doesn’t have any premade components for things like transistors or op-amps, and cirCeTZ seems to be dead for about a year now and I can’t get it to work.

Is there just not currently an easy way to make circuit figures in Typst?

Thank you for your patience.

I’m also interested in this question. I’ve been using diagrams.net for circuit drawings, with the occasional use of xdot or Visio. I just export to png then include in my Typst source as images.

If you only need a couple of new components, I’d suggest adding them to circuiteria yourself and submitting a PR. Diagram elements are here in the circuiteria repo: circuiteria/elements at main - circuiteria - HERDAC.

That said, circuiteria seems to be intended more for logic-level abstraction. I don’t see any alternatives that provide transistor-level detail; you may have to do this on your own with CeTZ.

2 Likes

I’ve actually been looking for a package like this myself, specifically for creating circuit diagrams with components like resistors, capacitors, and so on, but I haven’t found anything that fully meets the need. I’d be interested in collaborating to develop such a package if others are also keen to explore it.

Maybe we could brainstorm on how to implement it, possibly drawing some inspiration from how similar packages work in LaTeX, or even consider a fresh approach that fits Typst’s unique style and syntax. Let me know if anyone’s interested in working together to make this happen!

2 Likes

Minor update!
It turns out that the dev branch of cirCeTZ does still work, though there are some deprecation warnings.

All you need to do is put the repository in your packages directory:

  • $XDG_DATA_HOME or ~/.local/share on Linux
  • ~/Library/Application Support on macOS
  • %LOCALAPPDATA% on Windows

With this directory format typst/packages/local/cirCeTZ/0.0.1
Such that the typst.toml file is in 0.0.1

Then you import it with

#import "@local/cirCeTZ:0.0.1": cetz, components

It is completely undocumented but inside the tests folder there are some tutorials which are so far pretty simple and informative, especially if you’re familiar with CircuiTikZ. Though keep in mind that you always replace "/src/lib.typ" with "@local/cirCeTZ:0.0.1"

2 Likes

I’d be very interested in working on a package like this!
Though developing a new one from scratch seems daunting! Especially since I’m no artist. Since cirCeTZ seems to still work what do you think of reviving that? Since there has already been a lot of work done there.

If you have some ideas on how the syntax/API can be improved then we could overhaul cirCeTZ and cannibalize it.

If you’re open to reviving cirCeTZ then the first thing we need to do is update it to modern the CeTZ API to get rid of the warnings and document it as we read through the code base.

2 Likes

I think that’s a great idea! Starting with a fork of cirCeTZ sounds like a solid approach. We can then work together to optimize the code, remove deprecated warnings, and gradually add more elements. Let’s set up the fork and start by familiarizing ourselves with the code base—then we can discuss potential improvements and additions as we go along. Excited to dive in with you! By the way, what’s your GitHub account name?

Indeed, circuiteria was first created for logic-block circuits, as it was something useful for me in a System Designs course (see Circuiteria:0.1.0 - Drawing block circuits with Typst made easy, using CeTZ - #3 by LordBaryhobal)
As I said in that post, I am open to adding this sort of elements to the package as this is something that is indeed currently somewhat lacking in the Typst universe
Feel free to contribute to the package if you can (and if you can understand what I’ve written :sweat_smile:) I will also try to look into implementing this but this is not a promise

2 Likes

That sounds like a better idea! Expanding Circuiteria seems like a great way to bring more comprehensive circuit elements into Typst. It would be really helpful if you could add one more traditional element, like a resistor, to set a foundation. From there, I’d be glad to contribute by adding additional components. Thanks for being open to collaboration—I’m looking forward to building on what you’ve created!

1 Like

I have actually started implementing resistors and capacitors. I’ll try to commit and push what I have asap

3 Likes

Sounds great, thanks for jumping on that! Looking forward to seeing your updates!

Hi, owner of cirCeTZ here. I haven’t deliberately abandoned development, a lot of life stuff has hit me over the past year and I’ve been working on slightly bigger projects (e.g. CeTZ) with what little energy I actually have to spare.

CirCeTZ ideally should be an accurate port of circuiTikZ, you should be able to replicate one in the other with minimal changes to the options/styling. I don’t remember what state I’ve left it in but I think most of the infrastructure is there. What burnt me out was having to read the circuitikz source code to figure out all the details for each component (just thinking about it is giving me a headache). The alternative would be paying some 600 euro to access the only maintained standard IEC 60617, which might possibly lead to a few licensing issues.

That being said if someone is happy to pick up the tedious work of making the components (or at least figuring out all the details and noting them down far away from any tex code). I’ll be happy to setup PR templates for components and further improve the structure.

I’m sad I didn’t see this sooner, so if you have any further questions or just want to talk it’ll be better if you ping me on discord @fenjalien. Either dms or we can setup a thread in the cetz universe.

Thanks for the interest though :)

2 Likes