DominikPeters / tikz.dev-issues

Feedback, suggestions, and bug reports for tikz.dev
1 stars 0 forks source link

Incorrect tikzpicture size when using dvisvgm output driver #22

Closed csevast closed 9 months ago

csevast commented 9 months ago

Hi, I want to produce an SVG file with a node shape, e.g. rectangle. I use the following LaTeX code:

\usepackage[usenames]{color}
\pagestyle{empty}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\begin{document}
  \pagecolor{white}%
  \begin{tikzpicture}
    \node (start) [draw, rectangle, minimum width=24mm, minimum height=16mm] {How are you?};
  \end{tikzpicture}
\end{document}

and then I use xelatex and then dvisvgm to produce the SVG file: xelatex -no-pdf -interaction nonstopmode -output-directory .\ test1.tex & dvisvgm -n -o .\test1.svg test1.xdv

Unfortunately, the produced SVG file has a background object with larger width than the width of the rectangle, resulting in a TikZ picture with larger width. The width is depended on the text width, i.e., if the text is short, the resulting background object width is not longer than the rectangle width, and there is no problem. But when the text width is longer than some critical length, the tikzpicture width is not the same as the drawn object width. Also, I noticed the same problem with the height. In the following example, the problem appears on the top of the tikzpicture:

\usepackage[usenames]{color}
\pagestyle{empty}             % do not remove
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\begin{document}
  \pagecolor{white}%
  \begin{tikzpicture}
    \node (point1) [coordinate];
    \node at (0,-3cm) (start) [draw, rectangle, minimum width=24mm, minimum height=16mm] {How are you?};
    \draw (point1) -- (start);
  \end{tikzpicture}
\end{document}

with the following command to be executed: xelatex -no-pdf -interaction nonstopmode -output-directory .\ test3.tex & dvisvgm -n -o .\test3.svg test1.xdv

I am using: Windows 11 MiKTeX-XeTeX 4.10 (MiKTeX 23.5) dvisvgm 3.0.4 pgf 3.1.10

Thank you for your support.

test1 test3 files.zip

DominikPeters commented 9 months ago

Sorry, I don't think this is the right forum for asking this. Maybe try stackexchange.

csevast commented 9 months ago

I was thinking that the problem is a bug of dvisvgm output driver and not a TikZ syntax problem.

DominikPeters commented 9 months ago

I don't have anything to do with dvisvgm, I only maintain the html version of the tikz manual :)

csevast commented 9 months ago

I am sorry, I was mixed with the repositories.