You're reading the public-facing archive of the Category Theory Zulip server.
To join the server you need an invite. Anybody can get an invite by contacting Matteo Capucci at name dot surname at gmail dot com.
For all things related to this archive refer to the same person.
I would like to write a book in LaTeX and have the chapters appear as web pages or blog articles. I want to be able to keep editing each chapter over and over, and update the corresponding chapter each time this happens. I want the webpages to look fairly good. I also want the final result to be printable as a single PDF file. I want all of this to be quite easy to do.
What's a good way to do this?
Right now I could write in LaTeX, convert some formatting commands to HTML by hand, and create either a blog article or a web page. This would not work well for references (to theorems in other chapters, for example) or citations (of previous literature).
I could probably get someone to help me do the format conversion using some automated system. @Simon Burton is already doing something like this for my Applied Category Theory Course, and that works quite well.
But I'm wondering if there are other frameworks for doing what I want.
You could fork the repo of the Stacks project or the Clowder project and customize it to your liking or use it as is.
I tried latexml recently, it converts latex to html.. This is what the arxiv is using to generate html pages for papers. It was looking pretty good, even though it involved a lot of fiddling with css files. But I gave up when I saw the output on commutative diagrams from tikzcd... Maybe it's worth pursuing, i found the developers on github quite helpful when i had problems..
I'm essentially ignorant of programming, and prefer to remain as close as possible to that state of ignorance, but will accept a certain amount of learning if necessary. For the Clowder project, it starts by saying
Requirements. This project uses Conda as Gerby requires
python3.6. It also requiresinkscapeformake picturesto run properly.
Then it describes the "initial setup". It doesn't say if the initial setup requires that I've first do something to get the "requirements", or whether the initial setup automatically gives me the requirements. I'm afraid I need to first do something to get the "requirements". I have no idea how to install python3.6 or inkscape. So do I need to learn that?
The Stacks project is even less clear about what I actually need to do.
Simon Burton said:
I tried latexml recently, it converts latex to html.. This is what the arxiv is using to generate html pages for papers
I used to use something called latex2html - it allowed me to easily create a website based on my paper "The octonions". The math symbols are stored as tiny gifs, and they don't look very good. But latex2html was very easy for an idiot like me to use, and the results were quite useful, at least to me.
The output of latexml looks a lot better, at least in some cases.
But I gave up when I saw the output on commutative diagrams from tikzcd...
For some books I might write, this wouldn't matter much. I don't mind creating one or two tikz pictures "by hand" for a website version of a book, and including them as jpegs. For other books, the number of tikz diagrams would be very large.
I'm also wondering if forester would be suitable. Is @Jon Sterling here?
What are the downsides of your system, the one we're using for Lectures in Applied Category Theory, @Simon Burton - apart from the fact that currently I rely on you every time I want to make a change? Presumably I could be trained to do that stuff myself?
(Jon Sterling left this Zulip a long time ago due to personal conflicts; he is allegedly easier to reach elsewhere.)
Morgan Rogers (he/him) said:
(Jon Sterling left this Zulip a long time ago due to personal conflicts; he is allegedly easier to reach elsewhere.)
He's fairly active on mathstodon, where I believe @John Baez also has an account.
John Baez said:
What are the downsides of your system, the one we're using for Lectures in Applied Category Theory
Well we never figured out how to get latex or pdf out of it... so that would be step 1 to try and get that to work...
(A big part of this is what file format do you write in, in this case it's some kind of markdown. For latexml it would be latex... )
Okay, I didn't notice we (= you) never managed to get latex or PDF out of it. For my book projects that will be essential.
A big part of this is what file format do you write in...
I'd prefer to write in something close to LaTeX. I can stomach using MathJax for equations and markdown for section headers, etc., and when I'm finished writing the book converting everything to pure LaTeX.
I should start by trying latexml.
A simple infrastructure produced these pages https://tetrapharmakon.github.io/species/
The repo is public https://github.com/tetrapharmakon/species for anyone who wants to clone and tinker
Pro: one can write arbitrary latex, yes, tikz; yes, quiver; yes, xymatrices; yes, whatever perversion one has can be impelemented. On the other hand, latexml has limitations
Con: it might be a tiny bit counterintuitive in the beginning, because there are idiomatic ways to place the image where you really want. Nothing that doesn't come natural after a couple days.
Btw, I will eventually continue writing those notes... it's been a while...
these images are plain tikz
produced as follows:
{% tex classes: [antex, display] %}
\begin{tikzpicture}
\draw (0,0) circle (1cm);
\draw[->] (70:1.15cm) arc (70:35:1.15cm);
\foreach[count=\j] \i in {4,3,2,1,0}{
\node[draw, fill=white, circle, inner sep=1pt] at (\i*360/5+90+72:1cm) {\footnotesize $x_{\j}$};
}
\begin{scope}[xshift=3cm]
\draw (0,0) circle (1cm);
\draw[->] (70:1.15cm) arc (70:35:1.15cm);
\foreach[count=\j] \i in {4,3,2,1,0}{
\node[draw, fill=white, circle, inner sep=1pt] at (\i*360/5+90:1cm) {\footnotesize $x_{\j}$};
}
\end{scope}
\begin{scope}[xshift=7cm]
\draw (0,0) circle (1cm);
% \draw[->] (70:1.15cm) arc (70:35:1.15cm);
\foreach[count=\j] \i in {0,1,2,3,4}{
\node[draw, fill=white, circle, inner sep=1pt] at (\i*360/5+90:1cm) {\footnotesize $x_{\j}$};
}
\end{scope}
\end{tikzpicture}
{% endtex %}
Another option that seems to be better documented is chirun. It also has a web-based frontend which may allow you to skip any coding (except what is necessary to publish the website you create).
Besides the stacks project, Lurie's Kerodon also uses Gerby. But the set-up instructions (eg here to clone the stack project) are really non-trivial.
I’ll mention pretext even though I don’t know a ton about it. https://pretextbook.org/
My understanding is that pretext is not actually written in latex, but rather some kind of XML, which is kind of a dealbreaker for me. (But if I'm wrong, someone please correct me.)
It would be great if we could assemble all the suggestions in this thread into a list that summarizes the pros and cons of each, not just for John but for others who might be interested (which might include me, someday). Perhaps on an nLab page?
Oh yeah, that would be a dealbreaker for me too.
John Baez said:
I'm essentially ignorant of programming, and prefer to remain as close as possible to that state of ignorance, but will accept a certain amount of learning if necessary. For the Clowder project, it starts by saying
Requirements. This project uses Conda as Gerby requires
python3.6. It also requiresinkscapeformake picturesto run properly.Then it describes the "initial setup". It doesn't say if the initial setup requires that I've first do something to get the "requirements", or whether the initial setup automatically gives me the requirements. I'm afraid I need to first do something to get the "requirements". I have no idea how to install python3.6 or inkscape. So do I need to learn that?
For Clowder you need to separately install Conda and inkscape, but python3.6 will be installed automatically when you run the make conda-create command.
I've tried documenting how to build it as much as I could; there's even a “GitHub action” that automatically compiles the website to here whenever a new update is pushed.
Still, I'd advise not using Gerby if you don't want to mess too much with code. As great as Gerby is, there is a HUGE amount of things you might end up needing to do =/
For Clowder specifically, I've essentially spent the last two months working on a fork of Gerby that would do everything I wanted it to, along with corresponding changes to the website.
Emily (she/her) said:
Still, I'd advise not using Gerby if you don't want to mess too much with code. As great as Gerby is, there is a HUGE amount of things you might end up needing to do =/
It's also relatively easy to break the project if you don't compile it often, and then if that happens you'll have no idea what you did that got Gerby to not compile...
Maybe using plain plasTeX could be a better solution. Gerby is a fork of it, but it's not well-maintained, so it's essentially something like 2 years behind plasTeX.
I think Forester might be another nicer alternative, I think Tim used it for translations here
I thought Forester was not LaTeX?
Regarding non-latex alternatives: in the long run, I'm very hopeful about typst. This is a LaTeX replacement with an HTML export feature under active development.
There's also github.com/slatex/RusTeX which has an option to compile LaTeX to xhtml
The group also has a webserver that you can run to serve the XHTML pages with mouseover and stuff like that, here's an example of a webpage written in LaTeX and compiled to XHTML using Rustex
https://mathhub.info/?uri=https%3A%2F%2Fmathhub.info%3Fa%3DPapers%2F22-CICM-Injecting-Formal-Mathematics%26d%3Dpaper%26l%3Den
the first thing that jumps out is the rich mouseover context, the previews of related pages
Eventually we'll be able to produce accessible tagged PDFs, from which web pages can be derived via something like ngPDF. This depends on the progress of the LaTeX tagging project; something that's also required as of this month for publishing ebooks in the EU/UK under the European Accessibility Act.
In case no one has mentioned this one: I've just started experimenting with a LaTeX package lwarp for a book-sized project. From the link:
"This package converts LATEX to HTML by using LATEX to process the user’s document and generate HTML tags. External utility programs are only used for the final conversion of text and images. Math may be represented by SVG files or MathJax. Hundreds of LATEX packages are supported, and their load order is automatically verified."
Do you have any opinions on lwarp, @Rich Hilliard?
It was simple to install. Seems to do fine on the usual stuff: text formatting, document organization, references and linking.
It supports various approaches to rendering math and diagrams. I haven't experimented with those enough yet to choose an approach.
Nathanael Arkor said:
I thought Forester was not LaTeX?
Forester is not LaTeX but it allows you to write arbitrary LaTeX, critically including general tikz or whatever other library-dependent code you want, in almost the way you’re used to. We’re using it a lot at Topos recently and it has a lot of great features including exporting to the Web by default and to ordinary LaTeX in a mostly automatic way, plus very flexible linking capabilities for writing in a modular way. I suspect it’s still “alpha” enough that John wouldn’t like it but I don’t think there’s anything clearly better yet.
@Owen Lynch you’ve thought hard about this, do you want to drop your opinions about the various options mentioned here and why you like Forester best?
By "use arbitrary LaTeX", you mean I can use packages like tabularray, etc. freely?
Screenshot 2025-07-03 at 1.24.00 PM.png
Yes, you can. Here's an excerpt from a note of David Jaz's in the real Topos forest where he typesets a type theory using mathpartir; I added an example from the tabularray docs to see that Forester has no issues with that library either. It just runs your real LaTeX installation on the requisite parts of your forester document, then inserts the result into the final .xml output as SVG (I don't know any details about this processing pipeline.)
The code looks something like this. It's a pretty analogous syntax to LaTeX, except for the somewhat annoying hygiene requirement to tag everything, including a paragraph of plain text, inside some backslash-and-braces macro.
\p{In this sketch, I will describe a simple type theory whose contexts are in one-to-one corresondence with [direct categories](djm-002L). I don't think it quite works as stated.}
\p{The rules are as follows: }
\tex{\usepackage{mathpartir}}{
\begin{mathpar}
\inferrule{\phantom{\bullet}}{\bullet \jctx }
\and \inferrule{\Gamma \yields A \jtype}{\Gamma, .x : A \yields x : A}
\and \inferrule{\Gamma \yields \mathcal{J}}{\Gamma, .x : A \yields \mathcal{J}} \\
\inferrule{\phantom{\bullet}}{\bullet : \Gamma \to \bullet} \and
\inferrule{\sigma : \Gamma \to \Delta \and \Delta \yields A \jtype \and \Gamma \yields t : A[\sigma]}{\sigma, x \gets t : \Gamma \to \Delta, .x : A} \\
\inferrule{\Gamma \yields A \jtype}{\Gamma, .x : A \jctx} \and
\inferrule{\sigma : \Gamma \to \Delta}{\Gamma \yields \Cone(\sigma) \jtype}
\end{mathpar}
}
\p{Here is a test of the tabulararray #{\LaTeX} package:}
\tex{\usepackage{tabularray}}{
\begin{tblr}{lccr}
\hline
Alpha & Beta & Gamma & Delta \\
\hline
Epsilon & Zeta & Eta & Theta \\
\hline
Iota & Kappa & Lambda & Mu \\
\hline
\end{tblr}
}
Jon's motivation in developing Forester was exactly to allow people to "build their own Stacks project in ten minutes", incidentally, and it's true that you can probably get an example running without needing to do anything that "feels like programming."
I will say that there are like 5 different "latex to html" "compilers" and each of them works for some undefined subset of LaTeX, and I think none of those subsets include tikz; I think the only reasonable way to get good quality typesetting of figures is just to shell out to LaTeX and Forester makes this especially easy. Forester has its quirks, but I think there isn't really a serious contender in its domain.
How many of these options have a way to insert additional code into the HTML output that isn't LaTeX? E.g. to embed an interactive javascript activity or exercise?
Forester can do that!
Also @John Baez I'd be happy to set up a website built with Forester for you.
Thanks a million for the offer, @Owen Lynch. I'm not quite ready to dive in, which will happen when I start writing my book on combinatorics and categories. A couple of questions:
This process is slightly involved, but also extremely customizable (e.g., it is more or less straightforward to add new environments, change the document class, translate html tables into latex tables, etc.)
It looks like lwarp is more full-featured than the other latex-to-html pipelines I've seen in the past though!
Quite impressive!
It looks like lwarp is a single three-megabyte source code file https://ctan.org/tex-archive/macros/latex/contrib/lwarp, which is 99,690 lines. I am in awe at the mind who can program like this.
@Mike Shulman lwarp defines LaTeX environments warpprint and warpHTML to direct specific content only to the generated print or web versions, respectively.
With warpHTML you could embed javascript in the HTML with <script>.
Owen Lynch said:
It looks like lwarp is a single three-megabyte source code file https://ctan.org/tex-archive/macros/latex/contrib/lwarp, which is 99,690 lines. I am in awe at the mind who can program like this.
There are also some 595 ancillary packages, as you can see in the documentation PDF, which is a bit longer than a Lurie book; it seems like you have one for making lwarp work with pretty much every TeX library (including tikz!) This might be easier for you to get started with, John, although it’s really amazingly enormous and I wonder whether the user usually gets to avoid all that complexity.
Since I couldn't get myself to read Lurie's books, there's no way I'll engage with a comparably large book just to learn a piece of software.
Surely that's just a reference manual and you wouldn't have to actually read it all to use the software?
I was just joking.
Apparently the html version of the Picturing Quantum Software book is made using make4ht ( another latex -> html converter ...)
That looks nice! I'm raring to go on this book.
(Hmm, that sounds like a very cowboy-ish expression, I wonder if non-Americans will understand it.)
Mike Shulman said:
My understanding is that pretext is not actually written in latex, but rather some kind of XML, which is kind of a dealbreaker for me. (But if I'm wrong, someone please correct me.)
I've started experimenting with PreTeXt, and it's actually fairly nice. The mathematics is straight-up LaTeX. The XML is only used for document structure such as sectioning, blocks, and lists; this is where LaTeX tends to use begin/end environments anyway, so the verbosity of XML is not that much greater, and appropriate editor tooling can automatically insert the ending tags for you.
The PreTeXt schema introduces a bit more verbosity, e.g. a theorem requires a <theorem> tag containing a <statement> tag containing a <p> tag before you can start stating the theorem, but that should also be automatable with a good editor (Emacs doesn't yet have such automation, as far as I can see, but I might do something about that if I continue using PreTeXt). And the reason for that verbosity is logical, since a <theorem> tag can also contain a <title> and a <proof>, which are then associated to the theorem by the XML structure and can be easily programmatically manipulated.
The XML-based design essentially forces you to separate semantics from presentation. There is no way to say within the schema "make this text 15 points tall and italics", only "here begins a section with this title". So it's not a replacement for (La)TeX as an engine for layout of printable documents. But all those things you can do with TeX are exactly the things that make it so hard to compile to other formats like HTML, so this is arguably a good thing.
PreTeXt produces HTML output that I think looks overall excellent, especially for textbooks (here are a couple examples), and the available semantic information can at least in principle improve accessibility to screen readers and so on. (And the PreTeXt people are thinking hard about this sort of thing -- for instance, you are instructed to put ending punctuation outside a display-math environment, because it is semantically not part of the mathematics and thus should be treated differently by non-visual output formats; but in visual output formats like PDF and HTML such punctuation is automatically moved to the end of the displayed mathematics, where it looks good, rather than at the beginning of the following line.) It can also be compiled to PDF by way of LaTeX, so the output looks like LaTeX since it is, and also to epub and kindle formats.
Personally, I prefer the "linear" presentation of a PreTeXt HTML document to the forester/stacks "atomized" approach, especially for something like a book that is "projected on a totally ordered way on the page axis" in the words of Serge Lang. For authoring purposes, you're free to split up your source code into multiple files as finely as you like to facilitate reorganization, using <xi:include> tags to stitch it together. Of course YMMV, but at the moment I'm happy enough with PreTeXt, compared to the alternatives I've seen, that I'm about to embark on a significant project using it.
Very helpful review, thanks Mike.
@John Baez how do you feel about qubit.guide? (note the download icon button that links to https://qubit.guide/qubit_guide.pdf and https://qubit.guide/qubit_guide_b5.pdf)
it's written in markdown but exports to pure LaTeX (which is used to automatically build those PDFs whenever we update the markdown files)
(sorry, haven't caught up with this thread yet, but just wanted to throw this out as another option if it hasn't already been mentioned)
Thanks, Tim. I don't feel anything (yet). But I will someday loop back to this topic and try to find the system that's the easiest for me to use.
@Mike Shulman you forgot to mention one of the main advantages of preText for me: that it can output Braille for people who have difficulties seeing. I expect that means that other alphabets are also easily covered. I wanted to use it, as many of the open source books recommended by AIM use it, but I lost my patience. glad you haven't.
I did mention "accessibility to screen readers and so on", but true I didn't mention Braille specifically.