Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package 'tikz-cd': incompatibility with equations #127

Open
iabarus opened this issue Jul 24, 2023 · 1 comment
Open

Package 'tikz-cd': incompatibility with equations #127

iabarus opened this issue Jul 24, 2023 · 1 comment

Comments

@iabarus
Copy link

iabarus commented Jul 24, 2023

LaTeX

\documentclass{article}
\usepackage{mathtools}
\usepackage{tikz-cd}
\begin{document}
\[
    \begin{tikzcd}[arrows=to]
        \cdots \rar & H_n(A \cap B) \rar & H_n(A) \oplus H_n(B) \rar & H_n(X) \rar 
    \end{tikzcd}
\]
\end{document}

make4ht

make4ht file.tex 'mathjax'
@michal-h21
Copy link
Owner

The problem here is that when you enclose TikZ environment in math, it won't get parsed by LaTeX and it will end verbatim in the output HTML. It is not something that can be fixed easily without modification of your source file.

What I would do is this: define a new environment which switches to the math mode by default, and then redefine it in the TeX4ht config file to start picture before switching to math. In this way, you will enforce creation of the picture.

Here is the TeX file:

\documentclass{article}
\usepackage{mathtools}
\usepackage{tikz-cd}
\newenvironment{pictenv}{\[}{\]}
\begin{document}
\begin{pictenv}
    \begin{tikzcd}[arrows=to]
        \cdots \rar & H_n(A \cap B) \rar & H_n(A) \oplus H_n(B) \rar & H_n(X) \rar & \hphantom{0}\\
        \hphantom{\cdots} \rar 
        & H_{n-1}(A \cap B) \rar 
        & \makebox[\widthof{$H_n(A) \oplus H_n(B)$}][c]{$\cdots\hfill \cdots$} \rar
        &  H_0(X) \rar & 0
    \end{tikzcd}
\end{pictenv}
\end{document}

The configuration file can look like this:

\Preamble{xhtml}
\renewenvironment{pictenv}{\Picture*{}$$}{$$\EndPicture}{}{}
\begin{document}
\EndPreamble

The \Picture*{}...\EndPicture code should force the image creation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants