在绘制一个简单的 3D(实际上是假 3D)立方体时,我意识到角落最终会出现不必要的线条延伸。我知道这与线条本身的宽度有关,但我该如何去除它们?也欢迎绘制所需图形的替代解决方案。
例子:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[draw=black,fill=gray!20] (0,0) --(4.8,0)-- (4.8,5)--(0, 5)--cycle;
\draw[draw=black,fill=gray!20] (4.8,5) -- (4.9,4.8)--(4.9,-0.1)--(4.8,0)--cycle;
\draw[draw=black,fill=gray!20] (0,0) -- (0.1,-0.1)--(4.9,-0.1)--(4.8,0)--cycle;
\draw[dashed,draw=black] (4.8,5) -- (4.9,4.8)--(0.1,4.8)--(0.,5)--cycle;
\draw[dashed,draw=black] (0.1,-0.1)--(0.1,4.8)--(0.,5)--(0,0)--cycle;
\end{tikzpicture}
\end{document}
答案1
在这种情况下,最简单的选择似乎是设置,line join=bevel
因为您有三条线在一点合并。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[line join=bevel]
\draw[draw=black,fill=gray!20] (0,0) --(4.8,0)-- (4.8,5)--(0, 5)--cycle;
\draw[draw=black,fill=gray!20] (4.8,5) -- (4.9,4.8)--(4.9,-0.1)--(4.8,0)--cycle;
\draw[draw=black,fill=gray!20] (0,0) -- (0.1,-0.1)--(4.9,-0.1)--(4.8,0)--cycle;
\draw[dashed,draw=black] (4.8,5) -- (4.9,4.8)--(0.1,4.8)--(0.,5)--cycle;
\draw[dashed,draw=black] (0.1,-0.1)--(0.1,4.8)--(0.,5)--(0,0)--cycle;
\end{tikzpicture}
\end{document}