General questions regarding Texmacs

I recently started playing with Texmacs after it was recommended to me by a friend. I like it a lot, but there are couple of things I would like to do that are not apparent to me at the moment.

  1. I downloaded the manual from this link. While reading it, I noticed the location of a lot of the menu items described in the manual do not match with the current version of Texmacs. Is there a more up to date manual?

  2. What is the recommended way to create a cover page?

  3. I noticed that there’s no listing environment. How does one define a new environment? Also, how does one build a list of such environments like list of figures?

  4. Is it possible to integrate like minted to properly format code blocks?

1 Like

Hi, Welcome!

  1. The full manual can be obtained from the Help (and I think in that case the key combinations will match your system, but I’m not sure). Apart from this, Joris wrote a book “The Jolly Writer” (TJW)with updated detailed informations.

  2. There is no recommended way, as far as I know. You can create a table of the right vertical size, or just add some spacing around the title.

  3. You can read the user manual on how to define new macros / environments, or TJW. There are also some info in the blog (https://texmacs.github.io/notes/docs/main.html) and some examples of macros and packages in the tm-forge repository (https://github.com/texmacs/tm-forge). Feel free to ask around in the forum for help.

  4. Short answer: no. There is no automatic way to convert LaTeX packages to TeXmacs, they are two different systems. TeXmacs can interface to python so one could in principle write a Python code which uses the Pygment library to render the code and then display in TeXmacs. See for example the “Graph” plugin which gives a similar interface for some graphical output. For some languages TeXmacs has an internal parser which can do some syntax highlight (C++, Scheme). Look here (https://texmacs.github.io/notes/docs/customize-syntax-color.html) to see how to customise it a bit.

Re 4: I’ve written a plugin to do what @mgubi suggests. It still has some bugs, but you could try it out:
https://github.com/woutersj/tm-pygments

1 Like

I added the files as per the instruction on the README. I don’t understand how to apply the syntax colors. Have a look.

image

Did you put that text inside Insert → Fold → Executable → Pygments and activate it? That looks like the standard TeXmacs highlighting you would get inside a “Block of code”.

Looks like a great plugin. I wonder if it would be hard to modify it to add also line numbering on the side. What do you think @jeroen?

One could put the fold inside a numbered tag.

Screenshot%20from%202022-01-14%2020-22-49

This seems to have been implemented for use with TeXmacs’ standard code listings (in TeXmacs/packages/environment/env-program.ts), but hasn’t been made available through the GUI, as far as I can tell.

1 Like

@jeroen, your plugin has just made it possible to highlight any language. Thanks!

image

I’ve skimmed over Pygments and apparently it also handles line numbers already, but I guess one would have to implement the feature in the translator. Your solution is already very good.

Is it possible for you to give me an idea on how to create a listing environment (see image below), and then list them all like in the table of figures?

If you look in the Help “The standard TeXmacs styles” and there section 3.1, it is described a macro to generate a new “Figure”-like environment. I guess you can use that to have a new “mylisting” environment which behaves like a Figure. You should experiment to see if the TOC is produced correctly I never used this. In general if you know the name of a macro you can look into $TEXMACS_PATH/styles and $TEXMACS_PATH/packages to see how it is implemented and maybe copy some code and modify to suit your needs.

Thanks, I’ll have a look. I hope you don’t mind me taking this opportunity to ask one more question. I have been experimenting with sessions such as maxima and loving it a lot. I am just wondering how I can create a shortcut (keybinding) to insert a new session insert of having to click on the icon and choosing the session I want. I looked at the code but I don’t know how to do it for sessions.

I haven’t tried it, but I would think something like

(kbd-map ("M-s m" (make-session "maxima" "default")))

@jeroen, can you help me write a macro that allows me to quickly input a pygment executable? Here’s my attempt so far.

  <assign|mk|<macro|body|<wide-framed-colored|#f5f2f0|#f5f2f0|<value|framed-width>|<value|framed-hsep>|<value|framed-vsep>|<with|font|Iosevka|font-base-size|10|par-par-sep|0.3333fn|<\script-input|pygments|default>
    %python; default <arg|body>
  </script-input| >>>>>

The issue I face with this code is that the pygment cell is not executable.

This does not seems the way you should customise the output of a script. I guess is not working because the UI needs the script tag to work properly. If you look into TeXmacs/packages/compute/scripts.ts you see that the script-output macro look for a customised output macro for your given package. If it does not find any it uses a generic output formatting macro generic-script-output. I suggest to put your formatting code into a macro called pygments-script-output and then just use the generic script-input macro to insert your pygments code. To make your solution would I guess would need to write some scheme code to switch between the input and output form of your custom tag.

1 Like