mgieseki / dvisvgm

A fast DVI, EPS, and PDF to SVG converter
https://dvisvgm.de
GNU General Public License v3.0
310 stars 34 forks source link

[BUG] Regular polygon problem #189

Closed VincentTam closed 2 years ago

VincentTam commented 2 years ago

Background

I'm using the same setup as in my previous issues.

Goal

Draw a regular polygon with n vertices marked with a circular dot and a label Vₖ with k = 1,…,n.

Input

\documentclass[tikz]{standalone}
\usetikzlibrary{calc}
\begin{document}
\newcommand\myR{2}
\newcommand\n{7}
\newcommand\dTheta{360/\n}
\tikzset{
  every pin edge/.style={opacity=0},
  pin distance=2pt,
  mypt/.style={circle,fill=black,minimum size=0.5pt,inner sep=-2pt},
}
\begin{tikzpicture}
\foreach \k in {1,...,\n} {\coordinate[mypt,pin={\dTheta*\k}:{$V_{\k}$}] (V\k) at ({\dTheta*\k}:\myR);}
\foreach \k in {2,...,\n} {\draw (V\the\numexpr\k-1) -- (V\k);}
\draw (V7) -- (V1);
\end{tikzpicture}
\end{document}

Use latex 220627-reg-n-gon and dvisvgm 220627-reg-n-gon to generate the SVG file. ℹ️ I removed --no-fonts to simplify the above command.

Actual output

actual output

Expected output

VS code PDF output

Problem

How can I get the expected output?

mgieseki commented 2 years ago

The problem is most likely caused by a Ghostscript version that is too old. Your example makes use of transparency settings which require at least GS 9.52. All previous versions don't provide the interface to access the transparency operators from external applications like dvisvgm. If you use the GS library coming with MiKTeX which is based on GS 9.25, then that's the reason. In this case you need to install a newer GS version. Alternatively, you can specify document class option dvisvgm to embed SVG instead of PS specials into the DVI file.

VincentTam commented 2 years ago

thanks for reply. i'm using GS 9.52 the came with MikTeX. image

mgieseki commented 2 years ago

thanks for reply. i'm using GS 9.52 the came with MikTeX.

Nope, it's 9.25. 😃 As mentioned above, this version is too old to process the PS specials in your example.

VincentTam commented 2 years ago

oops nice catch! thx for your alternative. it's really helpful. it seems that there's more config work in the first approach and i really wish to deal with other stuff (like learning TikZ 3D and animation). image

mgieseki commented 2 years ago

Using a different GS version is pretty easy. Just install Ghostscript 9.55.0, for example, and assign the absolute file path of gsdll64.dll (if you use the 64-bit MiKTeX) or gsdll32.dll to environment variable LIBGS. That's it.

VincentTam commented 2 years ago

thx again.

image

image