Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 8 down vote accepted

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).

share|improve this answer
1  
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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