ブロックの中心からではない複数の矢印を持つ TikZ ブロック図

ブロックの中心からではない複数の矢印を持つ TikZ ブロック図

かなりシンプルな図を作成しようとしていますが、ノードの中心から離れずに左側の複数の矢印を取得する方法がわかりません。

作成したいブロック図

答え1

2 つのオプション: アンカーとシフトを使用する方法と、次の<name>.<angle >構文を使用する方法:

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\node[draw,minimum size=2cm] (x) {X};
\draw[->] ([yshift=-10pt]x.west) -- node[fill=white] {a} +(-1cm,0pt);
\draw[->] ([yshift=10pt]x.west) -- node[fill=white] {b} +(-1cm,0pt);
\draw[->] (x.120) -- node[fill=white] {c} +(0pt,1cm);
\draw[->] (x.60) -- node[fill=white] {d} +(0pt,1cm);
\end{tikzpicture}

\end{document}

ここに画像の説明を入力してください

としてクラウディオ・フィアンドリーノ言及した彼のコメントもう一つのオプションはライブラリを使用することですcalc。この場合、シフトは絶対的ではありませんが、アンカーの観点から計算できます。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}
\node[draw,minimum size=2cm] (x) {X};
\draw[->] ([yshift=-10pt]x.west) -- node[fill=white] {a} +(-1cm,0pt);
\draw[->] ([yshift=10pt]x.west) -- node[fill=white] {b} +(-1cm,0pt);
\draw[->] (x.120) -- node[fill=white] {c} +(0pt,1cm);
\draw[->] (x.60) -- node[fill=white] {d} +(0pt,1cm);
\draw[->]
  ( $ (x.north east)!0.5!(x.east) $ ) -- 
    node[fill=white] {e} 
  +(1cm,0pt);
\draw[->] 
  ( $ (x.east)!0.5!(x.south east) $ ) -- 
    node[fill=white] {f} 
    +(1cm,0pt);
\end{tikzpicture}

\end{document}

ここに画像の説明を入力してください

上記の例では、は と( $ (x.north east)!0.5!(x.east) $ )の中間の座標にある点を意味します。x.north eastx.east

答え2

PSTricks のソリューション:

\documentclass{article}

\usepackage{pstricks-add}
\usepackage{xfp}

\newcommand*\Width{\fpeval{2*\arrowLength+\boxLength}}
\newcommand*\Height{\boxLength}

\def\arrowLength{3}
\def\boxLength{3}


\begin{document}

\begin{pspicture}(\Width,\Height)
 \psset{arrows = ->}
  \psframe(\arrowLength,0)(\fpeval{\arrowLength+\boxLength},\boxLength)
  \rput(\fpeval{\arrowLength+0.5*\boxLength},\fpeval{0.5*\boxLength}){X}
  \pcline(\arrowLength,\fpeval{\boxLength/3})(0,\fpeval{\boxLength/3})
  \ncput*{a}
  \pcline(\arrowLength,\fpeval{2/3*\boxLength})(0,\fpeval{2/3*\boxLength})
  \ncput*{b}
  \pcline(\fpeval{2*\arrowLength+\boxLength},\fpeval{0.5*\boxLength})%
         (\fpeval{\arrowLength+\boxLength},\fpeval{0.5*\boxLength})
  \ncput*{c}
\end{pspicture}

\end{document}

出力

\arrowLength描画は「自動化」されており、との値を選択するだけでよいことに注意してください\boxLength

関連情報