오른쪽에 있는 2개의 화살표의 올바른 위치를 찾는 데 문제가 있습니다. 나는 그들이 "중간"에 있기를 바랍니다.
암호:
\documentclass[12pt,a4paper]{scrartcl}
\begin{document}
\usetikzlibrary{decorations.markings}
\usepackage{tikz}
\begin{figure}[htbp]
\centering
\begin{minipage}[b]{.4\linewidth}
\begin{tikzpicture}
\node (System) [draw,minimum size=24mm] {Motor};
\coordinate[above left = of System.west] (a1);
\coordinate[below = 7mm of a1] (a2);
\coordinate[below = 7mm of a2] (a3);
\coordinate[below = 6.5mm of a3] (a4);
\coordinate[above right= of System.east] (b1);
\foreach \i [count=\xi from 1] in {2,...,5}
\coordinate[below=of b\xi] (b\i);
\foreach \i [count=\xi from 1] in {$u_\mathrm{a}$,$i_\mathrm{a}$,$u_\mathrm{f}$,$i_\mathrm{f}$}
\draw[-latex'] (a\xi) node[left] {\i} -- (a\xi-| System.west);
\foreach \i [count=\xi from 1] in {$n$,$M$}
\draw[-latex'] (System.east |- b\xi) -- (b\xi) node[right] {\i};
\end{tikzpicture}
\caption{GSM als Motor}
\label{fig:gsmmotor}
\end{minipage}
\qquad
\begin{minipage}[b]{.4\linewidth}
\begin{tikzpicture}
\node (System) [draw,minimum size=24mm] {Generator};
\coordinate[above left = of System.west] (a1);
\coordinate[below = 7mm of a1] (a2);
\coordinate[below = 7mm of a2] (a3);
\coordinate[below = 6.5mm of a3] (a4);
\coordinate[above right= of System.east] (b1);
\foreach \i [count=\xi from 1] in {2,...,5}
\coordinate[below=of b\xi] (b\i);
\foreach \i [count=\xi from 1] in {$n$,$M$,$u_\mathrm{f}$,$i_\mathrm{f}$}
\draw[-latex'] (a\xi) node[left] {\i} -- (a\xi-| System.west);
\foreach \i [count=\xi from 1] in {$u_a$,$i_a$}
\draw[-latex'] (System.east |- b\xi) -- (b\xi) node[right] {\i};
\end{tikzpicture}
\caption{GSM als Generator}
\label{fig:gsmgenerator}
\end{minipage}
\end{figure}
\end{document}
화살표를 중앙에 맞추려면 어떻게 해야 하나요?
감사해요!
답변1
기반내 대답:
\documentclass[12pt,a4paper]{scrartcl}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
positioning}
\begin{document}
\begin{figure}[htbp]
\centering
\begin{minipage}[b]{.4\linewidth}
\centering
\begin{tikzpicture}[
node distance = 3mm and 12mm
]
\node (System) [draw,minimum size=24mm] {Motor};
%
\coordinate[above left = of System.west, label=left:$u_a$] (a2);
\coordinate[above = 6mm of a2, label=left:$i_a$] (a1);
\coordinate[below left = of System.west, label=left:$u_f$] (a3);
\coordinate[below = 6mm of a3, label=left:$u_f$] (a4);
%
\coordinate[above right = of System.east, label=right:$n$] (b1);
\coordinate[below right = of System.east, label=right:$M$] (b2);
%
\foreach \i in {1,...,4}{\draw[-Latex] (a\i) -- (a\i -| System.west);}
\foreach \i in {1,2}{\draw[-Latex] (b\i -| System.east) -- (b\i);}
\end{tikzpicture}
\caption{GSM als Motor}
\label{fig:mimo}
\end{minipage}
\hfil
\begin{minipage}[b]{.4\linewidth}
\centering
\begin{tikzpicture}[
node distance = 3mm and 12mm
]
\node (System) [draw,minimum size=24mm] {Generator};
%
\coordinate[above left = of System.west, label=left:$n$] (a2);
\coordinate[above = 6mm of a2, label=left:$M$] (a1);
\coordinate[below left = of System.west, label=left:$u_3$] (a3);
\coordinate[below = 6mm of a3, label=left:$u_2$] (a4);
%
\coordinate[above right = of System.east, label=right:$u_a$] (b1);
\coordinate[below right = of System.east, label=right:$i_a$] (b2);
%
\foreach \i in {1,...,4}{\draw[-Latex] (a\i) -- (a\i -| System.west);}
\foreach \i in {1,2}{\draw[-Latex] (b\i -| System.east) -- (b\i);}
\end{tikzpicture}
\caption{GSM als Generator}
\label{fig:mimo}
\end{minipage}
\end{figure}
\end{document}
답변2
이를 위해서는 라이브러리나 복잡한 명령이 필요하지 않습니다. 를 사용하면 pos=<fraction>
각 가장자리의 일부 파벌 위치에 좌표를 추가한 다음 화살표와 노드를 추가할 수 있습니다. 이 모든 것은 다음과 같이 간단합니다.
\path (System.south west) -- (System.north west)
foreach \X/\Z in {0.05/i_f,0.35/u_f,0.65/M,0.95/n}
{coordinate[pos=\X](aux) (aux) edge[latex-] ++ (-1,0)
node[left=1cm]{$\Z$}};
MWE:
\documentclass[12pt,a4paper]{scrartcl}
\usepackage{tikz}
\begin{document}
\begin{figure}[htbp]
\centering
\begin{minipage}[b]{.4\linewidth}
\begin{tikzpicture}
\node (System) [draw,minimum size=24mm] {Motor};
\path (System.south west) -- (System.north west)
foreach \X/\Z in {0.05/i_f,0.35/u_f,0.65/M,0.95/n}
{coordinate[pos=\X](aux) (aux) edge[latex-] ++ (-1,0)
node[left=1cm]{$\Z$}};
\path (System.south east) -- (System.north east)
foreach \X/\Z in {0.3/u_a,0.7/i_a}
{coordinate[pos=\X] (aux) (aux) edge[-latex] ++ (1,0) node[right=1cm]{$\Z$}};
\end{tikzpicture}
\caption{GSM als Motor.}
\label{fig:gsmmotor}
\end{minipage}
\qquad
\begin{minipage}[b]{.4\linewidth}
\begin{tikzpicture}
\node (System) [draw,minimum size=24mm] {Motor};
\path (System.south west) -- (System.north west)
foreach \X/\Z in {0.05/i_f,0.35/u_f,0.65/M,0.95/n}
{coordinate[pos=\X](aux) (aux) edge[latex-] ++ (-1,0)
node[left=1cm]{$\Z$}};
\path (System.south east) -- (System.north east)
foreach \X/\Z in {0.3/u_a,0.7/i_a}
{coordinate[pos=\X] (aux) (aux) edge[-latex] ++ (1,0) node[right=1cm]{$\Z$}};
\end{tikzpicture}
\caption{GSM als Generator.}
\label{fig:gsmgenerator}
\end{minipage}
\end{figure}
\end{document}
답변3
두 개의 화살표를 배치하려면가운데, 나는 당신이 원한다고 생각했습니다(제가 착각하지 않았으면 좋겠습니다)이 두 개의 화살표는제삼그리고3분의 2측면의. 이를 위해 저는
calc
이러한 제3자를 정확하게 찾을 수 있는 라이브러리를 사용합니다.\coordinate (u) at ($(System.north east)!.3333!(System.south east)$); \coordinate (i) at ($(System.north east)!.6666!(System.south east)$);
가로로 배치하려면
arrow
먼저 텍스트를right
각제삼시스템 노드의 다음 구문을 사용하여 화살표를 그립니다edge
.\node[right =of u]{$n$}edge[<-](u); \node[right =of i]{$M$}edge[<-](i);
나는 TikZ와 함께 두 인물을 나란히 배치할 자유를 얻었습니다. 이를 위해 각각의
scope
환경을 배치하고 두 번째 환경을xshift=7cm
. 각 범위 환경에 이름을 지정했으며local bounding box=motor
,local bounding box=generator
이를 통해 아래에 텍스트를 매우 쉽게 배치할 수 있습니다.\begin{scope}[local bounding box=motor] % code for figure 1 % ... \end{scope} \node [anchor=north,text width=6cm]at (motor.south) {\captionof{figure}{GSM als Motor}}; % caption text
\begin{scope}[xshift=7cm,local bounding box=generator] % code for figure 2 % .... \end{scope} \node [anchor=north,text width=6cm]at (generator.south) {\captionof{figure}{GSM als Generator}}; % caption text
밑줄 친 것처럼 숫자에 수동으로 번호를 매기지 않으려면토르비욘 T첫 번째 솔루션에서는
capt-of
부동 개체에 번호를 매길 수 있는 패키지를 사용했습니다.- 그래서 저는 더 이상 사용하지 않는 코드의 모든 줄에 대해 (삭제하지 않고) 주석을 달았습니다.
www.DeepL.com/Translator로 번역됨
\documentclass[12pt,a4paper]{scrartcl}
\usepackage{tikz,capt-of}
\usetikzlibrary{decorations.markings,positioning,arrows,calc}
\begin{document}
%\begin{figure}[htbp]
\centering
%\begin{minipage}[b]{.4\linewidth}
\begin{tikzpicture}
\begin{scope}[local bounding box=motor]
\node (System) [draw,minimum size=24mm] {Motor};
\coordinate[above left = of System.west] (a1);
\coordinate[below = 7mm of a1] (a2);
\coordinate[below = 7mm of a2] (a3);
\coordinate[below = 6.5mm of a3] (a4);
\coordinate[above right= of System.east] (b1);
\foreach \i [count=\xi from 1] in {2,...,5}
\coordinate[below=of b\xi] (b\i);
\foreach \i [count=\xi from 1] in {$u_\mathrm{a}$,$i_\mathrm{a}$,$u_\mathrm{f}$,$i_\mathrm{f}$}
\draw[-latex'] (a\xi) node[left] {\i} -- (a\xi-| System.west);
% \foreach \i [count=\xi from 1] in {$n$,$M$}
% \draw[-latex'] (System.east |- b\xi) -- (b\xi) node[right] {\i};
\coordinate (u) at ($(System.north east)!.3333!(System.south east)$);
\coordinate (i) at ($(System.north east)!.6666!(System.south east)$);
\node[right =of u]{$n$}edge[<-](u);
\node[right =of i]{$M$}edge[<-](i);
\end{scope}
%\node[anchor=north,yshift=-5mm] at (motor.south){Figure\,1: GSM als Motor};
\node [anchor=north,text width=6cm]at (motor.south) {\captionof{figure}{GSM als Motor}};
% \end{tikzpicture}
% \caption{GSM als Motor}
% \label{fig:gsmmotor}
%\end{minipage}
%\qquad
%\begin{minipage}[b]{.4\linewidth}
% \begin{tikzpicture}
\begin{scope}[xshift=7cm,local bounding box=generator]
\node (System) [draw,minimum size=24mm] {Generator};
\coordinate[above left = of System.west] (a1);
\coordinate[below = 7mm of a1] (a2);
\coordinate[below = 7mm of a2] (a3);
\coordinate[below = 6.5mm of a3] (a4);
\coordinate[above right= of System.east] (b1);
\foreach \i [count=\xi from 1] in {2,...,5}
\coordinate[below=of b\xi] (b\i);
\foreach \i [count=\xi from 1] in {$n$,$M$,$u_\mathrm{f}$,$i_\mathrm{f}$}
\draw[-latex'] (a\xi) node[left] {\i} -- (a\xi-| System.west);
% \foreach \i [count=\xi from 1] in {$u_a$,$i_a$}
% \draw[-latex'] (System.east |- b\xi) -- (b\xi) node[right] {\i};
\coordinate (u) at ($(System.north east)!.3333!(System.south east)$);
\coordinate (i) at ($(System.north east)!.6666!(System.south east)$);
\node[right =of u]{$u_a$}edge[<-](u);
\node[right =of i]{$i_a$}edge[<-](i);
\end{scope}
%\node[anchor=north,yshift=-5mm] at (generator.south){Figure\,2: GSM als Generator};
\node [anchor=north,text width=6cm]at (generator.south) {\captionof{figure}{GSM als Generator}};
\end{tikzpicture}
% \caption{GSM als Generator}
\label{fig:gsmgenerator}
%\end{minipage}
%\end{figure}
\end{document}