下面的标签放错了

下面的标签放错了

知道为什么放置在“下方”的标签(例如:B)放错了位置,而上方、左侧和右侧的标签却放对了位置吗?

在此处输入图片描述

%%%%%%%%%%%%%%%%%% INTRODUCTION %%%%%%%%%%%%%%%%%%
\documentclass[border=10pt]{standalone}
%%%%%%%%%%%%%%%%%% PACKAGE %%%%%%%%%%%%%%%%%%
\usepackage{tikz, tkz-euclide}%  permet de dessiner des figures, des graphiques
\usepackage{adjustbox}% permet de déterminer une taille de fenêtre
%%  FONT
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tgadventor}% paquet de police de caractère TGadventor
\usepackage{sansmath}%  Copie-colle la police active dans 
%                       \sfdefault (/!\ N'EST PAS UNE POLICE DE CARACTÈRES)
\usepackage{xcolor}
%%%%%%%%%%%%%%%%%% INPUT %%%%%%%%%%%%%%%%%%
%\input{preamble.tex}
%\input{parameters.tex}

%\input{types/f2d_figlab}
%%%%%%%%%%%%%%%%%% SETUP %%%%%%%%%%%%%%%%%%
\tikzset{
    fig2D/.style={font={\sansmath\sffamily\Large}, line width=0.4mm, line cap=round, line join=round, >=latex, x=1.0cm, y=1.0cm,},
    %%%%%%%%%%%%%%%%%%%%%%%% DOTTED TRIANGLOID %%%%%%%%%%%%%%%%%%%%%%%%
    pics/dotted triangloid/.style={code={%
    \tikzset{triangloid/.cd,#1}%
    \def\pv##1{\pgfkeysvalueof{/tikz/triangloid/##1}}
    \draw [solid, pic actions, fill=\pv{fill}]
    %%  point o - bas gauche
    (0,0) coordinate (o)
    node [circle, fill=black, scale=0.5, label={[\pv{poso}, inner sep=\pv{inner sep},]\pv{labo}}] {}
    %% point a - bas droite
    (\pv{scale}*\pv{width},0) coordinate (a)
    node [circle, fill=black, scale=0.5, label={[\pv{posa}, inner sep=\pv{inner sep},]\pv{laba}}] {}
    %% point b - sommet
    ({\pv{scale}*\pv{offset})},\pv{scale}*\pv{height}) coordinate (b)
    node [circle, fill=black, scale=0.5, label={[\pv{posb}, inner sep=\pv{inner sep},]\pv{labb}}] {}
    %% jonction entre les points
     (o) 
     -- (a) 
     node [midway, label={[\pv{posA}, inner sep=\pv{inner sep},shift={(0pt,-6pt)}]\pv{labA}}] {}
     -- (b)
     node [midway, label={[\pv{posB}, inner sep=\pv{inner sep},]\pv{labB}}] {}
     -- (o)
     node [midway, label={[\pv{posC}, inner sep=\pv{inner sep},,shift={(-2pt,0pt)}]\pv{labC}}] {}
     ;
  }},
  triangloid/.cd,
  width/.initial=5,
  height/.initial=2,
  offset/.initial=0,
  labA/.initial=,
  labB/.initial=,
  labC/.initial=,
  labo/.initial=,
  laba/.initial=,
  labb/.initial=,
  posA/.initial=below,
  posB/.initial=above right,
  posC/.initial=left,
  poso/.initial=below,
  posa/.initial=below,
  posb/.initial=above,
  inner sep/.initial=0pt,
  fill/.initial=black!0,
  scale/.initial=1,
}
%%%%%%%%%%%%%%%%%% DOCUMENT %%%%%%%%%%%%%%%%%%
\begin{document}
\begin{tikzpicture}[fig2D]

\pic {dotted triangloid={width=8.82, height=6.47, offset=2.35, labo=B, laba=C, labb=A, posa=right, inner sep=0pt, fill= orange!20}};

\path
    (o) -- (b) node [circle, pos=0.333, fill=black, scale=0.5, label=below right: D] (d) {}
    (a) -- (b) node [circle, pos=0.333, fill=black, scale=0.5, label=below left: E] (e) {}
;

\draw
    %%%     Tracé segment DE
    (d) -- (e)
    %%%     Tracé segment en pointillé
    (o) +(-3pt, 3pt) coordinate (o')
    (b) +(-5pt, -3pt) coordinate (b')
    (o') edge[<->, densely dashed,] node [left, inner sep=6pt]{12 cm} (b')
    %
    (d) +(3pt, 3pt) coordinate (d')
    (e) +(-3pt, 3pt) coordinate (e')
    (d') edge[<->, densely dashed,] node [above, inner sep=6pt]{6 cm} (e')
    %
    (o) +(3pt, -3pt) coordinate (o'')
    (a) +(-3pt, -3pt) coordinate (a')
    (o'') edge[<->, densely dashed,] node [below, inner sep=10pt]{10 cm} (a')
;

\end{tikzpicture}
\end{document}

答案1

摘要:改变

node [circle, fill=black, scale=0.5, label={[\pv{poso}, inner sep=\pv{inner sep},]\pv{labo}}] {}

node [circle, fill=black, scale=0.5, label={[inner sep=\pv{inner sep},]\pv{poso}:\pv{labo}}] {}

其它标签也类似。


语法label

label={[<options>]<angle>:<text>}

其中<angle>定义标签相对于其所属节点的位置。您使用了语法

label={[<options>]<text>}

省略<angle>:。如手册中所述,如果<angle>缺少 ,above则使用 ,即标签放置在节点上方。

你的poso等被添加为标签样式的一部分,这意味着它们只影响标签节点的锚点,不是相对于“父”节点的位置请看这个简化的例子:

在此处输入图片描述

\documentclass[border=1mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node [circle, fill=black!50, label={[inner sep=0,draw=blue,ultra thin,above]B}] {};
\node [circle, fill=black!50, label={[inner sep=0,draw=blue,ultra thin,below]B}] at (0.5,0) {};
\node [circle, fill=black!50, label={[inner sep=0,draw=blue,ultra thin]below:B}] at (1,0) {};
\end{tikzpicture}
\end{document}

左侧标签的above样式为 ,这只是 的另一种说法anchor=south。中间的标签为below,意思是anchor=north。如您所见,south左侧标签上的锚点相对于节点的位置与north中间标签上的锚点相同。

然而,在右侧标签中,below添加为<angle>,因此标签被放置在节点下方(并且anchor=north默认情况下为)。

相关内容