dvisvgm Guide for TikZ Pictures with Pattern Filling

A quick note of the right commands for the conversion

Problem

I had issues in getting a SVG from a TikZ picture containing a pattern filling: https://github.com/mgieseki/dvisvgm/issues/158. The reported issue was created last year, and it’s marked as fixed. Nonetheless, I had this issue even though my MikTeX was up-to-date.

Discussion

  1. I wanted to confirm whether my dvisvgm.exe, which had been shipped with MikTeX, was latest.
  2. I gave a MWE illustrating the problem with the graph of y = (x + 1)² with region under the curve filled with a pattern in the above issue. I knew that’s probably off-topic, but the package owner might have some insights about the problem. It turned out that PDF → SVG was partly supported by dvisvgm. Using DVI → SVG, I managed to get the filling pattern, but I lost the beautiful Computer Modern Roman fonts—that’s another issue.
  3. Hoping for a response from the owner for the previous problem, I started https://github.com/mgieseki/dvisvgm/issues/186. He suggested the use of --no-fonts or --font-format=woff. I observed no difference in the local filesystem. I uploaded everything I got through GitHub so that he could see what my dvisvgm.exe had output. I didn’t expected that the Computer Modern Roman fonts disappeared on GitHub side. If I hadn’t asked there, I would have never known that it’s the web browser’s security measure not to load the embedded font data in a SVG loaded from a server.

Skills learned

Meaning of some commonly used parameters of dvisvgm:

[Read More]
LaTeX  dvisvgm  SVG 

Dvisvgm's Issue With Fill Pattern

Goal

Generate SVG file for TikZ graphics.

Method

  1. TeX → PDF with PDFLaTeX
  2. PDF → SVG with dvisvgm -P filename

Example: I generated a PGF plot from the source code on my personal template.

working SVG
working PDF
Git Bash for PDF
Git Bash for SVG

Problem

When I applied this method to the following TeX code in my previous post, dvisvgm -P returns a blank SVG.

\documentclass[tikz,border=2pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.6}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis lines=center,legend style={at={(0.7,0.7)},anchor=south west}]
\addplot [domain=-3:3, thick, smooth, yellow] { 1/sqrt(2*pi)*exp(-x^2/2) };
\addlegendentry{$y = \frac{1}{\sqrt{2\pi}} e^{-x^2/2}$};
\addplot [dashed, yellow] coordinates {(1.5,0) (1.5,0.14)};
\addlegendentry{99th percentile};
\addplot[domain=-3:1.5, pattern=north east lines,draw=none, fill opacity=0.3]
  { 1/sqrt(2*pi)*exp(-x^2/2) } \closedcycle;
\end{axis}
\end{tikzpicture}
\end{document}

This code passes the compiler.

[Read More]
LaTeX  dvisvgm  SVG