首先,工作代码:
\documentclass[journal]{IEEEtran}
\usepackage{libertine}
\usepackage{cite}
\usepackage{url}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{setspace}
\usepackage{algorithm}
\usepackage{algorithmicx}
\usepackage{algpseudocode}
\usepackage[english]{babel}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\begin{center}
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3cm,
thick,main node/.style={,fill=white!20,draw,font=\sffamily\small\bfseries}]
\node[main node] (dancing) {dancing};
\node[main node] (monkey) [below of=dancing] {monkey};
\path[every node/.style={font=\sffamily\small}]
(dancing) edge node [below] {test} (monkey)
;
\end{tikzpicture}
\end{center}
\end{document}
如下所示,我得到了带有箭头重叠的文本。
有办法改变这种情况吗?我还可以修改图表中各个箭头的大小吗?
多谢!
答案1
这是一个可能的解决方案。使用包rotatebox
中的功能graphicx
,或者借助 tikzlibrarypostioning
或。above left=xxcm and xxcm
below right=xx cm and xxcm
代码
\documentclass{article}
\usepackage{tikz,graphicx}
\usetikzlibrary{arrows,positioning,calc}
\begin{document}
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3cm,
thick,main node/.style={,fill=white!20,draw,font=\sffamily\small\bfseries}]
\node[main node] (dancing) {dancing};
\node[main node,below=3cm of dancing] (monkey) {monkey};
\path[]
(dancing) edge node [] {\rotatebox[origin=cc]{90}{test}} (monkey)
;
\path[]
(dancing) edge node [below right=0.5cm and 0.1cm] {test} (monkey)
;
\path[]
(dancing) edge node [above left=0.5cm and 0.1cm] {test} (monkey)
;
\end{tikzpicture}
\end{document}