下面的 MWE 生成了电弧炉和钢包炉的 TikZ 图纸,其中充满了自定义图案。在 TeXstudio 中,它们看起来正是我想要的样子——线条粗细正确,图案完全填充了形状:
但是,当我在其他各种程序中查看相同的 PDF 时,它们的外观最多只能算是不好看,图案线的叠加会导致一些难看的伪影。我很想听听一些建议,关于如何保证我的 TikZpictures 能够正确显示,或者至少能够一致显示,也许可以通过一些代码调整。
福祉PDF阅读器:
线条粗细没有差异,图案没有完全填充形状。
火狐浏览器:
线条粗细有些正确,但有一个形状根本没有填充图案。
Microsoft Edge:
线条粗细也有些正确,但形状未完全填充。
梅威瑟:
\documentclass[margin=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,shadings,patterns,intersections}
\usepackage{tikzpagenodes}
\makeatletter
\tikzset{% customization of pattern
hatch distance/.store in=\hatchdistance,
hatch distance=5pt,
hatch thickness/.store in=\hatchthickness,
hatch thickness=5pt
}
\pgfdeclarepatternformonly[\hatchdistance,\hatchthickness]{north east hatch}% name
{\pgfqpoint{-1pt}{-1pt}}% below left
{\pgfqpoint{\hatchdistance}{\hatchdistance}}% above right
{\pgfpoint{\hatchdistance-1pt}{\hatchdistance-1pt}}%
{
\pgfsetcolor{\tikz@pattern@color}
\pgfsetlinewidth{\hatchthickness}
\pgfpathmoveto{\pgfqpoint{0pt}{0pt}}
\pgfpathlineto{\pgfqpoint{\hatchdistance}{\hatchdistance}}
\pgfusepath{stroke}
}
\pgfdeclarepatternformonly[\hatchdistance,\hatchthickness]{north west hatch}% name
{\pgfqpoint{-1pt}{-1pt}}% below left
{\pgfqpoint{-\hatchdistance}{\hatchdistance}}% above right
{\pgfpoint{\hatchdistance-1pt}{\hatchdistance-1pt}}%
{
\pgfsetcolor{\tikz@pattern@color}
\pgfsetlinewidth{\hatchthickness}
\pgfpathmoveto{\pgfqpoint{0pt}{0pt}}
\pgfpathlineto{\pgfqpoint{-\hatchdistance}{\hatchdistance}}
\pgfusepath{stroke}
}
\makeatother
\begin{document}
\begin{tikzpicture}[thick,rounded corners=0.2mm]
\draw[pattern=north east hatch, hatch distance=2mm, hatch thickness=0.05mm] (0,0) coordinate(startpunkt1) --++(15mm,0) --++(0,8mm) .. controls ++(10mm,6mm) and ++(-10mm,0) .. ++(31mm,7mm) coordinate(mitteoben).. controls ++(10mm,0) and ++(-10mm,6mm) .. ++(31mm,-7mm) --++(0,-8mm) coordinate(schlackeobenR) --++(-5mm,0) coordinate(schlackeobenL) --++(0,6mm) .. controls ++(-10mm,5mm) and ++(5mm,0) .. ++(-26mm,5mm) .. controls ++(-5mm,0) and ++(10mm,5mm) .. ++(-26mm,-5mm) --++(0mm,-9mm) --++(-20mm,0) coordinate(abstichoben)-- cycle;
\draw[pattern=north east hatch, hatch distance=2mm, hatch thickness=0.05mm] (startpunkt1) ++(0,-8mm) coordinate(abstichunten) .. controls ++(25mm,-10mm) and ++(-20mm,0mm) .. ++(45mm,-14mm) coordinate(mitteunten) .. controls ++(20mm,0mm) and ++(-2mm,-1mm) .. ++(27mm,8mm) --++(0,6mm) coordinate(schlackeuntenL) --++(5mm,0) coordinate(schlackeuntenR) --++(0,-8mm) .. controls ++(-10mm,-8mm) and ++(10mm,0) .. ++(-31mm,-11mm) .. controls ++(-16mm,0) and ++(25mm,-12mm) .. ++(-46mm,17mm) -- cycle;
\draw[rounded corners=0mm] (schlackeobenL) -- (schlackeuntenL) -- (schlackeuntenR) -- (schlackeobenR) -- cycle;
\draw[rounded corners=0mm] (abstichoben)++(0,1mm) --++(0,-7mm);
\foreach\i in {-10,0,10}{%
\draw[fill=white] (mitteoben)++(-2mm,10mm)++(\i mm,0) rectangle ++(4mm,-33mm);
}
\end{tikzpicture}
\begin{tikzpicture}[thick,rounded corners=0.2mm]
\draw[name path=pfanne,pattern=north east hatch, hatch distance=2mm, hatch thickness=0.05mm] (0,0) coordinate(startpunkt1) --++(18mm,0) --++(6mm,46mm) coordinate (obenrechts) --++(-3mm,0) --++(-5.6mm,{-46mm/6*5.6}) coordinate (eckeuntenrechts) --(startpunkt1 |-,|- eckeuntenrechts)
(startpunkt1) --++(-18mm,0) --++(-6mm,46mm) coordinate (obenlinks) --++(3mm,0) --++(5.6mm,{-46mm/6*5.6}) coordinate (eckeuntenlinks) --(startpunkt1 |-,|- eckeuntenlinks);
\draw[pattern=north west hatch, hatch distance=2mm, hatch thickness=0.05mm] (obenlinks) ++(0,1.7mm) coordinate(startpunkt2) --++(0,1.5mm) --++(5mm,0) --++(9mm,3mm) coordinate(deckellinksoben) --(startpunkt1 |-,|- deckellinksoben) --++(0,-3mm) coordinate (deckelrechtsunten) -- (deckellinksoben |-,|- deckelrechtsunten) --++(-9mm,-3mm) --++(-5mm,0) --(startpunkt2)
(obenrechts) ++(0,1.7mm) coordinate(startpunkt3) --++(0,1.5mm) --++(-5mm,0) --++(-9mm,3mm) coordinate(deckelrechtsoben) --(startpunkt1 |-,|- deckelrechtsoben) --++(0,-3mm) coordinate (deckelrechtsunten2) -- (deckelrechtsoben |-,|- deckelrechtsunten2) --++(9mm,-3mm) --++(5mm,0) --(startpunkt3);
\path[name path=auxobenlinks] (startpunkt1) ++(-30mm,37mm) --++(20mm,0);
\path[name path=auxobenrechts] (startpunkt1) ++(30mm,37mm) --++(-20mm,0);
\path[name path=auxuntenlinks] (startpunkt1) ++(-30mm,34mm) --++(20mm,0);
\path[name path=auxuntenrechts] (startpunkt1) ++(30mm,34mm) --++(-20mm,0);
\coordinate[name intersections={of=auxobenlinks and pfanne,by=collideobenlinks}];
\coordinate[name intersections={of=auxobenrechts and pfanne,by=collideobenrechts}];
\coordinate[name intersections={of=auxuntenlinks and pfanne,by=collideuntenlinks}];
\coordinate[name intersections={of=auxuntenrechts and pfanne,by=collideuntenrechts}];
\draw (collideobenlinks) --++(-4mm,0) coordinate (auxlinks);
\draw (collideuntenlinks) -- (auxlinks |-,|- collideuntenlinks);
\draw (collideobenrechts) --++(4mm,0) coordinate (auxrechts);
\draw (collideuntenrechts) -- (auxrechts |-,|- collideuntenrechts);
\draw (auxlinks) ++(0,1mm) rectangle ++(-1mm,-5mm);
\draw (auxrechts) ++(0,1mm) rectangle ++(1mm,-5mm);
\foreach\i in {-8,0,8}{%
\draw[fill=white,opacity=1] (startpunkt1)++(-2mm,67mm)++(\i mm,0) rectangle ++(4mm,-33mm);
}
\end{tikzpicture}
\end{document}