3
\documentclass[12pt,a4paper,onecolumn]{article}
\usepackage{tikz}
\usepackage{caption}
\usetikzlibrary{positioning,fit,calc}

\begin{document}
\tikzstyle{every node}=[circle, draw, fill=black!100,
                       inner sep=0pt, minimum width=6pt]
\begin{tikzpicture}[thick,scale=0.8]%
\draw(0,0)node[label={[yshift=0cm]270:{$1$}}](1){};
\draw(0,4)node[label={[yshift=0cm]90:{$2$}}](2){};
\draw(4,4)node[label={[yshift=0cm]90:{$3$}}](3){};
\draw(4,0)node[label={[yshift=0cm]270:{$4$}}](4){};

\draw[->, line width=0.3mm, >=latex, shorten <= 0.2cm, shorten >= 0.15cm](1)--(2);
\draw[dashed, ->, line width=0.3mm, >=latex, shorten <= 0.2cm, shorten >= 0.15cm](2)--(3);
\draw[densely dotted,->, line width=0.3mm, >=latex, shorten <= 0.2cm, shorten >= 0.15cm](3)--(4);
\draw[densely dashdotdotted, ->, line width=0.3mm, >=latex, shorten <= 0.2cm, shorten >= 0.15cm](4)--(1);
\end{tikzpicture}
{\captionof{figure}{4 types of arcs.}}

In Figure 1, there are 4 types of arcs, namely the solid $<display Solid Line Here>$, dashed $<display Dashed Line Here>$, densely dotted $<display Densely Dotted Line Here>$, and densely dashdotdotted $<display Densely Dashdotdotted Line Here>$.
\noindent\par The best I can do is 
In Figure 1, there are 4 types of arcs, namely the solid $<display Solid Line Here>$, dashed $<--->$, densely dotted $<\cdots>$, and densely dashdotdotted $<display Densely Dashdotdotted Line Here>$
\end{document}

Thank you

Torbjørn T.
  • 206,688

1 Answers1

4

You can insert TikZ pictures at almost arbitrary locations in your document. There is even the shorthand notation \tikz...; for inline pictures with a single path.

To get a nice centering on the line I used baseline=-\the\fontdimen22\textfont2 which is the height at which operators will be centered in math mode. See also What do different \fontdimen<num> mean

\documentclass[12pt,a4paper,onecolumn]{article}
\usepackage{tikz}
\usepackage{caption}
\usetikzlibrary{positioning,fit,calc}

\begin{document}

\begin{center} \begin{tikzpicture}[ thick, scale=0.8, every node/.style={ circle, draw, fill=black!100, inner sep=0pt, minimum width=6pt }] \draw(0,0)nodelabel={[yshift=0cm]270:{$1$}}{}; \draw(0,4)nodelabel={[yshift=0cm]90:{$2$}}{}; \draw(4,4)nodelabel={[yshift=0cm]90:{$3$}}{}; \draw(4,0)nodelabel={[yshift=0cm]270:{$4$}}{};

\draw[-&gt;, line width=0.3mm, &gt;=latex, shorten &lt;= 0.2cm, shorten &gt;= 0.15cm](1)--(2);
\draw[dashed, -&gt;, line width=0.3mm, &gt;=latex, shorten &lt;= 0.2cm, shorten &gt;= 0.15cm](2)--(3);
\draw[densely dotted,-&gt;, line width=0.3mm, &gt;=latex, shorten &lt;= 0.2cm, shorten &gt;= 0.15cm](3)--(4);
\draw[densely dashdotdotted, -&gt;, line width=0.3mm, &gt;=latex, shorten &lt;= 0.2cm, shorten &gt;= 0.15cm](4)--(1);

\end{tikzpicture} \captionof{figure}{\label{fig:arcs}4 types of arcs.} \end{center}

\newcommand*\lineexample[1]{% #1~(\tikz[baseline=-\the\fontdimen22\textfont2]\draw#1--(1.618em,0);)% }

In Figure~\ref{fig:arcs}, there are 4 types of arcs, namely the \lineexample{solid}, \lineexample{dashed}, \lineexample{densely dotted}, and \lineexample{densely dashdotdotted}.

\end{document}

enter image description here


Just for fun, here is the same example again with \graph.

\documentclass[12pt,a4paper,onecolumn]{article}
\usepackage{tikz}
\usetikzlibrary{graphs}

\begin{document}

\begin{figure} \centering \begin{tikzpicture}[ thick, scale=0.8, every node/.style={ circle, draw, fill=black!100, inner sep=0pt, minimum width=6pt }]

\node[label={below:$1$}](1) at (0,0) {};
\node[label={above:$2$}](2) at (0,4) {};
\node[label={above:$3$}](3) at (4,4) {};
\node[label={below:$4$}](4) at (4,0) {};

\graph [use existing nodes,edges={&gt;=latex,shorten &lt;=0.2cm,shorten &gt;=0.15cm}] {
  1 -&gt;[solid] 2 -&gt;[dashed] 3 -&gt;[densely dotted] 4 -&gt;[densely dashdotted] 1
};

\end{tikzpicture} \caption{\label{fig:arcs}4 types of arcs.} \end{figure}

\newcommand*\lineexample[1]{% #1~(\tikz[baseline=-\the\fontdimen22\textfont2]\draw#1--(1.618em,0);)% }

In Figure~\ref{fig:arcs}, there are 4 types of arcs, namely the \lineexample{solid}, \lineexample{dashed}, \lineexample{densely dotted}, and \lineexample{densely dashdotted}.

\end{document}

Henri Menke
  • 109,596
  • The densely dashdotted line looks different; I'm afraid it confuses the reader further. Is it possible to make it exactly the same as the picture? And you mentioned "You can insert TikZ pictures at almost arbitrary locations in your document. There is even the shorthand notation \tikz...; for inline pictures with a single path." Have you done this already? Thank you – Spherical Moments Mar 01 '22 at 16:01
  • @SphericalMoments I misspelled the line type. I typed densely dashdotted instead of densely dashdotdotted. After fixing that it looks the same. – Henri Menke Mar 01 '22 at 16:36
  • ok thank you. Can we omit the words "densely dashdotdotted", as I meant to type them in manually? So, the command would only show the lines within brackets but no words at all. – Spherical Moments Mar 01 '22 at 16:58
  • In the command \lineexample, you can see #1~ at the beginning. This is what types the name of the dash type. If you just want the lines but not the names, delete this part. – SebGlav Mar 01 '22 at 18:02
  • ok thank you very much – Spherical Moments Mar 02 '22 at 06:38