# Joining lines from different draw commands, TikZ

I'm wondering whether there's a way in TikZ to join neatly to lines drawn with different \draw commands. Specifically for me, joining a line to an arc.

Here's my MWE:

\documentclass{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}

\draw (0,0) -- (1,0);
\draw (1,0) arc (180:360:0.5);
\draw (2,0) -- (3,0);

\end{tikzpicture}
\end{document}


If you were to zoom in to the join of the arc and the line you can see that there isn't a nice miter-type join. Is there a way to rectify this? To make this one continuous line for example?

Thanks.

• Simply: \draw (0,0) -- (1,0) arc (180:360:0.5)--(3,0); – Herr K. Jun 2 '14 at 16:29

Like this:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) -- (1,0) arc (180:360:0.5) -- (3,0);
\end{tikzpicture}
\end{document}


Zoom on joint:

This does not really answer your question, if you really need to join lines from different \draw.

• That's weird, that didn't work for me earlier. I guess I just did a silly spelling mistake. Thanks. – thosphor Jun 2 '14 at 16:36

The best solution is using one \draw command as shown in the answer of Hans-Peter E. Kristiansen.

Sometimes this is not possible. For example, if the lines are drawn with different colors. Then the line width has to be taken into account and some improvisation is needed.

Example:

\documentclass{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}

\draw
(0,0) -- (1,0)
(2,0) -- (3,0)
;
\draw[red]
(1,.5\pgflinewidth) --
(1,0) arc (180:360:0.5)
-- (2,.5\pgflinewidth)
;

\end{tikzpicture}
\end{document}


I agree with what Heiko says about drawing using one \draw command. When it is not possible to draw every thing using one \draw command, you can take shelter under line cap.

\documentclass[border=5pt]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[line cap=rect]   %% <--------

\draw (0,0) -- (1,0);
\draw (1,0) arc (180:360:0.5);
\draw (2,0) -- (3,0);

\end{tikzpicture}
\end{document}