Closed Iey4iej3 closed 4 years ago
This issue seems to be caused by this command:
\fill[pattern=north east lines,pattern color=gray,opacity=0.5]
(2,8) -- (2,5) -- (5,5) -- (5,3) -- (6,3) -- (6,2) -- (8,2) -- (8,8);
I hope it was fixed by the last commit: 9ec3171. I don't remember why I used dvips
driver instead of dvisvgm
. I guess there were some issues, so it is possible that other TikZ images will fail. Please test it, if you have more examples.
The image shows but it is truncated. I opened the svg
file, it is also truncated. You can compile it with pdflatex
and compare the result, see the leftmost column.
Ah I can see it. It isn't truncated when I load the dvips
driver, but the conversion fails when the pattern is used then. I guess similar issue in the past was the reason to use dvips
driver instead of dvisvgm
. I need to investigate this more.
You can try this version of pgfsys-dvisvgm4ht.def
. It seems to not crop the image:
% Copyright 2006 by Till Tantau
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.
%
% See the file doc/generic/pgf/licenses/LICENSE for more details.
% Driver commands for tex4ht
%
% Load common pdf commands:
%
\input pgfsys-dvisvgm.def
%\input pgfsys-dvips.def
\AtBeginDocument{
% configure the output picture format to svg
\Configure{Picture}{.svg}
% insert tex4ht hook to the code used at the start and end of each TikZ picture
\def\pgfsys@beginpicture{%
\bgroup%
\ifdefined\inside@pict@cmd% handle nested uses
\def\run@pict@cmd{}% insert the \Picture hooks only in the top nesting level
\def\end@pict@cmd{}%
\else
% use different version of \Picture depending on the vertical mode
\ifvmode\def\run@pict@cmd{\Picture*}\else\def\run@pict@cmd{\Picture+}\fi%
\def\end@pict@cmd{\EndPicture}%
\fi%
% command used to detect nesting
\def\inside@pict@cmd{}%
\csname a:tikzpicture\endcsname%
\orig@pgfsys@begin%
}%
\def\pgfsys@endpicture{%
\orig@pgfsys@end%
\csname b:tikzpicture\endcsname%
\egroup%
\par%
}%
\ConfigureEnv{tikzpicture}{\ifvmode\Picture*{}\else\Picture+{}\fi\def\inside@pict@cmd{}}{\EndPicture}{}{}
}
% Make the code inserted by tex4ht configurable
\NewConfigure{tikzpicture}{2}
\Configure{tikzpicture}{%
% \ifvmode\IgnorePar\fi\EndP%\HtmlParOff
\protect\csname nested:math\endcsname% support display math
\run@pict@cmd{}%
}{\end@pict@cmd}
\let\orig@pgfsys@begin\pgfsys@beginpicture
\let\orig@pgfsys@end\pgfsys@endpicture
\def\pgf@sys@postscript@header#1{{\special{! #1}}}
\endinput
%%% Local Variables:
%%% mode: latex
%%% End:
That seems working (I tried another tikz
picture).
Seemingly this does not work for tikz-cd
. Sample code:
\documentclass{amsart}
% Include the following code before \usepackage{tikz}
\ifdefined\HCode
\def\pgfsysdriver{pgfsys-dvisvgm4ht.def}
\fi
\usepackage{tikz}
\usepackage{tikz-cd}
\DeclareMathOperator\HH{HH}
\DeclareMathOperator\HP{HP}
\DeclareMathOperator\myH{H}
\DeclareMathOperator\dR{dR}
\begin{document}
Look at
\[
\begin{tikzcd}
(R_1,M_1) \rar[shift left,"f"]\rar[shift right,"g"'] & (R_0,M_0) \lar\rar & (R,M)
\end{tikzcd}
\]
and
\begin{tikzcd}
&\HH_*(X/k)\arrow[Rightarrow]{dr}{\text{Tate}}&\\
\myH^*(X,\Omega^*_X)\arrow[Rightarrow]{ur}{\text{HKR}}\arrow[Rightarrow]{dr}[swap]{\text{Hodge--de Rham}}&&\HP_*(X/k)\\
&\myH^*_{\dR}(X/k)\arrow[Rightarrow]{ur}[swap]{\text{de Rham--HP}}&
\end{tikzcd}
\end{document}
Both images are broken (strange enough, the images in this extracted form are broken differently from those integrated in the original ebook).
I hope it is fixed by the last commit. But please test it also with other files.
Seemingly working, except: is it expected that if I enable \usepackage{todonotes}
, then the generated SVG is incorrect? I tested the preamble and found that it is this package which leads to a problem.
@Iey4iej3 maybe you use todonotes
before \def\pgfsysdriver{pgfsys-dvisvgm4ht.def}
? It loads TikZ, but with wrong driver if it is used earlier.
Thanks for clarifications.
MWE
Remark
I try to manipulate
dvisvgm
manually, and getPostScript error: undefined in pgfpat3
.