我花了几个小时(:-))尝试使用“每个标签”方法用 90 度文本注释节点。虽然我可以旋转文本,但它的位置会转移到图片中某个更远的地方。我不想将“旋转”指令放到每个节点上,我宁愿用“每个标签”样式来定义它。
\documentclass[12pt,a4paper,oneside]{report}
\usepackage[utf8]{inputenc}
\usepackage{pgf, tikz}
\usepackage{tikzscale}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{automata,calc,positioning}
\usetikzlibrary{angles,intersections,quotes,arrows.meta}
\begin{document}
\def \V {1.5}
\begin{tikzpicture}[every node/.style={line width=0.1mm, minimum size=1cm}]
\tikzstyle{every label}=[rotate=-90]
\node[label={[label distance=0.1cm]:A}, circle, draw] (A) at (1,0) { A};
\node[draw, circle] (B) at (2,0) {B};
\node[draw, circle] (C) at (3,0) {C};
\node[draw, circle] (D) at (4,0) {D};
\node[draw, circle] (E) at (5,0) {E};
\node[draw, circle] (F) at (6,0) {F};
\node[draw, circle] (G) at (1,\V) {G};
\node[draw, circle] (H) at (2,\V) {H};
\node[draw, circle] (I) at (3,\V) {I};
\node[draw, circle] (J) at (4,\V) {J};
\node[draw, circle] (K) at (5,\V) {K};
\node[draw, circle] (L) at (6,\V) {L};
\draw[->] (B) to [bend left=60] (K) ;
\end{tikzpicture}
\end{document}
答案1
您只需在旋转命令后定义标签的锚点:
\documentclass[12pt,a4paper,oneside]{report}
\usepackage{tikz}
\usetikzlibrary{angles,intersections,quotes,arrows.meta}
\begin{document}
\def \V {2}
\begin{tikzpicture}[
C/.style = {circle, draw, minimum size=1cm},% every node influence on label node too,
every label/.style = {label distance=0pt, inner sep=1pt}
]
\node[C,label={[rotate=90, anchor=east]below:A}] (A) at (1,0) { A};
\node[C] (B) at (2,0) {B};
\node[C] (C) at (3,0) {C};
\node[C] (D) at (4,0) {D};
\node[C] (E) at (5,0) {E};
\node[C] (F) at (6,0) {F};
\node[C] (G) at (1,\V) {G};
\node[C] (H) at (2,\V) {H};
\node[C] (I) at (3,\V) {I};
\node[C] (J) at (4,\V) {J};
\node[C] (K) at (5,\V) {K};
\node[C] (L) at (6,\V) {L};
\draw[->] (B.north) .. controls + (0,1) and + (0,-1) .. (K.south) ;
\end{tikzpicture}
\end{document}