brucemiller / LaTeXML

LaTeXML: a TeX and LaTeX to XML/HTML/ePub/MathML translator.
http://dlmf.nist.gov/LaTeXML/
Other
924 stars 98 forks source link

tikz-cd.sty support #1280

Closed l8l closed 7 months ago

l8l commented 4 years ago

For all sorts of diagrams in mathematics, the latex tikz-cd package (distinct from tikz), is extremely useful. As can be seen here, it is one of the most used packages for which there is no binding yet.

I provide below the code of a minimal example that I would like to be able to convert into html (format html5 with mathml (including a mathjax fallback option) or mathsvg)

\documentclass[12pt]{article}

\usepackage{amsmath}
\usepackage{tikz-cd}

\begin{document}

\title{LaTeXML with tikz-cd}
\maketitle

\begin{abstract}
This is a sample LaTeXML document with a missing binding for the tikz-cd package.
\end{abstract}

\section{First Section}

Here is a typical tikz-cd graph:
\begin{equation}
  \begin{tikzcd}
        A \ar{r}{\phi} \ar{d}{a} \ar{dr}{b} & B \\
        C & D
  \end{tikzcd}
\end{equation}

\end{document}

As I said, it would already be fine/very useful if latexml would be able to convert all the graphs into svg-images and include them on the html site, even when the rest of the equations are in the format mathml. I suppose that this should be easier than a complete mathml support for graphs because one could write a macro that compiles the diagram as a standalone and then includes the svg automatically at the right place.

In case it helps, I also provide below the code for a minimal standalone latex document that produces (upon compilation with latex) the graph as a single pdf document:

\documentclass[tikz, preview]{standalone}
\usepackage{amsmath,amssymb,amsfonts}
% any other macros or packages that might affect the diagram
\usepackage{tikz-cd}
\begin{document}
\begin{equation}
  \begin{tikzcd}
        A \ar{r}{\phi} \ar{d}{a} \ar{dr}{b} & B \\
        C & D
  \end{tikzcd}
\end{equation}
\end{document}

Thanks a lot.

dginev commented 3 years ago

One early comment I will make for this issue is that on my (hopefully vanilla) texlive 2019 I am seeing tikz-cdrelying on a pgf version 3 library tikzlibraryarrows.meta.code.tex, which isn't installed on my system. So this should be something we visit after we have baseline tikz working on a texlive 2020, and maybe we can achieve a direct reliance on the pgf kernel with little binding intervention for tikz-cd.

dginev commented 3 years ago

The build log of the first example looks much better after the latest merge of #1413 .

What seems required next is an upgrade to latexml's treatment of halign, (discussed some time back e.g. in #760, and now on our mid-term roadmap. We should be able to implement a range of features and bindings once we ship that upgrade, tikz-cd and xy being two big beneficiaries.

dginev commented 2 years ago

Update: tikz-cd support is one of the most vocally requested packages from the ar5iv announcement period.

In addition, a doctoral candidate who has completed their thesis tried out latexml and reported back on twitter with tikz-cd as one of the most "dangeours" missing pieces, i.e. one of the most likely to cause errors/fatals.

Side-note: They also ran into a pgf Fatal that was already patched in the github head branch, so we may also consider a 0.8.7 release at some recent point.