문제
레이블이 지정된 노드 외부에 상자를 그리고 있는데 상자가 내부 노드 위의 레이블을 설명하지 않습니다.
내 문서의 MWE는 다음과 같습니다.
\documentclass[10pt]{article}
\ExpandArgs{c}\newcommand{new@fontshape}{anything}
\usepackage[russian,indonesian]{babel}
\usepackage{newtx}
\usepackage{linguex}
\usepackage[none]{hyphenat}
\usepackage{geometry}
\usepackage{setspace}
\usepackage{booktabs}
\usepackage{tikz}
\usepackage{tikz-qtree}
\usepackage{gb4e}
\usepackage{adjustbox}
\usetikzlibrary{shapes.geometric, arrows, chains, decorations.pathreplacing, positioning, fit}
\AtBeginDocument{%
\DeclareFontFamilySubstitution{T2A}{\familydefault}{Tempora-TLF}%
}
\primebars
\let\emptyset\varnothing
\geometry{
a4paper,
margin=3cm
}
\newcommand{\?}[1]{\foreignlanguage{russian}{#1}}
\noautomath
\begin{document}
\vspace{5mm}
\section*{Hubungan sintaksis}
\vspace{5mm}
\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=2.5cm, text centered, draw=black, text width=3cm]
\tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
\tikzstyle{process} = [rectangle, minimum width=1cm, minimum height=1cm, text centered, draw=black, text width=2.5cm]
\tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30]
\tikzstyle{arrow} = [thick,->,>=stealth]
\tikzstyle{line} = [draw, -latex']
\def\layersep{2.5cm}
\begin{adjustbox}{width=\textwidth}
\begin{tikzpicture}[node distance=4cm, box/.style = {draw,black,inner sep=10pt,rounded corners=5pt}]
\node (kr) [process, label=above:{Agen}] {Kerusiaan};
\node (bn) [process, right of=kr, label=above:{Sasaran}] {Binan};
\path [line] (kr) -- node [text width=2.5cm,midway,above,align=center ] {Aksi} (bn);
\node[box,fit=(kr)(bn)] {};
\end{tikzpicture}\hspace{1cm}%
\begin{tikzpicture}[node distance=4cm, box/.style = {draw,black,inner sep=10pt,rounded corners=5pt}]
\node (kr) [process, label=above:{Agen}] {Binan};
\node (bn) [process, right of=kr, label=above:{Sasaran}] {Non-kerusiaan};
\path [line] (kr) -- node [text width=2.5cm,midway,above,align=center ] {Aksi} (bn);
\node[box,fit=(kr)(bn)] {};
\end{tikzpicture}\hspace{1cm}%
\begin{tikzpicture}[node distance=4cm, box/.style = {draw,black,inner sep=10pt,rounded corners=5pt}]
\node (kr) [process, label=above:{Agen}] {Binan};
\node (bn) [process, right of=kr, label=above:{Sasaran}] {Kerusiaan};
\path [line] (kr) -- node [text width=2.5cm,midway,above,align=center ] {Aksi} (bn);
\node[box,fit=(kr)(bn)] {};
\end{tikzpicture}
\end{adjustbox}
\end{document}
상자는 레이블이 각 노드의 일부라는 점을 무시합니다. 그냥 통과하고 라벨 위에 공간을 남기지 않습니다.
상자가 레이블을 통과하지 않고 그 위에 텍스트가 추가되기를 원합니다. 대략 다음과 같습니다.
내 코드를 어떻게 개선할 수 있나요?
내가 지금까지 한 일
sep
in 만 변경할 수 있다는 것을 알고 있지만 {draw,black,inner sep=10pt,rounded corners=5pt}
위쪽 상자 공간과 아래쪽 상자 공간 사이에 고르지 않은 공간이 생성됩니다.
\documentclass[10pt]{article}
\ExpandArgs{c}\newcommand{new@fontshape}{anything}
\usepackage[russian,indonesian]{babel}
\usepackage{newtx}
\usepackage{linguex}
\usepackage[none]{hyphenat}
\usepackage{geometry}
\usepackage{setspace}
\usepackage{booktabs}
\usepackage{tikz}
\usepackage{tikz-qtree}
\usepackage{gb4e}
\usepackage{adjustbox}
\usetikzlibrary{shapes.geometric, arrows, chains, decorations.pathreplacing, positioning, fit}
\AtBeginDocument{%
\DeclareFontFamilySubstitution{T2A}{\familydefault}{Tempora-TLF}%
}
\primebars
\let\emptyset\varnothing
\geometry{
a4paper,
margin=3cm
}
\newcommand{\?}[1]{\foreignlanguage{russian}{#1}}
\noautomath
\begin{document}
\vspace{5mm}
\section*{Hubungan sintaksis}
\vspace{5mm}
\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=2.5cm, text centered, draw=black, text width=3cm]
\tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
\tikzstyle{process} = [rectangle, minimum width=1cm, minimum height=1cm, text centered, draw=black, text width=2.5cm]
\tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30]
\tikzstyle{arrow} = [thick,->,>=stealth]
\tikzstyle{line} = [draw, -latex']
\def\layersep{2.5cm}
\begin{adjustbox}{width=\textwidth}
\begin{tikzpicture}[node distance=4cm, box/.style = {draw,black,inner sep=18pt,rounded corners=5pt}]
\node (kr) [process, label=above:{Agen}] {Kerusiaan};
\node (bn) [process, right of=kr, label=above:{Sasaran}] {Binan};
\path [line] (kr) -- node [text width=2.5cm,midway,above,align=center ] {Aksi} (bn);
\node[box,fit=(kr)(bn)] {};
\end{tikzpicture}\hspace{1cm}%
\begin{tikzpicture}[node distance=4cm, box/.style = {draw,black,inner sep=18pt,rounded corners=5pt}]
\node (kr) [process, label=above:{Agen}] {Binan};
\node (bn) [process, right of=kr, label=above:{Sasaran}] {Non-kerusiaan};
\path [line] (kr) -- node [text width=2.5cm,midway,above,align=center ] {Aksi} (bn);
\node[box,fit=(kr)(bn)] {};
\end{tikzpicture}\hspace{1cm}%
\begin{tikzpicture}[node distance=4cm, box/.style = {draw,black,inner sep=18pt,rounded corners=5pt}]
\node (kr) [process, label=above:{Agen}] {Binan};
\node (bn) [process, right of=kr, label=above:{Sasaran}] {Kerusiaan};
\path [line] (kr) -- node [text width=2.5cm,midway,above,align=center ] {Aksi} (bn);
\node[box,fit=(kr)(bn)] {};
\end{tikzpicture}
\end{adjustbox}
\end{document}
라벨의 위쪽 상자와 노드 아래쪽의 아래쪽 상자 사이의 공간이 동일해지도록 하고 싶습니다. 외부 상자 위에 텍스트가 추가되었습니다. 어떻게 해야 하나요?
답변1
이 코드를 통해 작동하게 만들었습니다.
\documentclass[10pt]{article}
\ExpandArgs{c}\newcommand{new@fontshape}{anything}
\usepackage[russian,indonesian]{babel}
\usepackage{newtx}
\usepackage{linguex}
\usepackage[none]{hyphenat}
\usepackage{geometry}
\usepackage{setspace}
\usepackage{booktabs}
\usepackage{tikz}
\usepackage{tikz-qtree}
\usepackage{gb4e}
\usepackage{adjustbox}
\usetikzlibrary{shapes.geometric, arrows, chains, decorations.pathreplacing, positioning, fit}
\AtBeginDocument{%
\DeclareFontFamilySubstitution{T2A}{\familydefault}{Tempora-TLF}%
}
\primebars
\let\emptyset\varnothing
\geometry{
a4paper,
margin=3cm
}
\newcommand{\?}[1]{\foreignlanguage{russian}{#1}}
\noautomath
\begin{document}
\vspace{5mm}
\section*{Hubungan sintaksis}
\vspace{5mm}
\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=2.5cm, text centered, draw=black, text width=3cm]
\tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
\tikzstyle{process} = [rectangle, minimum width=1cm, minimum height=1cm, text centered, draw=black, text width=2.5cm]
\tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30]
\tikzstyle{arrow} = [thick,->,>=stealth]
\tikzstyle{line} = [draw, -latex']
\def\layersep{2.5cm}
\begin{adjustbox}{width=\textwidth}
\begin{tikzpicture}[node distance=4cm, box/.style = {draw,black,inner sep=5pt,rounded corners=5pt}]
\node (kr) [process, fill=gray!15,thin,rounded corners] {Kerusiaan};
\node (bn) [process, fill=gray!60,thin,rounded corners, right of=kr] {Binan};
\node (n1) [inner sep=0pt,draw=none,above=2pt of kr] {Agen};
\node (n2) [inner sep=0pt,draw=none,above=3.5pt of bn] {Sasaran};
\path [line] (kr) -- node [text width=2.5cm,midway,above,align=center] {Aksi} (bn);
\path (kr) -- node[midway,draw=none,inner sep=2pt, above=12.5mm] {teks} (bn);
\node[box,fit=(kr)(bn)(n1)(n2)] {};
\end{tikzpicture}\hspace{1cm}%
\begin{tikzpicture}[node distance=4cm, box/.style = {draw,black,inner sep=5pt,rounded corners=5pt}]
\node (kr) [process, fill=gray!60,thin,rounded corners] {Binan};
\node (bn) [process, fill=gray!5,draw,dashed, right of=kr] {Non-kerusiaan};
\node (n1) [inner sep=0pt,draw=none,above=2pt of kr] {Agen};
\node (n2) [inner sep=0pt,draw=none,above=3.5pt of bn] {Sasaran};
\path [line] (kr) -- node [text width=2.5cm,midway,above,align=center ] {Aksi} (bn);
\path (kr) -- node[midway,draw=none,inner sep=2pt, above=12.5mm] {teks} (bn);
\node[box,fit=(kr)(bn)(n1)(n2)] {};
\end{tikzpicture}\hspace{1cm}%
\begin{tikzpicture}[node distance=4cm, box/.style = {draw,black,inner sep=5pt,rounded corners=5pt}]
\node (kr) [process, fill=gray!60,thin,rounded corners] {Binan};
\node (bn) [process, fill=gray!15,thin,rounded corners, right of=kr] {Kerusiaan};
\node (n1) [inner sep=0pt,draw=none,above=2pt of kr] {Agen};
\node (n2) [inner sep=0pt,draw=none,above=3.5pt of bn] {Sasaran};
\path [line] (kr) -- node [text width=2.5cm,midway,above,align=center ] {Aksi} (bn);
\path (kr) -- node[midway,draw=none,inner sep=2pt, above=12.5mm] {teks} (bn);
\node[box,fit=(kr)(bn)(n1)(n2)] {};
\end{tikzpicture}
\end{adjustbox}
\end{document}
또 다른 제안을 환영합니다!
답변2
세 가지 환경을 만드는 대신 tikzpicture
세 인물이 각각 환경에 있는 환경 하나만 만들어서 scope
서로 정확하게 배치할 수 있도록 합니다.
그런 다음 각 레이블이 Agen
정의되자마자 이름을 지정합니다.
\documentclass[10pt]{article}
\ExpandArgs{c}\newcommand{new@fontshape}{anything}
\usepackage[russian,indonesian]{babel}
\usepackage{newtx}
\usepackage{linguex}
\usepackage[none]{hyphenat}
\usepackage{geometry}
\usepackage{setspace}
\usepackage{booktabs}
\usepackage{tikz}
\usepackage{tikz-qtree}
\usepackage{gb4e}
\usepackage{adjustbox}
\usetikzlibrary{shapes.geometric, arrows, chains, decorations.pathreplacing, positioning, fit}
\AtBeginDocument{%
\DeclareFontFamilySubstitution{T2A}{\familydefault}{Tempora-TLF}%
}
\primebars
\let\emptyset\varnothing
\geometry{
a4paper,
margin=3cm
}
\newcommand{\?}[1]{\foreignlanguage{russian}{#1}}
\noautomath
\begin{document}
\vspace{5mm}
\section*{Hubungan sintaksis}
\vspace{5mm}
\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=2.5cm, text centered, draw=black, text width=3cm]
\tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
\tikzstyle{process} = [rectangle, minimum width=1cm, minimum height=1cm, text centered, draw=black, text width=2.5cm]
\tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30]
\tikzstyle{arrow} = [thick,->,>=stealth]
\tikzstyle{line} = [draw, -latex']
\def\layersep{2.5cm}
\begin{adjustbox}{width=\textwidth}
\begin{tikzpicture}[node distance=4cm, box/.style = {draw,black,inner sep=5pt,rounded corners=5pt}]
\node (kr) [process, label={[name=label 1]above:Agen}] {Kerusiaan};
\node (bn) [process, right of=kr, label=above:Sasaran] {Binan};
\path [line] (kr) -- node [text width=2.5cm,midway,above,align=center ] {Aksi} (bn);
\node[fit=(bn)(label 1),inner sep=0pt] (fit 1){};
\node[box,fit=(kr)(fit 1)] {};
\begin{scope}[xshift=8cm]
\node (kr) [process, label={[name=label 2]above:Agen}] {Binan};
\node (bn) [process, right of=kr, label=above:{Sasaran}] {Non-kerusiaan};
\path [line] (kr) -- node [text width=2.5cm,midway,above,align=center ] {Aksi} (bn);
\node[fit=(bn)(label 2),inner sep=0pt] (fit 2){};
\node[box,fit=(kr)(fit 2)] {};
\end{scope}
\begin{scope}[xshift=16cm]
\node (kr) [process, label={[name=label 3]above:Agen}] {Binan};
\node (bn) [process, right of=kr, label=above:{Sasaran}] {Kerusiaan};
\path [line] (kr) -- node [text width=2.5cm,midway,above,align=center ] {Aksi} (bn);
\node[fit=(bn)(label 3),inner sep=0pt] (fit 3){};
\node[box,fit=(kr)(fit 3)] {};
\end{scope}
\end{tikzpicture}
\end{adjustbox}
\end{document}