\documentclass[a4paper, 12pt]{article}
\usepackage{amsfonts}
\usepackage{tikz}
\usepackage{amsmath}
\newtheorem{theorem}{Theorem}
\newtheorem{example}[theorem]{Example}
\begin{document}
\begin{center}
\begin{tikzpicture}[scale=0.65,
thick,
acteur/.style={
circle,
fill=blue,
thick,
inner sep=0.5pt,
minimum size=1.8mm
}
]
\node (a3) at (0,0) [acteur,label=below:\scriptsize{3}]{};
\node (a1) at (1.5,1)[acteur,label=below:\scriptsize{1}]{};
\node (a2) at (0,2) [acteur,label=above:\scriptsize{2}]{};
\node (a4) at (3,1) [acteur,label=right:\scriptsize{4}]{};
\draw [<-] (a1) -- (a2);
\draw [<-] (a2) -- (a3);
\draw(a3) -- (a1);
\draw [<-] (a1) -- (a4);
\node at (-2.5,1) {\textit{$G$}};
\end{tikzpicture}
\end{center}
\end{document}
在此图中,我需要边缘中间的箭头。如何在 Latex 中做到这一点?
答案1
在图书馆的帮助下decorations.markings
:
\documentclass[a4paper, 12pt]{article}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{center}
\begin{tikzpicture}[%scale=0.65,
acteur/.style = {circle, fill=blue, thick,
inner sep=0.5pt, outer sep=0pt, minimum size=1.8mm},
decoration = {markings, mark=at position 0.5 with {\arrowreversed[semithick]{>}}},
every label/.append style = {font=\scriptsize},
]
\node (a3) at (0,0) [acteur,label=below:3]{};
\node (a1) at (1.5,1)[acteur,label=below:1]{};
\node (a2) at (0,2) [acteur,label=above:2]{};
\node (a4) at (3,1) [acteur,label=right:3]{};
%
\draw[postaction={decorate}] (a1) -- (a2);
\draw[postaction={decorate}] (a2) -- (a3);
\draw[postaction={decorate}] (a3) -- (a1);
\draw[postaction={decorate}] (a1) -- (a4);
%
\node at (-2.5,1) {\textit{$G$}};
\end{tikzpicture}
\end{center}
编辑: 通过定义边缘样式,你可以使代码更短一些:
\documentclass[a4paper, 12pt]{article}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{center}
\begin{tikzpicture}[%scale=0.65,
acteur/.style = {circle, fill=blue, thick,
inner sep=0.5pt, outer sep=0pt, minimum size=1.8mm},
decoration = {markings, mark=at position 0.5 with {\arrowreversed[semithick]{>}}},
every label/.append style = {font=\scriptsize},
every edge/.append style = {postaction={decorate}} % <----
]
\node (a3) at (0,0) [acteur,label=below:3]{};
\node (a1) at (1.5,1)[acteur,label=below:1]{};
\node (a2) at (0,2) [acteur,label=above:2]{};
\node (a4) at (3,1) [acteur,label=right:3]{};
%
\draw (a1) edge (a2)
(a2) edge (a3)
(a3) edge (a1)
(a1) edge (a4);
%
\node at (-2.5,1) {\textit{$G$}};
\end{tikzpicture}
\end{center}
\end{document}