I am really loving make4ht
and tex4ht
, as they finally allow me to keep all of my tooling while generating web pages. One minor issue I am running into has to do with the kerning of some characters while in math mode. So if I have a tikz
image, I am getting things that look like this.
In the image below, you can see that the sigma
character is too close to the frame of the vector, and that the underbrace is a little off from the array as well.
In the corresponding pdf output, these issues don't exist. Now I could just add some spaces or something as a workaround, but wanted to check and see if there is anything that I might be doing wrong or any simple fixes. Could this be some sort of CSS issue?
Note, I can supply additional examples of this if it would be helpful.
UPDATED
I am including a full example. This was the code that regenerates the issue.
First, here isthe command string that I used:
make4ht -d html -f html5+latexmk_build -s mydevfile.tex
Here is the myconfig.cfg
\Preamble{xhtml,mathjax}
\Configure{@BODY}{\IgnorePar
\HCode{\detokenize{\(}}
\special{t4ht*<mymacros.tex}
\HCode{\detokenize{\)}}
\par
}
\begin{document}
\EndPreamble
The mymacros.tex
file:
\def\RRRR{{\bf R}}
\newcommand\bface[1]{{\mathbf #1}}
\newcommand\grid[3]{
\begin{tikzpicture}[baseline=(current bounding box)]
\foreach \x in {1,...,#2} {
\foreach \y in {1,...,#1} {
\draw[fill=#3, color=#3] ($(0.4*\x, 0.4*\y)$) circle[radius=0.15cm];
}
}
\draw (0.2, 0.2) rectangle ($(0.4*#2, 0.4*#1) + (0.2, 0.2)$);
\end{tikzpicture}
}
\renewcommand{\vec}[1]{\mathbf{#1}}
The mymacros.sty
file:
\ProvidesPackage{mymacros}
\input{mymacros.tex}
\endinput
Finally, here is a minimal latex document, mydevfile.tex
:
\documentclass[12pt, a4paper, oneside, headinclude, footinclude]{article}
\ifdefined\HCode
\def\pgfsysdriver{pgfsys-dvisvgm4ht.def}
\fi
\usepackage{tikz}
\usetikzlibrary{shapes.multipart, positioning, decorations.markings,
arrows.meta, calc, fit}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage{mymacros}
\title{\normalfont\spacedallcaps{My doc}}
\author{\spacedlowsmallcaps{kb}}
\date{\today\\version 0.1}
\begin{document}
\pagestyle{scrheadings}
\maketitle
\setcounter{tocdepth}{2}
\tableofcontents
\section*{First Section}
\[
\RRRR = \bface{x}
\]
Some simple text.
\[
\underbrace{\grid{10}{1}{red}}_{\mathbf{\hat{x}}} =
\sigma \left( \underbrace{\grid{10}{5}{blue}}_{\mathbf{u}^\top}
\sigma \left( \underbrace{\grid{5}{2}{blue}}_{\mathbf{w}^\top}
\sigma \left(\underbrace{\grid{2}{5}{blue}}_{\mathbf{U}}
\sigma\left( \underbrace{\grid{5}{10}{blue}}_{\mathbf{V}}
\underbrace{\grid{10}{1}{red}}_{x}\right)\right) \right) \right)
\]
\end{document}