# How insert tikz graph in text?

In order to integrate a legend into the text of my pdf file, I want to extend the answer of a previous question on this site https://tex.stackexchange.com/a/196784/15140 in order to add in front of the diamond a line which is either dotted or dashed. Something looking:

prices are represented as -----<> and weights as - - -<>

How can I achieve this ?

Add an extra line and argument like:

\draw[#2] (-3,0.5) -- (0,0.5);


The extra argument can be used to control how the line is drawn. Change -3 as you wish so as to change the length of the line.

\documentclass{article}
\usepackage{tikz}

\newcommand{\sqdiamond}[2][fill=black]{\tikz [x=1.2ex,y=1.85ex,line width=.1ex,line join=round, yshift=-0.285ex]{ \draw  [#1]  (0,.5) -- (.5,1) -- (1,.5) -- (.5,0) -- (0,.5) -- cycle;
\draw[#2] (-3,0.5) -- (0,0.5);}}%
\newcommand{\MyDiamond}[2][fill=black]{\raisebox{-0.275ex}{\sqdiamond[#1]{#2}}}

\begin{document}
prices are represented as \MyDiamond[draw=red,fill=cyan]{dashed} and weights as \MyDiamond[draw=olive,fill=magenta]{loosely dashed}

\end{document}