如何设置 TikZ 中所有节点和所有标签之间的距离?

如何设置 TikZ 中所有节点和所有标签之间的距离?

Tikz Pgf 手册第 240 页指出:

label distance = <distance>在主节点和标签节点之间额外插入<distance>,默认为0pt。

这是不适用于由生成的文档Geogebra

\documentclass[10pt]{article}

\usepackage{pgf,tikz}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\pagestyle{empty}

\begin{document}
\definecolor{xdxdff}{rgb}{0.49019607843137253,0.49019607843137253,1.}
\definecolor{uuuuuu}{rgb}{0.26666666666666666,0.26666666666666666,0.26666666666666666}
\definecolor{qqqqff}{rgb}{0.,0.,1.}
    \begin{tikzpicture}[label distance = 0.5cm, line cap=round,line join=round,>=triangle 45,x=1.3539289842855764cm,y=1.5233942677491352cm]
        \clip(-1.,-1.) rectangle (11.,6.);
        \draw (0.27364775674239095,3.5536119181673125)-- (1.1893105429946793,0.35474712702121464);
        \draw (1.1893105429946793,0.35474712702121464)-- (6.279319969251443,0.632286021094505);
        \draw (6.279319969251443,0.632286021094505)-- (2.3146633946526336,1.4604297463807696);
        \draw (2.3146633946526336,1.4604297463807696)-- (0.27364775674239095,3.5536119181673125);
        \draw [dotted] (1.1893105429946793,0.35474712702121464)-- (2.3146633946526336,1.4604297463807696);
        \draw [dotted] (0.27364775674239095,3.5536119181673125)-- (6.279319969251443,0.632286021094505);
        \draw (1.7519869688236565,0.9075884367009921)-- (1.7798228040999855,0.3869455192360619);
        \draw (3.276483862996917,2.0929489696309087)-- (3.364647193570481,0.4733599777408055);
        \begin{scriptsize}
            \draw [fill=qqqqff] (0.27364775674239095,3.5536119181673125) circle (1.5pt);
            \draw[color=qqqqff] (0.1693146889897907,3.6775074361235256) node {$A$};
            \draw [fill=qqqqff] (1.1893105429946793,0.35474712702121464) circle (1.5pt);
            \draw[color=qqqqff] (1.0626665816214305,0.29320355089855427) node {$B$};
            \draw [fill=qqqqff] (6.279319969251443,0.632286021094505) circle (1.5pt);
            \draw[color=qqqqff] (6.403215487207657,0.6518484712981176) node {$C$};
            \draw [fill=qqqqff] (2.3146633946526336,1.4604297463807696) circle (1.5pt);
            \draw[color=qqqqff] (2.360309111794397,1.5517211806642952) node {$D$};
            \draw [fill=uuuuuu] (1.7519869688236565,0.9075884367009921) circle (1.5pt);
            \draw[color=uuuuuu] (1.7017066216061072,1.0561391088394438) node {$E$};
            \draw [fill=uuuuuu] (3.276483862996917,2.0929489696309087) circle (1.5pt);
            \draw[color=uuuuuu] (3.3188691717714116,2.1842404039144343) node {$F$};
            \draw [fill=xdxdff] (1.7798228040999855,0.3869455192360619) circle (1.5pt);
            \draw[color=xdxdff] (1.7669147889514822,0.28668273416401674) node {$G$};
            \draw [fill=xdxdff] (3.364647193570481,0.4733599777408055) circle (1.5pt);
            \draw[color=xdxdff] (3.3840773391167867,0.3584117182439294) node {$H$};
        \end{scriptsize}
    \end{tikzpicture}
\end{document}

标签距离节点太近:

在此处输入图片描述

答案1

label distance影响labels 而不是node像代码中那样明确绘制的 s。但是,在这种情况下,您可以通过等调整位置aboveright

\documentclass[10pt]{article}

\usepackage{pgf,tikz}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\pagestyle{empty}

\begin{document}
\definecolor{xdxdff}{rgb}{0.49019607843137253,0.49019607843137253,1.}
\definecolor{uuuuuu}{rgb}{0.26666666666666666,0.26666666666666666,0.26666666666666666}
\definecolor{qqqqff}{rgb}{0.,0.,1.}
    \begin{tikzpicture}[label distance = 0.5cm, line cap=round,line join=round,>=triangle 45,x=1.3539289842855764cm,y=1.5233942677491352cm]
        \clip(-1.,-1.) rectangle (11.,6.);
        \draw (0.27364775674239095,3.5536119181673125)-- (1.1893105429946793,0.35474712702121464);
        \draw (1.1893105429946793,0.35474712702121464)-- (6.279319969251443,0.632286021094505);
        \draw (6.279319969251443,0.632286021094505)-- (2.3146633946526336,1.4604297463807696);
        \draw (2.3146633946526336,1.4604297463807696)-- (0.27364775674239095,3.5536119181673125);
        \draw [dotted] (1.1893105429946793,0.35474712702121464)-- (2.3146633946526336,1.4604297463807696);
        \draw [dotted] (0.27364775674239095,3.5536119181673125)-- (6.279319969251443,0.632286021094505);
        \draw (1.7519869688236565,0.9075884367009921)-- (1.7798228040999855,0.3869455192360619);
        \draw (3.276483862996917,2.0929489696309087)-- (3.364647193570481,0.4733599777408055);
        \begin{scriptsize}
            \draw [fill=qqqqff] (0.27364775674239095,3.5536119181673125) circle (1.5pt);
            \draw[color=qqqqff] (0.1693146889897907,3.6775074361235256) node {$A$};
            \draw [fill=qqqqff] (1.1893105429946793,0.35474712702121464) circle (1.5pt);
            \draw[color=qqqqff] (1.0626665816214305,0.29320355089855427) node[below] {$B$};
            \draw [fill=qqqqff] (6.279319969251443,0.632286021094505) circle (1.5pt);
            \draw[color=qqqqff] (6.403215487207657,0.6518484712981176) node[right] {$C$};
            \draw [fill=qqqqff] (2.3146633946526336,1.4604297463807696) circle (1.5pt);
            \draw[color=qqqqff] (2.360309111794397,1.5517211806642952) node[above] {$D$};
            \draw [fill=uuuuuu] (1.7519869688236565,0.9075884367009921) circle (1.5pt);
            \draw[color=uuuuuu] (1.7017066216061072,1.0561391088394438) node {$E$};
            \draw [fill=uuuuuu] (3.276483862996917,2.0929489696309087) circle (1.5pt);
            \draw[color=uuuuuu] (3.3188691717714116,2.1842404039144343) node[above] {$F$};
            \draw [fill=xdxdff] (1.7798228040999855,0.3869455192360619) circle (1.5pt);
            \draw[color=xdxdff] (1.7669147889514822,0.28668273416401674) node[below] {$G$};
            \draw [fill=xdxdff] (3.364647193570481,0.4733599777408055) circle (1.5pt);
            \draw[color=xdxdff] (3.3840773391167867,0.3584117182439294) node[below] {$H$};
        \end{scriptsize}
    \end{tikzpicture}
\end{document}

在此处输入图片描述

您也可以在above等中使用距离right=2mm。例如,将其node[right=-1mm] {$C$};用于C节点并查看差异。

答案2

我会将命令转换\draw\path命令,并沿着相应的线定位标签。然后,您将获得具有标准距离的完美对齐的标签。看看我如何对D和进行操作B。使用distposdistneg作为相应路径开头或结尾处的节点。

\documentclass[10pt]{article}

\usepackage{pgf,tikz}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\pagestyle{empty}

\def\distpos{-1.16}
\def\distneg{0.16}

\begin{document}
\definecolor{xdxdff}{rgb}{0.49019607843137253,0.49019607843137253,1.}
\definecolor{uuuuuu}{rgb}{0.26666666666666666,0.26666666666666666,0.26666666666666666}
\definecolor{qqqqff}{rgb}{0.,0.,1.}
    \begin{tikzpicture}[label distance = 0.5cm, line cap=round,line join=round,>=triangle 45,x=1.3539289842855764cm,y=1.5233942677491352cm]
        \clip(-1.,-1.) rectangle (11.,6.);
        \draw (0.27364775674239095,3.5536119181673125)-- (1.1893105429946793,0.35474712702121464);
        \draw (1.1893105429946793,0.35474712702121464)-- (6.279319969251443,0.632286021094505);
        \draw (6.279319969251443,0.632286021094505)-- (2.3146633946526336,1.4604297463807696);
        \draw (2.3146633946526336,1.4604297463807696)-- (0.27364775674239095,3.5536119181673125);
        \path [draw,dotted] (1.1893105429946793,0.35474712702121464) edge node [font=\scriptsize, blue, pos=-\distneg] {$B$}  (2.3146633946526336,1.4604297463807696);
        \path (1.1893105429946793,0.35474712702121464) edge node [font=\scriptsize, blue, pos=-\distpos] {$D$}  (2.3146633946526336,1.4604297463807696);
        \draw [dotted] (0.27364775674239095,3.5536119181673125)-- (6.279319969251443,0.632286021094505);
        \draw (1.7519869688236565,0.9075884367009921)-- (1.7798228040999855,0.3869455192360619);
        \draw (3.276483862996917,2.0929489696309087)-- (3.364647193570481,0.4733599777408055);
        \begin{scriptsize}
            \draw [fill=qqqqff] (0.27364775674239095,3.5536119181673125) circle (1.5pt);
            \draw[color=qqqqff] (0.1693146889897907,3.6775074361235256) node {$A$};
            \draw [fill=qqqqff] (1.1893105429946793,0.35474712702121464) circle (1.5pt);
            \draw [fill=qqqqff] (6.279319969251443,0.632286021094505) circle (1.5pt);
            \draw[color=qqqqff] (6.403215487207657,0.6518484712981176) node {$C$};
            \draw [fill=qqqqff] (2.3146633946526336,1.4604297463807696) circle (1.5pt);
            \draw [fill=uuuuuu] (1.7519869688236565,0.9075884367009921) circle (1.5pt);
            \draw[color=uuuuuu] (1.7017066216061072,1.0561391088394438) node {$E$};
            \draw [fill=uuuuuu] (3.276483862996917,2.0929489696309087) circle (1.5pt);
            \draw[color=uuuuuu] (3.3188691717714116,2.1842404039144343) node {$F$};
            \draw [fill=xdxdff] (1.7798228040999855,0.3869455192360619) circle (1.5pt);
            \draw[color=xdxdff] (1.7669147889514822,0.28668273416401674) node {$G$};
            \draw [fill=xdxdff] (3.364647193570481,0.4733599777408055) circle (1.5pt);
            \draw[color=xdxdff] (3.3840773391167867,0.3584117182439294) node {$H$};
        \end{scriptsize}
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容