# Rounded ends with tikz

I can draw double lines, and I can draw rounded caps using certain arrowheads. However, in combination they don't look as you would expect:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,scopes}
\begin{document}
\begin{tikzpicture}
\draw [line width = 4pt,-round cap] (0,0) -- (0,1);
{ [every path/.style = {double distance = 2pt, very thick}]
\draw (1,0) -- (1,1);
\draw [-round cap] (2,0) -- (2,1);
}
\end{tikzpicture}
\end{document}


I would prefer the "round cap" on a doubled line to cause the lines to curve around the end and meet, as in:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,scopes}
\begin{document}
\begin{tikzpicture} [very thick, x=1em]
\draw (0,0) -- (0,1)
arc [x radius = 0.5em, y radius = 0.5em, start angle = 180, end angle = 0]
(1,0) -- (1,1);
\end{tikzpicture}
\end{document}


Obviously I can draw such a thing, but how can I do it with an arrow head?

-

You can use the line cap=round option (other permissible values are butt (default) and rect):

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw[double distance = 0.5cm,line cap=round] (0,0) -- (1,0);
\end{tikzpicture}
\end{document}


Note however that the cap extends beyond the actual line (i.e. (0,0) is at the center of the cap and not on the boundary).

Here is an actual arrow tip:

\documentclass{article}
\usepackage{tikz}

\makeatletter
\pgfarrowsdeclare{open cap}{open cap}
{\pgfarrowsleftextend{+0pt}\pgfarrowsrightextend{+0.5\pgflinewidth}}
{
\pgfmathsetlength{\pgfutil@tempdimb}{.5*\pgflinewidth-.5*\pgfinnerlinewidth}%
\pgfsetlinewidth{\pgfutil@tempdimb}
\pgfsetbuttcap
\pgfsetdash{}{0pt}
\pgfmathsetlength{\pgfutil@tempdima}{.5*\pgfutil@tempdimb+.5*\pgfinnerlinewidth}%
\pgfpathmoveto{\pgfqpoint{0pt}{\pgfutil@tempdima}}
\pgfpatharc{270}{90}{-\pgfutil@tempdima}
\pgfusepathqstroke
}
\makeatother

\begin{document}
\begin{tikzpicture}
\draw[very thick,double distance = 0.5cm,open cap-open cap] (0,0) -- (1,0);
\end{tikzpicture}
\end{document}


Here (0,0) is at the end of the line (i.e. the boundary of the cap).

-
For your first solution: IIRC you can use shorten > and shorten < also if you actually don't have any arrow heads. These could be use to compensate for the overhang, i.e. by setting half the double distance with a negative sign. –  Martin Scharrer Jun 22 '11 at 21:31
Beautiful: that arrow tip is exactly what I want. I will remember how to do that. –  Ryan Reich Jun 23 '11 at 14:52