2

I'm drawing a 3d cube in tikz.

\documentclass{article}
\usepackage{tikz}

\begin{document} \begin{tikzpicture}[line width=1mm] \draw (0,0) rectangle (5,5); \draw[fill=gray!40] (5,5)--(6,4)--(6,-1)--(5,0)--cycle; \end{tikzpicture} \end{document}

How to avoid this ugly effect? enter image description here

  • 1
    When three lines meet, you could draw the two outer lines normally, and the third middle line with line cap=round. See also https://tex.stackexchange.com/a/12024/8650 . – hpekristiansen Jul 06 '20 at 16:52

1 Answers1

7

I would draw the fill first, then the outer most cycle and lastly the diagonal lines with line cap=round or line cap=butt. Like this:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[line width=1mm]
\fill[gray!40] (5,5)--(6,4)--(6,-1)--(5,0)--cycle;
\draw (0,0) -- (0,5) -- (5,5) -- (6,4) -- (6,-1) -- (5,0) -- cycle (5,5) -- (5,0);
\end{tikzpicture}
\end{document}

Part of bow with corrected line joint

You can draw all the lines first with different colors, to check if everything looks ok. -Also see What is the easiest way to draw a 3D cube with TikZ?