Search code examples
latextikz

Extra line on path with rounded corners in tikz


I'm drawing a path in tikz with rounded corners,

\documentclass{beamer}

\usepackage{tikz}
\usetikzlibrary{arrows}
\tikzset{>=latex}

\begin{document}
\begin{frame}
    \begin{tikzpicture}    
        \draw[->, rounded corners = 5mm] (9,2) -- (9.2,1.7) -- (1.7,1.7) -- (1, 1); 
    \end{tikzpicture}
\end{frame}
\end{document}

but there appears to be an extra line drawn at the beginning (highlighted by red circle below)?

enter image description here

How to I get rid of that?


Solution

  • If the top of your arc is only 3 mm above your line, latex has a hard time to squeeze a 5 mm rounded corner in there. To avoid this:

    • move the endpoint of your arc a bit further up
    • use another approach to draw the arc. You could use a real arc, the to operation, a Bézier curve, ...

    \documentclass{beamer}
    
    \usepackage{tikz}
    \usetikzlibrary{arrows}
    \tikzset{>=latex}
    
    \begin{document}
    \begin{frame}
        \begin{tikzpicture}    
            \draw[->, rounded corners = 5mm] (9,2.2) -- (9.2,1.7) -- (1.7,1.7) -- (1, 1); 
        \end{tikzpicture}
        
        \begin{tikzpicture}    
            \draw[->] (9,2) to[in=0,out=-60] (8.8,1.7) [rounded corners = 5mm] -- (1.7,1.7) -- (1, 1); 
        \end{tikzpicture}
    \end{frame}
    \end{document}
    

    enter image description here