Newcomer questions about TeXmacs

Hi, I have recently discovered TexMacs. Like many people before me, I always assumed that TexMacs is a special Emacs mode for Tex and never thought twice about it. I’m here because of the recent HackerNews post that explained what TexMacs is and was immediately interested!

I started writing some dummy documents last week, and thought that writing my PhD thesis in TexMacs could be a good idea! I’m still considering the transition, with some questions in mind:

  1. Is there support for alternative editors? I know about Mogan, which doesn’t run on my current MacOS setup. I need to try under my other computer running EndeavourOS.
  2. Is there a support for Vim keybindings? I’m used to writing LaTeX in Neovim, and have a hard time switching to a normal editing mode.
  3. Is TexMacs working nice with version control? I would like to be able to view the git diffs and to track my manuscript using Git/GitHub. Using some custom scripts, it could also be a nice way to automatically publish a HTML version of it so that my advisers can take a look at it.
  4. How stable is the software? I’m afraid of it crashing with no alternative editors available. I’m looking for something with minimal friction and no configuration rabbit-hole like the usual combo of LaTeX with an IDE.

Thanks a lot! Will probably try to write a paper using it to try TexMacs for the first time :slight_smile:

Hello and welcome!

I have transitioned to TeXmacs around a year ago. I was just unable to finish a very long and technical paper without having the math in front of me.

  1. Mogan and TeXmacs are almost indistinguishable, they differ on a technical level but in practice they are almost the same.
  2. I believe there is no modal editing in TeXmacs. However the key bindings are customizable. It seems a bit daunting at first because it is mainly done in a config file written in scheme but we can help you out. Actually, TeXmacs has a quite well thought through keybinding system that makes inputting math “natural”. I was coming from Emacs+Auctex and used the backquote + character to enter many mathematical symbols e.g. ` + a gave \alpha etc. It was relatively easy to configure TeXmacs to accept this since I did not want to lose muscle memory and for some things doing letter + TAB + TAB + TAB.... did not seem the best for me.
  3. I use version control with texmacs documents. This allows me to have tracking of the history. The git diffs are partially useful: you get the gist but they are a bit difficult to read. HOWEVER TeXmacs has a great intrinsic diff tool: you feed it two versions of the file and it gives a comparison that is better than latexdiff!! You can then live edit it and cherry-pick modifications.
  4. Stability is ok. The software does crash periodically but the developers are very helpful in debugging. Many bugs have been fixed but not released. It might make sense to use the snapshot version if it is available for your system. However, for me, the crashes were never particularly a deal breaker, and they never lead to data loss (setup autosave to 60sec).
  • (3-4) However, you will never have issues with lock-in!! TeXmacs has both an import and an export to LaTeX. For my 108 page manuscript, I exported to LaTeX before submitting to arxiv. The final adjustments (mainly aesthetic but also some technical to make it compile) took around 3 hours. Importing a LaTeX file and making it be reasonable in TeXmacs tool slightly less (1h?). The import-export capability is inadequate to be able to collaborate with someone not using TeXmacs but is good enough to never feel constrained by the system. Actually, when collaborating with others, I often write up the first draft of a section in TeXmacs, export it to LaTeX, and then include it into the main file.
    Also, about exporting, you can directly export to PDF and that is immediate. It does NOT go through LaTeX but exports quality PDF directly so there is no friction there. I routinely export a PDF at the end of each working day to have it on my tablet to be able to highlight potential errors that I fix the next morning!
    I think HTML export also works but last time I tried it gave really ugly pages, but that might have been just some issue with my setup. If you want collaborative markup of PDFs there are multiple solutions. You could even host it on github and suggest using something like https://web.hypothes.is/ (that is unfortunately underutilized even though it is a good tool!)

Another thing that works very well with TeXmacs is live math input. It is just so so natural. Often, when I have to do and record important manipulations, dealing with tricky multiple integrals, I do so in TeXmacs. Being able to copy-paste an equation and then select blocks and copy-paste then around is a godsend. I made a template with some predefined environments for such “scratchwork”. Then copy-pasting inside TeXmacs is seamless.

Here are some issues I personally have encountered:

  • For large files TeXmacs becomes a quite slow (enough that the latency is a constant annoyance). The solution seems to be to split the document into a multifile project ones http://www.texmacs.org/tmdoc/main/links/man-multifile.en.html. The setup is a bit quirky, but the export is relatively seamless after that. If you need help, ask here. I’ll share my setup. The issue of performance is tricky: some people have stated that they wrote thesis with no issues. Others have significant issues. But at the end of the day: there are workarounds, and you are never locked in. You can always go back to LaTeX with minimal time expenditure.
  • Opening the same file in multiple windows (e.g. to be able to see the different parts of the project) is very quirky. The behavior is essentially undocumented, but once you figure it out, it can be done without problem. However, there is a popup preview functionality for references that is a godsend and better than anything I have seen elsewhere (also better than PDF). Also there is a breadcrumb-style navigation shortcut. If you follow a link, you can then press alt+ <leftarrow> to return to the place you were editing previously.
  • The search & replace functionality does not work well. If you are replacing text or maybe a label and references then it works reasonably well. I found more structured search/replace e.g. with wildcards often broken and very slow. In LaTeX, I did do some regexp manipulations that I was unable to do in TeXmacs. To be fair, the regexp based ones in LaTeX are also very unreliable because they are not “context aware”
3 Likes

Let me comment a bit about two remarks of @guraltsev:

  1. crashes: my own experience with TeXmacs (and as a developer) is that it does not crash on me “periodically”. Actually in my usual uses it never crashes and I do not remember any problematic situation which lead to systematic crash. But I suspect this is linked to the fact that, as experience user, I tend not to do strange things with it. There were an issue with multiple windows or closing widgets, which should have been recently solved by @pjoyez and committed to the repo. But it is still not in the released version. If a user experience a crash which is somewhat reproducible it would be very useful to know. As developers we corrected the crash we know of, usually it is a problem with the UI but again my experience does not agree with that of @guraltsev.

  2. speed. I work on long papers, and recently several of my students wrote their PhD thesis with TeXmacs keeping all the content in one file. As far as I know they didn’t experienced drastic slowdown even for documents with ~150 page. What is certainly helpful is not to use “paper mode” but only “papyrus mode” which avoid page breaking and should make typesetting faster. Anyway there is no magic bullet: I’m not sure TeXmacs has any particular strategy to minimise re-typesetting while editing, so as the document get longer the typesetting times get also longer. TeXmacs however has some strategy to minimise redrawing, so only parts of the document which are visible are recomputed. What I noticed myself is that sometimes the typesetting become very slow even for relatively short documents (50 pages or less). Sometimes this is due to the presence of tables or other content, not intrinsically due to the lenght of the document. It would be interesting to understand clearly what slow down TeXmacs so that we can improve the situation.

There is a list of documents created with TeXmacs here:

https://texmacs.github.io/notes/docs/example-documents.html

if you want to see very long documents you can look at the theses mentioned there and moreover at the following documents:

the PhD thesis of Barashkov (160 page): https://bonndoc.ulb.uni-bonn.de/xmlui/handle/20.500.11811/9684
the PhD thesis of Galeati (216 pages): https://bonndoc.ulb.uni-bonn.de/xmlui/handle/20.500.11811/10089

an example of a recent paper written in TeXmacs: https://arxiv.org/pdf/2212.05584.pdf

To check yourself about the speed the easier way is to let TeXmacs generate the user manual and then try to edit it. Choose Help -> Full Manuals-> User Manual in the menus. It will take some time for TeXmacs to collate all the manual pages and create a single document with all the user manual, but at that point you can edit /save the document as you like. It is a fairly complex document with a lot of images and references, and indeed you can feel some diminished speed, but I guess this is the really extreme situation in which you can expect TeXmacs to not perform optimally.

Just to be clear: if any user experience some sluggish behaviour which sets in as a document become longer, we would like to know. I know some situations exists but I cannot yet pinpoint them precisely.

3 Likes

Vim keybindings were discussed here: A very tiny vim in Texmacs but I’m not sure what you mean by “normal editing mode”. Keep also in mind that TeXmacs is a structure editor, so in many ways it does not behave like a usual text editor. You have explicitly to create and exit structure with appropriate commands.

As for git: there is some rudimentary support for version control, but we do not have yet integration between our internal versioning system and git. There is slightly better support for SVN. Help is welcome to improve the situation. It should not be very difficult to make a nice interface to git. @darcy what is your opinion on this? you worked a bit on the problem.

HTML generation works. Our blog: https://texmacs.github.io/notes/docs/main.html is created in TeXmacs and delivered with GitHub pages, so you can look there for inspiration on how set up things. You can look at the paper of Joris van der Hoeven for examples of translations to HTML, e.g. https://www.texmacs.org/joris/resultant/resultant-abs.html

1 Like

Thanks for all the answers!

I am writing about computer music so I don’t think that I’ll be taking advantage of the math input even though it looks very nice. I’ll probably be arranging a lot of figures / tables / pictures / code boxes and the occasional musical score that I can format using a tool like Lilypond or MuseScore. Compared to a PhD thesis in mathematics, I am afraid of having to deal with an extremely dense/big document of ~300+ pages but the splitting in multiple files is how I deal with LaTeX already so it’s probably fine :slight_smile:

I’ve tried on MacOS (MBPro 2021) and Linux. Performance was much better using EndeavourOS even though editing was a bit slower than usual. It took approx. 3 minutes to generate the document on MacOS and editing was less than ideal. New letters are appearing several seconds (sometimes 10s+) after input. It’s true that the document is crazy complex, and I believe that it would be much better without having that much tables and special glyphs. Some viewing modes are not usable. I’ll search for that papyrus mode. I would love to help with this but I’m not particularly competent with either C++ or Scheme.

I guess I was referring to non-modal editing similar to what I experience now with the Discourse forum. I guess that I can also type long paragraphs in Neovim and copy/paste in the TeXmacs buffer for formatting. I really like how clean the output looks and will probably also try the HTML export to rework my personal website.

Thanks everyone for your very quick answer. I’ll stick with it for the time being and see if I can transition later on for larger documents!

EDIT: I finally managed to run Mogan on MacOS and the editing experience is slightly smoother.

1 Like

There are some suggestions for large documents in Jolly Writer section 6.6.

I still do not understand, I do not use often Discourse, but seems to me a chatting app as many, the analogy is not helping me understand what you mean. Why you do not want to type directly in TeXmacs? What is the problem?

Vim allows you to have different editing modes for your text document. There is a mode for moving around in the text using keybindings (selecting words, moving up or down a line, go to the end of the line) and other modes for inserting text (Insert mode, Visual Mode, etc…). Sure I want to write text, but sometimes I just need to move around in the text and I’m generally more at ease using Vim for that as I don’t have to reach my mouse or can be more efficient by just typing a command moving the cursor where I need it to be. Normal editing mode, as such, is the editing mode you use in 99% of other computer applications, where you write text directly when you click on a text box, essentially being stuck into a single mode used for everything (writing, moving, selecting, etc…).

On a different topic, I’ve reached the point where I want to start inserting references in my text. I have a dummy .bib file that I am using to test that feature. I’m using a dummy file because I previously thought that my personal .bib file was broken. I keep hitting the Invalid bibliographic key list message whenever I am updating the document using Ctrl+Shift+R. I’m also unable to add a reference/citation anywhere in the text and the bibliography stays blank. I’m 100% sure that my .bib file is valid. Is there a solution/workaround to that problem?

I’m not sure what you mean that you are unable to add a citation in the text. Just type \cite and then hit enter and complete the label and hit enter again. This adds a citation, which should come with a ? until you do not recompile the bibliography. You have to insert the bibliography as explained in the TeXmacs online manual and indicate the file. If you already did that, is probably a problem with the bibliography entries. Can you show us one bibliography entry?

I understand now. I would have said that the usual editing is “modeless” while vim editing is “modal”. Actually TeXmacs editing is modal too, but the default modes are “text”, “math” and “prog” and keybindings can behave differently according in which mode the cursor is. I’m not sure that it is possible but maybe one can define other modal behaviour in TeXmacs using some variables and then emulate vim modes, but I never tried. If you want to get some fun with scheme this could be a nice exercise. :slight_smile:

1 Like

One thing that Texmacs for now does not do automatically is numbering sections correctly in subfiles. In each subfile I add the following code into the preamble (I found the suggestion in another thread that I currently cannot recall)

 <assign|section-nr|0>

so that sections are numbered correctly. Of course, you have to manually adjust things for now…

Does the post that @mgubi mentioned, namely, A very tiny vim in Texmacs, precisely address this? It is premature and basically a proof-of-concept, but it shows that vi-mode is implementable.

This is explained a bit in the online manual Help->Manual->Automatic content generation, section 8 is about books and multifile documents.

3 Likes