Sketches and plots in Texmacs

i discovered Texmacs a few days ago and like it so far. I’m studying physics and used Latex for all of my scientific writing. So far i miss the functionality of pgfplots + tikz and the latex export in inkscape. Is there any recommended way to get fitting (font, fontsize etc) plots and sketches in texmacs?

Welcome! You have several possibilities: there are various plugins which allow you to use e.g. TikZ or other programs like Graphviz to generate programmatically graphics within TeXmacs. You can also draw graphics inside TeXmacs. Or if you already have a graphics then you can “Ink over” it and add labels within TeXmacs. Another possibility is to use scheme to create graphics programmatically. For more informations please give a look at Help->Plugins->Graph for example, or to the blog we maintain here:

for example this tutorial in the use of TikZ via the Graph plugin:

or about using scheme to program graphics:


Here you find some example of using Python within TeXmacs to generate graphics:

Note however that for many kind of graphics, you can just use the internal drawing editor. In the document below all the graphics which are not generated by Python are made by hand within TeXmacs:

1 Like

This is very nice. I had not realized that the embedding of plots generated by Python is done with pdf_out(plt.gcf())

Maybe I shall write a short note about this on the blog.

1 Like

As Max showed, you can draw any plot (using sufficiently long polylines if necessary :slight_smile:), there are some—not terrible—limitations yet; that is, the if you use embedded TikZ drawings, you need to adapt the the font of TeXmacs to the TikZ drawing; and if you use Scheme graphics you have to either use the graphical editor (nice, but would benefit from further development) or you have to write your graphics using primitives (which might make for rather long programs).

For TikZ I suggest to develop the graphics in a TeX editor, then to copy-paste it in a “Graph” executable switch.

For Scheme, I have written a few functions ( which are the start of modular graphics (by the way grouping is available in the TeXmacs graphics editor as well) but they are severely limited.

I have also the feeling that to get to the quality of TikZ one needs to refine line thicknesses.

A nice thing, for anyone who would like to do it, would be IMHO to change the Scheme syntax so that one gets graphical commands which are easier to read. I have found a reader framework for Guile, which I think should be the right tool to modify the input syntax (, I did not yet manage to compile it though.
If one works on this, it looks to me that a very difficult thing would be to keep the “intrinsic” combinability of Scheme syntax (where everything combines with everything) while adding more syntactic symbols (e.g. different kinds of brackets) to make the input easier to read.

1 Like

When I write TiKZ code I usually do it in an interactive session within TeXmacs, even for TeX documents because it is faster to see the result.

Note that in the graphical editor you can press “!” to get a dialog which allow you to programmatically insert graphs of functions written in scheme, I used it sometimes to get a Gaussian density for my probability lectures. The graph can then edited as all the rest of the graphics.

1 Like

Yeah, even the font size is not shared. To customize the font size for xypic, I need to write the whole standalone .tex file manually, which seems a bit cumbersome.


It would be interesting to understand what is missing so that we can add it. Can you put here an example of the file in which you adapt the font size? We can probably make this automatic.

I didn’t know this too (or perhaps i had forgotten it). Do you know how to edit a graph made in this way? Selecting it and pressing return does not go back to the code.

For TikZ, if there were code highlighting (and maybe also code completion)—it would be easier to do everything in TeXmacs.

By the way for the running mode it is set to stop at errors, right? It is probably the best for compilation from TeXmacs, as otherwise one would need a mechanism to get quickly to the error lines (usual in TeX editors, might be too much to program this for a plugin).

I am thinking about the simplest case (I have deleted the image deta):



  Consider the commutative diagram







Here I set the font size to be 14, but the inserted commutative diagram does not share this setting.

The key problem is that we don’t have a conceptual framework for plugins to control what information should be shared, and continuously adding ad-hoc workarounds is not good for either developers or users.

At first sight it seems to me very hard, as one would need to get TeX to use the same fonts that TeXmacs does. But maybe it is possible?
Of course the message of re4zuaFe below is looking at the issue in a broader way.

Thank you all for your answers! Seems like i will learn the basics of scheme.

I used the integrated image editor, but it was unstable for me. It crashed texmacs 2/3 times in the ~1 hour i used it. Additionally the font size is still variable and not the same by default.

I’m currently writing a assignment with texmacs (quanten-hall-tm.pdf). Picture 3 and 5 are drawn with the integrated editor, 4 is imported from a tikz session in texmacs and the plots are made with pyplot. The integrated editor looks quite good, but pic. 5 are the default font sizes and it looks a bit out of place.
Pic. 4 looks really out of place since the tikz session somehow uses different fonts.

I used pgfplots and tikz in latex (see uo.pdf) for most of the graphs and sketches (my partner did some pictures) and i like that consistent look.

The graphs made with “!” can be just modified again in the editor, as far as I can see.

For TikZ, of course more tools would be useful but somebody must do it. :slight_smile: Personally I edit only very short snippets so I do not find difficult to find the problem.

Let me also say that for many tasks the integrated graphics editor is already quite good. Very simple commutative diagrams can be written within TeXmacs. Instead of putting resources to improve the connection with xypic it would be better to provide a replacement which can use all the power of TeXmacs. A possibility would be to postprocess the generated PS file to replace the text/fonts, but this require some work.

First about commutative diagrams within TeXmacs: I suppose that you meant the technical graphs inserted by Insert -> Image -> Commutative Diagram. The problem is that the cells are determined by coordinates (unlike xypic which computes the coordinates). This is cumbersome, especially when you want to edit one term significantly (this is quite normal when writing drafts of articles). For example, if you want to change the A in the square diagram A&B\\C&D to SomethingVeryLong, you need to adjust all positions of surrounding objects like vertical and horizontal arrows and even the positions of neighbor cells.

I suppose that the ideal way for xypic is to somehow implement xypic in TeXmacs. I suppose that it should be based on the existing tabular functionalities, and it is essentially about adding arrows of which the length is determined by the real positions of cells.

On the other hand, I don’t think that postprocess the generated PS file is anything better than to pass the environment variables to plugins like Graph and xypic in particular. The problem is that, it is xypic’s job to compute the positions of objects. If you postprocess the generated PS file, it is possible that the computed positions are no longer appropriate due to the change of fonts or font sizes. xypic needs these information to produce a better visual effect of diagram.

Well you have two choices, you can of course change the font size in the text you add, by making it smaller. Or you can envelop the graphics within a <with|font-size|0.5| your graphics here > tag so to control the scaling factor of the font. As for the crash it would be useful to know reliable ways to make it happen. I use often the graphics editor and lately I never experience real crashes. But I agree that the code is not as solid as we would like.

1 Like

Another strategy would be to program cells with text which have reference points around and lines between reference points so that when one modify the cell the lines adjust automatically.

I’ve just found that somebody wrote a picture language for Guile;a=tree

The original language is described here:

it could have some interest to adapt it to generate TeXmacs graphics.

1 Like

Some more inspiration for a programmatic interface to the graphics output here:

1 Like

Hi Max

this looks to me the same as the one you pointed out to me in the github conversation (

I tried it using Geiser in emacs and I looked very quickly at a few functions in the code. There is one thing which I did not understand at all—how he generates the svg images, and one thing I think I understood—that he looks recursively within graphics for the structures he wants to modify.

Maybe step by step I will be able to extend and improve what I started.

I am also thinking about modifying Scheme’s syntax to make with it a more easily readable graphics language, but I cannot focus on what I would like to obtain. I have in mind that it should have one or a few more syntactical signs to distinguish an entity (and maybe which kind of entity) from an operation, but I am afraid that one would lose the ease of combination that one has with the standard Scheme syntax (only parentheses).

I have been able to compile guile-reader ( and tried a few of the examples in its manual. Perhaps that is the program that one needs to build up a syntax.

Thanks also for the second link.