
我有一個有 8 個節點的圖。我想繪製箭頭,它們會指向某些節點(例如我想繪製指向 4 個節點的箭頭)。另外,在每個箭頭旁邊我想寫一些文字。為此,我使用了以下網頁:http://en.wikibooks.org/wiki/LaTeX/Picture#Arrows我認為我必須單獨編寫每個箭頭並手動修復位置。但是,我無法將箭頭從原來的位置移開。有任何想法嗎?這是我使用的完整程式碼:
\\documentclass[11pt]{article}
\usepackage{tikz}
\usepackage{caption}
\usepackage{subcaption}
\begin{document}
\tikzset{%
point/.style = {fill=black,inner sep=1pt, circle, minimum width=3pt,align=right,rotate=60},
}
\tikzstyle{weight} = [font=\scriptsize]
\tikzstyle{vertex}=[circle,fill=blue!20]
\makeatletter
\setlength{\@fptop}{0pt}
\makeatother
\section{Some section}
\begin{figure}
\centering
\begin{subfigure}{0.5\textwidth}
\resizebox{0.7\textwidth}{!}{
\begin{tikzpicture}
[scale=.8,auto=right]
\put(0,10){\vector(1,0){20}}
\node[vertex] (v1) at (1,10) {$a$};
\node[vertex] (v2) at (1,8) {$b$};
\node[vertex] (v3) at (1,6) {$c$};
\node[vertex] (v4) at (1,4) {$d$};
\node[vertex] (v5) at (8,10) {$e$};
\node[vertex] (v6) at (8,8) {$f$};
\node[vertex] (v7) at (8,6) {$g$};
\node[vertex] (v8) at (8,4) {$h$};
\draw[->] (v1)--(v8);
\draw[->] (v1)--(v5);
\draw[->] (v2)--(v5);
\draw[->] (v2)--(v6);
\draw[->] (v3)--(v6);
\draw[->] (v3)--(v7);
\draw[->] (v4)--(v7);
\draw[->] (v4)--(v8);
\end{tikzpicture}
}
\caption{I want to place the arrow s.t. it will point to node "a". Also I want to insert some text above the arrow}
\label{fig:1}
\end{subfigure}
\hspace{4em}%
\caption{I want to place the arrow s.t. it will point to node "a". Also I want to insert some text above the arrow.}\label{fig:animals}
\end{figure}
\end{document}
答案1
可能是這樣的?
這是使用pin
標記節點的工具產生的。請注意,我已經更新了您的程式碼以一致地使用,\tikzset
因為\tikzstyle
它已被棄用。
\documentclass[tikz, border=10pt]{standalone}
\begin{document}
\tikzset{%
point/.style = {fill=black,inner sep=1pt, circle, minimum width=3pt,align=right,rotate=60},
weight/.style={font=\scriptsize},
vertex/.style={circle,fill=blue!20}
}
\begin{tikzpicture}
[scale=.8,auto=right]
\put(0,10){\vector(1,0){20}}
\node[vertex, pin={[pin edge=<-, pin distance=10pt]105:{Label Here}}] (v1) at (1,10) {$a$};
\node[vertex] (v2) at (1,8) {$b$};
\node[vertex] (v3) at (1,6) {$c$};
\node[vertex] (v4) at (1,4) {$d$};
\node[vertex] (v5) at (8,10) {$e$};
\node[vertex] (v6) at (8,8) {$f$};
\node[vertex] (v7) at (8,6) {$g$};
\node[vertex] (v8) at (8,4) {$h$};
\draw[->] (v1)--(v8);
\draw[->] (v1)--(v5);
\draw[->] (v2)--(v5);
\draw[->] (v2)--(v6);
\draw[->] (v3)--(v6);
\draw[->] (v3)--(v7);
\draw[->] (v4)--(v7);
\draw[->] (v4)--(v8);
\end{tikzpicture}
\end{document}