Top
Best
New

Posted by DominikPeters 8 hours ago

Show HN: TikZ Editor – WYSIWYG editor for figures in LaTeX(tikz.dev)
Hi all! TikZ is a widely-used LaTeX package for drawing figures in papers. It uses commands like \draw[->] (0,0) -- (1,2); to draw lines, shapes, text, etc. Academics usually code up their figures by hand, so there is lots of twiddling around with the coordinates and recompiling until things look nice. I guess it’s a bit like SVG, but it’s more code than markup, for example it has loops with \foreach.

I built an open-source WYSIWYG TikZ editor (available for web and desktop) that allows you to edit your TikZ source code visually by dragging and resizing elements. It simultaneously shows the source code and the rendered figure, and lets you edit either one while the two views stay in sync. I’m not aware of any other editors that are simultaneously source editors and WYSIWYG (even for editing SVG or HTML), and I’m quite pleased with how well the combination works.

The way the app is implemented is by parsing the TikZ code, and at all times keeping track of the exact source location of each object. Thereby, when a user drags an element to a new position, the app can override just the numbers in the coordinate without changing anything else in the code (such as line breaks or indentation).

This approach essentially required reimplementing a large fraction of TikZ, which is the kind of task that no human would ever want to do. I think building software that doesn’t exist yet because it would be impossibly tedious to code up is one of the great new possibilities thanks to coding agents, and it’s worth brainstorming for other examples. (This app was built almost entirely by Codex.)

Implementing the app came with lots of fun side quests, including building converters from SVG / pptx / ipe to TikZ, re-implementing the LaTeX hyphenation and line-breaking algorithm to support multi-line nodes, and making a color picker that uses the red!20!black color mixing notation used in LaTeX papers.

228 points | 45 comments
gignico 4 hours ago|
I've tried it now a little. The UI looks very cool, and generally the project is cool so congrats!

However, the generated TikZ code is not good in my opinion. Everything uses absolute coordinates, which in TikZ is seldom needed.

Just to start, if I place a single node I get absolute coordinates for it. Why? If you just write `\node {Hello};`, TikZ will put that at the center of the bounding box. No need to tell it's at `(0.5,2.91)` like it's happening in my test. Then features such as "align bottom" for a selection of multiple nodes should are manipulating the absolute coordinates instead of using TikZ's alignment features (anchors etc.).

I understand generating such code is more difficult. Maybe it can be something to point at for the next version, who knows...

wjholden 4 hours ago||
Oh man, good on you identifying a product that needs to exist. I've used a few TikZ editors (both online and desktop) and none of them are just amazing.

But, I've taken my papers to Typst. Could you have the agent do the same thing for Cetz, the TikZ equivalent for Typst?

DominikPeters 4 hours ago|
I don't use Typst myself and am not familiar with Cetz. From the docs it looks like it's in early stages of development, so it doesn't feel like the right time to do this to me (or at least should be a separate, perhaps forked, app). But certainly it would make sense to develop bidirectional converters that could in particular be used at file open and file save in this app.
lopsotronic 5 hours ago||
Ah, I love CircuitiTikZ. Only way to do simple text-based circuit diagrams.

https://ctan.org/pkg/circuitikz?lang=en

https://github.com/circuitikz/circuitikz

Some years ago I wired it up with `asciidoctor-diagram` so we could have simple circuits in our Asciidoc maintenance manuals. The techs loved the hell out of it, and we could collaborate on the things in a git versioned ecosystem vs whatever fresh hell the PDM/ERP had for us.

A very nice complement to the already awesome WireViz (https://github.com/wireviz/WireViz)

j2kun 7 hours ago||
Neat! I also enjoyed https://q.uiver.app/ by https://github.com/varkor which is a bit more specialized.
DominikPeters 7 hours ago||
Yes, there are several editors for more specialized things. Other nice examples: https://tikzit.github.io/ and https://www.circuit2tikz.tf.fau.de/designer/ and https://tikzcd.yichuanshen.de/
ixsploit 5 hours ago||
I used lyx during university. Was super happy. Still have all my homework and lecuture notes.

https://www.lyx.org/

mcswell 5 hours ago||
I'm running Linux Mint (xfce version), and I installed the .deb version (TikZ.Editor_0.4.0_amd64.deb). It's very odd...for example, when I open it or do File/New, many (but not all) of the grid cells are rectangles, not squares. Am I doing something wrong, like installing the wrong version? Or maybe misinterpreting what the faint grey lines are?
DominikPeters 5 hours ago|
Yeah that's odd, the grid should be square. Is the web version looking correct in the browser? Feel free to paste some screenshots into https://github.com/DominikPeters/tikz-editor/issues and I can look into it.
master-lincoln 7 hours ago||
As a student I really wanted something like this. Thanks for making it open source. My theoretical computer science prof happened to be Till Tantau the inventor of TikZ. An awesome communicator too.
DominikPeters 7 hours ago|
Schleswig-Holsteiners are everywhere :) Till Tantau also started the beamer package for making LaTeX presentations. Both beamer and tikz are very important contributions to science communication.
otto-riz 4 hours ago||
> the kind of task that no human would ever want to do

I'm not an AI evangelist, but this kind of thing is such a welcome boon. More itches can be scratched!

sorenjan 7 hours ago||
Looks really nice. You might consider adding some presets to make it easier to get started, like some common neural net architectures and other use cases for TikZ.
DominikPeters 7 hours ago|
Good idea. There is File > Open Example, but it could be extended for sure. On desktop you can even directly open an arXiv paper!
__mharrison__ 7 hours ago||
This is very cool, but I'm going to say the inevitable...

How hard would it be to support cetz? I'm not touching LaTeX if I can avoid it, but I'm using Typst all the time.

hw__ 4 hours ago|
Probably quite doable with a coding agent.

There is a full wysiwyg (vibe-coded) presentation software based on typst available which partially implements exactly that:

https://codeberg.org/presenst/presenst

srean 6 hours ago|
Is their anyone here old enough to remember Xfig ?

I was quite proud of the hours of work I had put in to configure it just so, with the 3d look and all.

bedstefar 5 hours ago|
I do. I used it in the late noughts for my cryptology BSc because I was too lazy/busy to learn TikZ proper
srean 5 hours ago||
Tikz by hand for busy diagrams can be a whole lot of work.

What I loved about Xfig was that one could use latex and latex fonts in the diagrams.

More comments...