[Tex/LaTex] Rounded ends with tikz

arrowstikz-pgf

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}

tiny sample pictures

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}

larger sample picture

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

Best Answer

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}

result

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}

result

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