Category Theory
Zulip Server
Archive

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.


Stream: community: general

Topic: Writing a book in LaTeX on the web


view this post on Zulip John Baez (Jul 02 2025 at 11:18):

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.

view this post on Zulip Ralph Sarkis (Jul 02 2025 at 11:26):

You could fork the repo of the Stacks project or the Clowder project and customize it to your liking or use it as is.

view this post on Zulip Simon Burton (Jul 02 2025 at 11:44):

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..

view this post on Zulip John Baez (Jul 02 2025 at 11:46):

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 requires inkscape for make pictures to 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?

view this post on Zulip John Baez (Jul 02 2025 at 11:47):

The Stacks project is even less clear about what I actually need to do.

view this post on Zulip John Baez (Jul 02 2025 at 11:52):

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.

view this post on Zulip Simon Burton (Jul 02 2025 at 12:03):

I'm also wondering if forester would be suitable. Is @Jon Sterling here?

view this post on Zulip John Baez (Jul 02 2025 at 12:12):

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?

view this post on Zulip Morgan Rogers (he/him) (Jul 02 2025 at 12:22):

(Jon Sterling left this Zulip a long time ago due to personal conflicts; he is allegedly easier to reach elsewhere.)

view this post on Zulip daniel gratzer (Jul 02 2025 at 12:35):

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.

view this post on Zulip Simon Burton (Jul 02 2025 at 12:36):

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... )

view this post on Zulip John Baez (Jul 02 2025 at 13:08):

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.

view this post on Zulip John Baez (Jul 02 2025 at 13:08):

I should start by trying latexml.

view this post on Zulip fosco (Jul 02 2025 at 13:37):

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...

view this post on Zulip fosco (Jul 02 2025 at 13:38):

these images are plain tikz

image.png

view this post on Zulip fosco (Jul 02 2025 at 13:39):

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 %}

view this post on Zulip Ralph Sarkis (Jul 02 2025 at 13:48):

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).

view this post on Zulip Jonas Frey (Jul 02 2025 at 14:14):

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.

view this post on Zulip Joe Moeller (Jul 02 2025 at 17:00):

I’ll mention pretext even though I don’t know a ton about it. https://pretextbook.org/

view this post on Zulip Mike Shulman (Jul 02 2025 at 17:02):

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.)

view this post on Zulip Mike Shulman (Jul 02 2025 at 17:03):

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?

view this post on Zulip Joe Moeller (Jul 02 2025 at 17:06):

Oh yeah, that would be a dealbreaker for me too.

view this post on Zulip Emily (she/her) (Jul 02 2025 at 17:31):

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 requires inkscape for make pictures to 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.

view this post on Zulip Emily (she/her) (Jul 02 2025 at 17:31):

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.

view this post on Zulip Emily (she/her) (Jul 02 2025 at 17:31):

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 =/

view this post on Zulip Emily (she/her) (Jul 02 2025 at 17:32):

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.

view this post on Zulip Emily (she/her) (Jul 02 2025 at 17:32):

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...

view this post on Zulip Emily (she/her) (Jul 02 2025 at 17:32):

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.

view this post on Zulip Emily (she/her) (Jul 02 2025 at 17:33):

I think Forester might be another nicer alternative, I think Tim used it for translations here

view this post on Zulip Nathanael Arkor (Jul 02 2025 at 17:38):

I thought Forester was not LaTeX?

view this post on Zulip Jonas Frey (Jul 02 2025 at 18:18):

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.

view this post on Zulip Patrick Nicodemus (Jul 03 2025 at 01:15):

There's also github.com/slatex/RusTeX which has an option to compile LaTeX to xhtml

view this post on Zulip Patrick Nicodemus (Jul 03 2025 at 01:18):

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

view this post on Zulip Patrick Nicodemus (Jul 03 2025 at 01:19):

the first thing that jumps out is the rich mouseover context, the previews of related pages

view this post on Zulip Ulrik Buchholtz (Jul 03 2025 at 09:12):

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.

view this post on Zulip Rich Hilliard (Jul 03 2025 at 13:40):

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."

view this post on Zulip John Baez (Jul 03 2025 at 14:04):

Do you have any opinions on lwarp, @Rich Hilliard?

view this post on Zulip Rich Hilliard (Jul 03 2025 at 14:51):

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.

view this post on Zulip Kevin Carlson (Jul 03 2025 at 17:10):

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.

view this post on Zulip Kevin Carlson (Jul 03 2025 at 17:10):

@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?

view this post on Zulip Nathanael Arkor (Jul 03 2025 at 19:54):

By "use arbitrary LaTeX", you mean I can use packages like tabularray, etc. freely?

view this post on Zulip Kevin Carlson (Jul 03 2025 at 20:29):

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.)

view this post on Zulip Kevin Carlson (Jul 03 2025 at 20:30):

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}
}

view this post on Zulip Kevin Carlson (Jul 03 2025 at 20:31):

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."

view this post on Zulip Owen Lynch (Jul 03 2025 at 20:33):

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.

view this post on Zulip Mike Shulman (Jul 03 2025 at 20:57):

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?

view this post on Zulip Owen Lynch (Jul 03 2025 at 21:24):

Forester can do that!

view this post on Zulip Owen Lynch (Jul 03 2025 at 21:27):

Also @John Baez I'd be happy to set up a website built with Forester for you.

view this post on Zulip John Baez (Jul 04 2025 at 09:54):

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:

view this post on Zulip Owen Lynch (Jul 04 2025 at 09:58):

view this post on Zulip Owen Lynch (Jul 04 2025 at 10:15):

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.)

view this post on Zulip Owen Lynch (Jul 04 2025 at 10:18):

It looks like lwarp is more full-featured than the other latex-to-html pipelines I've seen in the past though!

view this post on Zulip Owen Lynch (Jul 04 2025 at 10:18):

Quite impressive!

view this post on Zulip Owen Lynch (Jul 04 2025 at 10:22):

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.

view this post on Zulip Rich Hilliard (Jul 04 2025 at 11:09):

@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>.

view this post on Zulip Kevin Carlson (Jul 04 2025 at 17:48):

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.

view this post on Zulip John Baez (Jul 04 2025 at 18:11):

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.

view this post on Zulip Mike Shulman (Jul 04 2025 at 20:00):

Surely that's just a reference manual and you wouldn't have to actually read it all to use the software?

view this post on Zulip John Baez (Jul 04 2025 at 20:23):

I was just joking.

view this post on Zulip Simon Burton (Jul 07 2025 at 14:09):

Apparently the html version of the Picturing Quantum Software book is made using make4ht ( another latex -> html converter ...)

view this post on Zulip John Baez (Jul 07 2025 at 14:13):

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.)