
下面的MWE說明了這個問題:連接的填充區域之間有一個小間隙,背景將顯示在其中(請參見帶有紅色標記的放大圖)
\documentclass{scrartcl}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\pagecolor{green}
\begin{tikzpicture}[node distance=1mm and 6mm]
\node (b1) [text width=10mm, text height=10mm,fill=white]{};
\node (b2) [text width=10mm, text height=10mm,fill=black,right=of b1]{};
\fill[black] (b1.north east) -- (b2.north west) -- (b2.south west) -- (b1.south east) -- cycle;
\end{tikzpicture}
\end{document}
如何避免在填滿區域之間出現背景影像?
答案1
你必須使之outer sep
等於零。
\documentclass{scrartcl}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\pagecolor{green}
\begin{tikzpicture}[node distance=1mm and 6mm]
\node (b1) [text width=10mm, text height=10mm,fill=white,outer sep=0pt]{};
\node (b2) [text width=10mm, text height=10mm,fill=black,right=of b1,outer sep=0pt]{};
\fill[black] (b1.north east) -- (b2.north west) -- (b2.south west) -- (b1.south east) -- cycle;
\end{tikzpicture}
\end{document}