길이가 다양한 노드를 조화롭게 배치

길이가 다양한 노드를 조화롭게 배치

코드

\documentclass{article}
\usepackage{tikz}
\begin{document}
  \begin{tikzpicture}[font=\footnotesize, very thick]
  \def\r{3}
  \foreach \a/\n in {-2/{p-2}, -1/{p-1}, 0/0, 1/1, 2/2, 3/3, 4/4}
     \node[anchor=base] (\a) at (90+36*\a:\r) {$\circ$};
  \node (-3) at (90+36*-3:\r) {};
  \node (5) at (90+36*5:\r) {};
  \foreach \a/\name [remember=\a as \lasta (initially -3)] 
                in {-2/{p-3}, -1/{p-2}, 0/{p-1}, 1/0, 2/1, 3/2, 4/3, 5/4}
    {
    \draw[->, shorten >=5pt, shorten <=5pt] 
        (\lasta) 
        arc[radius=\r, start angle=90+36*(\lasta), end angle=90+36*(\a)]
        (\a);
    \node at (90+36*\lasta+18:\r+0.5) {$\alpha_{\name}$};
    }
  \foreach \a in { 1, ..., 14 } 
    {
    \node at (90+36*5+5*\a:\r) {$\cdot$};
    }
  \end{tikzpicture}
\end{document}

다음 그림을 생성합니다 여기에 이미지 설명을 입력하세요

나는 화살표에 라벨을 붙이는 것이 다소 혼란스럽다고 생각합니다. 나는 꽤 많은 것을 시도했지만 항상 다소 비대칭적인 위치로 끝났습니다.

그들이 잘 행동하게 할 수 있는 방법이 있나요?

물론 정확한 의미는여기에서는 해석이 가능하지만, 예를 들어 최소한 알파가 화살표에서 보다 일관된 거리에 표시되기를 바랍니다.

추신. 호를 따라 노드가 아닌 손으로 라벨을 붙이고 있습니다. 그렇게 하면 더 좋을 것 같지만 이것이 나쁜 선택이리라 예상합니다...

답변1

나는 그 지점에 대한 앵커를 설정할 것입니다.

\documentclass[border=25pt]{standalone}
\usepackage{tikz}
\newcommand\aesub[1]{\makebox[0pt][l]{\raisebox{0pt}[\height][0pt]{\scriptsize$#1$}}}
\begin{document}
  \begin{tikzpicture}[font=\footnotesize, very thick]
  \def\r{3}
  \foreach \a/\n in {-2/{p-2}, -1/{p-1}, 0/0, 1/1, 2/2, 3/3, 4/4}
     \node[anchor=base] (\a) at (90+36*\a:\r) {$\circ$};
  \node (-3) at (90+36*-3:\r) {};
  \node (5) at (90+36*5:\r) {};
  \foreach \a/\name [remember=\a as \lasta (initially -3)] 
                in {-2/{p-3}, -1/{p-2}, 0/{p-1}, 1/0, 2/1, 3/2, 4/3, 5/4}
    {
    \draw[->, shorten >=5pt, shorten <=5pt] 
        (\lasta) 
        arc[radius=\r, start angle=90+36*(\lasta), end angle=90+36*(\a)]
        (\a);
    %% to avoid writing the same thing multiple times
    \pgfmathsetmacro\aeangle{90+36*\lasta+18}
    %% to see the node
    \node[circle,inner sep=0.5pt,fill] at (\aeangle:\r+0.5) {};
    \node[anchor=(\aeangle+180),outer sep=0pt,inner sep=0pt] at (\aeangle:\r+0.5) {$\alpha_{\aesub{\name}}$};
    %% old style for comparison purposes
    %% \node[anchor=(\aeangle+180),outer sep=0pt,inner sep=0pt] at (\aeangle:\r+0.5) {$\alpha_{\name}$};
    }
  \foreach \a in { 1, ..., 14 } 
    {
    \node at (90+36*5+5*\a:\r) {$\cdot$};
    }
  \end{tikzpicture}
\end{document}

여기에 이미지 설명을 입력하세요

배치를 더 잘 볼 수 있도록 노드를 표시했습니다. 해당 줄을 주석 처리하면 됩니다. 또한 아래 첨자를 너비가 0, 높이가 0, 깊이가 0인 상자로 만드는 명령을 추가했습니다. 원래 높이가 거기에 남아 있어서 아래 첨자가 올바르게 배치됩니다(예: 너무 높지 않음). 이로 인해 경계 상자가 제대로 설정되지 않은 약간 바람직하지 않은 결과가 발생합니다. 그러나 그렇지 않은 경우 이 솔루션은 $\alpha_{...}$ 전체가 아닌 $\alpha$에 앵커를 설정합니다. 전체 라벨 이름에 대한 설정이 있는 경우 매크로를 사용하지 마세요 \aesub.

답변2

이것이 더 심미적으로 좋아 보이는가?

오프셋 라벨

\documentclass{article}
\usepackage{tikz}

\newlength{\tempwidth}

\begin{document}
  \begin{tikzpicture}[font=\footnotesize, very thick]
  \def\r{3}
  \foreach \a/\n in {-2/{p-2}, -1/{p-1}, 0/0, 1/1, 2/2, 3/3, 4/4}
     \node[anchor=base] (\a) at (90+36*\a:\r) {$\circ$};
  \node (-3) at (90+36*-3:\r) {};
  \node (5) at (90+36*5:\r) {};
  \foreach \a/\name [remember=\a as \lasta (initially -3)] 
                in {-2/{p-3}, -1/{p-2}, 0/{p-1}, 1/0, 2/1, 3/2, 4/3, 5/4}
    {
    \draw[->, shorten >=5pt, shorten <=5pt] 
        (\lasta) 
        arc[radius=\r, start angle=90+36*(\lasta), end angle=90+36*(\a)]
        (\a);
    \pgfextra{\settowidth{\tempwidth}{$\alpha_{\name}$}
       \pgfmathparse{0.5+0.005\tempwidth*cos(90+36*\lasta+18)}% fudge factor 0.005
       \global\let\temp=\pgfmathresult}
     \node at (90+36*\lasta+18:\r+\temp) {$\alpha_{\name}$};
    }
  \foreach \a in { 1, ..., 14 } 
    {
    \node at (90+36*5+5*\a:\r) {$\cdot$};
    }
  \end{tikzpicture}
\end{document}

여기서 알파는 대칭입니다(아래 첨자는 무시됩니다).

rlap 첨자

\documentclass{standalone}
\usepackage{tikz}

\newlength{\tempwidth}

\begin{document}
  \begin{tikzpicture}[font=\footnotesize, very thick]
  \def\r{3}
  \foreach \a/\n in {-2/{p-2}, -1/{p-1}, 0/0, 1/1, 2/2, 3/3, 4/4}
     \node[anchor=base] (\a) at (90+36*\a:\r) {$\circ$};
  \node (-3) at (90+36*-3:\r) {};
  \node (5) at (90+36*5:\r) {};
  \foreach \a/\name [remember=\a as \lasta (initially -3)] 
                in {-2/{p-3}, -1/{p-2}, 0/{p-1}, 1/0, 2/1, 3/2, 4/3, 5/4}
    {
    \draw[->, shorten >=5pt, shorten <=5pt] 
        (\lasta) 
        arc[radius=\r, start angle=90+36*(\lasta), end angle=90+36*(\a)]
        (\a);
     \node at (90+36*\lasta+18:\r+0.5) {$\alpha_{\rlap{$\scriptstyle\name$}}$};
    }
  \foreach \a in { 1, ..., 14 } 
    {
    \node at (90+36*5+5*\a:\r) {$\cdot$};
    }
  \node at (3.5,0) {\phantom{$alpha_{p-3}$}};% push right border
  \end{tikzpicture}
\end{document}

관련 정보