1

Here is my code:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
    \begin{tikzpicture}

    \fill[gray!50] (0,2.5) -- (2,2.5) -- ++(60:.2) -- ++(-2,0) -- cycle;
    \fill[gray!50] (0,2.5) -- (2,2.5) -- ++(0,-.2) -- ++(-2,0) -- cycle;
    \fill[gray!50] (2,2.5) -- ++(60:.2) -- ++(0,-.2) -- ++(60:-.2) -- cycle;

    \begin{scope}[shift={(60:1.3)}]
    \fill[gray!50] (0,2.5)  -- (2,2.5) -- ++(60:.2) -- ++(-2,0) -- cycle;
    \fill[gray!50] (0,2.5) -- (2,2.5) -- ++(0,-.2) -- ++(-2,0) -- cycle;
    \fill[gray!50] (2,2.5) -- ++(60:.2) -- ++(0,-.2) -- ++(60:-.2) -- cycle;
    \end{scope}

    %see here first will be helpful to understand
    \draw (0,0) -- (2,0) -- (2,2.5) -- (0,2.5) -- cycle;
    \draw (2,0) -- ++(60:1.5) -- ++(0,2.5) coordinate (a) -- ++(60:-.2) -- ++(0,-.2) -- ++(60:-1.1) -- ++(0,.2) -- ++(60:-.2);
    \draw (a) -- ++(-2,0) -- ++(60:-.2) coordinate (b) -- ++(2,0);
    \draw (b) -- ++(0,-.2) coordinate (c) -- ++(60:-.87);
    \draw[densely dotted] (c) -- ++(2,0);
    \draw (0,2.5) -- ++(60:.2) -- ++(2,0) -- ++(60:-.2) -- cycle;


    \end{tikzpicture}
\end{document}

The result of the code is in the figure, and I wonder why the part marked in red is not perfectly drawn. enter image description here

2
4

To answer the question why they are not perfectly drawn, they are. The problem is that to get the 3D effects you get quite sharp corners. You actually have the same problem in many places in the figure where corners of different angles are drawn on top of each other, but it is mostly visible in the marked corner. If you color the lines and change the order you can see the problem:

enter image description here

So, that is the reason for the problem, now how to fix it. As stated in the comment the easiest way is to have not sharp corners. As an argument to the tikzpicture you can say [line join=round]. That will directly make all the corners more aligned:

enter image description here

If you really want the sharp corners you can remove the last part of the red line (which is overlapped by the green line). That will remove the sharp corner,

\draw[green] (0,2.5) -- ++(60:.2) -- ++(2,0) -- ++(60:-.2) -- cycle;
%\draw[red] (2,0) -- ++(60:1.5) -- ++(0,2.5) coordinate (a) -- ++(60:-.2) -- ++(0,-.2) -- ++(60:-1.1) -- ++(0,.2) -- ++(60:-.2);
\draw[red] (2,0) -- ++(60:1.5) -- ++(0,2.5) coordinate (a) -- ++(60:-.2) -- ++(0,-.2) -- ++(60:-1.1) -- ++(0,.2);

It is not perfect, but better:

enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.