# Sharp short unwanted edges in tikz

While drawing a simple 3D (fake 3D in fact) cube, I realized that the corners end up with unwanted extensions of the line. I understand this is related to the width of the lines themselves, but how can I remove them? An alternative solution of drawing the desired figure is also welcomed.

Example:

\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}


• Try line join=bevel or draw the paths in a different way. – user121799 Jul 4 '18 at 10:26
• @marmot hey that works, consider posting it as answer so I can give you some points – Ander Biguri Jul 4 '18 at 10:28

In this case the simplest option seems to be to set line join=bevel since you have three lines merging at a point.

\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}