가새 설명이 포함된 간격 그리기

가새 설명이 포함된 간격 그리기

보고서를 위해서는 LaTeX/TikZ로 그리고 싶은 다음 그림이 필요합니다.

아이디어는 실제 선에 이산적인 간격이 있고 이 간격 위에 어떤 요소가 그 안에 있는지 쓰고 싶다는 것입니다.

(예를 들어 제가 추가한 그림과 같습니다.)

이것을 그리는 좀 더 쉬운 방법이 있나요 tikz?

나는 함께 일한 적이 없으니 tikz이것을 그리는 데 도움을 주실 수 있습니까?

그러면 다른 간격으로 직접 변경할 수 있을 것 같습니다.

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

편집: 인터넷에서 코드를 찾아서 수정했습니다.

\begin{tikzpicture}[decoration=brace]
% Die Grundlinie:
\draw(0,0)--(10,0);
% Striche und Beschriftung in Abständen 0, 2, 4, 6, ...
\foreach \x/\xtext in {0/$-m-n+1$,2/$-m-1$,4/$-m$,6/$0$,8/$m$,10/$m+n-1$}
  \draw(\x,5pt)--(\x,-5pt) node[below] {\xtext};
% obere geschweifte Klammer mit Text darüber:
\draw[decorate, yshift=2ex]  (0,0) -- node[above=0.4ex] {$0$'s}  (2,0);
\draw[decorate, yshift=2ex]  (10,0) -- node[above=0.4ex] {$l$'s and $0$'s with $l$'s separated by at least two $0$'s}  (4,0);
 \end{tikzpicture}

내가 얻는 것은 다음과 같습니다.

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

두 번째 괄호가 반대인 이유는 무엇입니까?

답변1

라이브러리 의 버팀대에는 버팀대의 면 방향을 바꾸는 decorations.pathreplacing옵션이 있습니다 . mirror따라서 이것이 올바른 방향으로 나아가기 위해 추가해야 할 전부입니다. 다음과 같이 할 수 있습니다:

\documentclass[tikz,border=1mm]{standalone}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}

\begin{tikzpicture}
% Die Grundlinie:
\draw(0,0)--(10,0);
% Striche und Beschriftung in Abständen 0, 2, 4, 6, ...
\foreach \x/\xtext in {0/$-m-n+1$,2/$-m-1$,4/$-m$,6/$0$,8/$m$,10/$m+n-1$}
    \draw(\x,5pt)--(\x,-5pt) node[below] {\xtext};
% obere geschweifte Klammer mit Text darüber:
\draw[decorate, decoration={brace}, yshift=2ex]  (0,0) -- node[above=0.4ex] {$0$'s}  (2,0);
\draw[decorate, decoration={brace, mirror}, yshift=2ex]  (10,0) -- node[above=0.4ex] {$l$'s and $0$'s with $l$'s separated by at least two $0$'s}  (4,0);
\end{tikzpicture}

\end{document}

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

답변2

해결책 은 다음과 같습니다 pstricks.

\documentclass[a4paper, pdf, x11names]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{pstricks-add}
\usepackage{stackengine}
\setstackEOL{\\}

\begin{document}

\centering
\psset{braceWidthOuter=4pt, braceWidthInner=4pt, braceWidth=0.8pt, labelsep =2ex}
\begin{pspicture}
    \psset{linecolor =IndianRed3}
    \psline(-1.2,0)(13.2,0)
    \psdots[dotstyle=B|](0,0.02)(3,0.02)(4.2,0.02)(12,0.02)
    \pnodes(0,0.6ex){Z1}(3,0.6ex){Z2}(4.2,0.6ex){L1}(12,0.6ex){L2}
    \uput[d](Z1){$-m-n + 1$}\uput[d](Z2){$-m-1$\uput[d](L1){$-m$}}\uput[d](L2){$m + n - 1$}
    \psset{rot=-90,linecolor=SlateGray4}
    \psbrace*(Z2)(Z1){\makebox[0pt]{only $ 0 $’ s}}
    \psbrace*(L2)(L1){\makebox[0pt]{\Centerstack{$ 0 $’s and $ l $’s\\$l $’s separated by at least $ 2 $ $ 0 $’s}}}
\end{pspicture}

\end{document}

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

관련 정보