Tikz 节点标签位置

Tikz 节点标签位置

我有这个 tikz 图,但节点 A 的标签被边缘覆盖。有没有办法将其定位在节点的右上角?

  \begin{figure}[H]
\centering
    \begin{tikzpicture}[font=\small, node distance={15mm}, thick, main/.style = {draw, circle}, scale=0.8,transform shape] 
\node[main , fill=black, label=left:{\small $B$}] (1) [] {}; 
  \node[main ,  label=right:{\small $A$}] (2) [ right of=1] {}; 
  \node[main , label=left:{\small $B$}] (1) [left  of=2] {}; 
\node[main , fill=black,label=above:{\small $C$}] (3) [right  of=2] {}; 
 \node[main, label=below:{\small $C^*$}] (4) [ below of=3] {};
 \node[main, label=below:{\small $R_C$}]  (5) [ below of=2]{}; 
 \node[main , label=above:{\small $B^*$}] (6) [above  of=1] {}; 
  \node[main , label=above:{\small $R_B$}] (7) [above  of=2] {}; 
\draw[->] (2) -- (1); 
\draw[->] (2) -- (3); 
\draw[->] (7) -- (6); 
  \draw[->] (2) -- (5); 
    \draw[->] (2) -- (7);
    \draw[->] (3) -- (4); 
\draw[->] (1) -- (6);
\draw[->] (5) -- (4); 
\end{tikzpicture}
\end{figure}

还有什么办法可以让图形变得曲线吗?是否有其他可以生成曲线图的软件包?

答案1

您的代码不完整。无论如何,您的问题的答案是对您的代码进行一些修正: label=above right:{\small $A$}]

完整的工作代码:

\documentclass{article}
\usepackage{tikz}
\begin{document}


    \centering
        \begin{tikzpicture}[scale=3,font=\small, node distance={15mm}, thick, main/.style = {draw, circle}, scale=0.8,transform shape] 
            \node[main , fill=black, label=left:{\small $B$}] (1) [] {}; 
            \node[main ,  label=above right:{\small $A$}] (2) [ right of=1] {}; 
            \node[main , label=left:{\small $B$}] (1) [left  of=2] {}; 
            \node[main , fill=black,label=above:{\small $C$}] (3) [right  of=2] {}; 
            \node[main, label=below:{\small $C^*$}] (4) [ below of=3] {};
            \node[main, label=below:{\small $R_C$}]  (5) [ below of=2]{}; 
            \node[main , label=above:{\small $B^*$}] (6) [above  of=1] {}; 
            \node[main , label=above:{\small $R_B$}] (7) [above  of=2] {}; 
            \draw[->] (2) -- (1); 
            \draw[->] (2) -- (3); 
            \draw[->] (7) -- (6); 
            \draw[->] (2) -- (5); 
            \draw[->] (2) -- (7);
            \draw[->] (3) -- (4); 
            \draw[->] (1) -- (6);
            \draw[->] (5) -- (4); 
        \end{tikzpicture}
\end{document}

输出:

在此处输入图片描述

答案2

这只是 @Raffaele Santoro 回答的一个小变化(+1)。

对于您的图像,我将定义两个节点样式,一个用于黑点,一个用于白点,通过定义节点的标签为陈旧every label/.append style = ...,通过every edge/.style and for node positioning use定位定义箭头样式library

\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                positioning}

\begin{document}
    \begin{tikzpicture}[baseline,
   node distance = 12mm and 12mm,
                   thick,
                   %on grid,
bdot/.style = {circle, draw, fill, inner sep=2.8pt,
                           label=#1, node contents = {}},
wdot/.style = {bdot=#1, fill=white},
every label/.append style = {node distance=2pt, inner sep=2pt, font=\footnotesize},
 every edge/.style = {draw, - Straight Barb}
                        ]
\node (1) [bdot=left:$B$];
\node (2) [wdot=above right:$A$, right=of 1];
\node (3) [bdot=above:$C$,  right=of 2];
\node (4) [wdot=below:$C^*$,below=of 3];
\node (5) [wdot=below:$R_C$,below=of 2];
\node (6) [wdot=above:$B^*$,above=of 1];
\node (7) [wdot=above:$R_B$,above=of 2];
\draw   (2) edge (1)    (2) edge (3) 
        (7) edge (6)    (2) edge (5) 
        (2) edge (7)    (3) edge (4) 
        (1) edge (6)    (5) edge (4);
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容