# [Tex/LaTex] Draw a dash-dotted line

tikz-pgf

How can I produce a dash-dotted line .-.-.-.-? I tried to find something in the tikz manual, but didn't find anything.

The various pre-defined dash patterns are documented in section 15.3.2 Graphic Parameters: Dash Pattern of the manual (for version 3.0.1.a dated 29 August 2015). They are dotted, dashed, dash dot and dash dot dot. Each of these have denser and looser variants, e.g. densely dashed and loosely dotted. Equivalently for the others.

In addition you can specify a custom pattern using e.g. dash pattern={on 4pt off 1pt on 2pt off 3pt}, which I guess is self explanatory.

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw [thick,dash dot] (0,1) -- (5,1);
\draw [thick,dash pattern={on 7pt off 2pt on 1pt off 3pt}] (0,0) -- (5,0);
\end{tikzpicture}

\end{document}


If you want to put a line like this in the text, and aligned better to the surrounding text, then you can add the baseline=<length> option to the tikzpicture. By default the bottom end of the tikzpicture is placed on the baseline of the surrounding text. If you add baseline=10pt then the tikzpicture will be placed so that y=10pt in its internal coordinate system is on the baseline of the surrounding text.

Here is an example. \tikz is a short form of the tikzpicture environment, intended for simple pictures placed in the text.

\documentclass{article}
\usepackage{tikz}

\begin{document}
Lorem ipsum \tikz\draw [thick,dash dot] (0,0) -- (3,0); dolor sit amet

Lorem ipsum \tikz[baseline=-0.5ex]\draw [thick,dash dot] (0,0) -- (3,0); dolor sit amet
\end{document}