ワンライナー: ライン -> ノード -> ライン

ワンライナー: ライン -> ノード -> ライン

この図を TikZ の 1 行だけで描画する方法はありますか?

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

これは

\node (A) [draw] {$h(t)$};
\draw (A.west) +(-1,0) circle (2pt) node [left] {$x(t)$} -- (A);
\draw (A.east) -- +(1,0) circle (2pt) node [right] {$y(t)=h(t)*x(t)$};

しかし、私はこれを1行で最適化する方法を探しています(現在のコードはかなり冗長です)。これが私の試みです

\draw (0,0) circle (2pt) node [left] {$x(t)$} -- ++(1,0) node [draw,right] {$h(t)$} -- +(1,0) circle (2pt) node [right] {$y(t)=h(t)*x(t)$};

これにより、次のようになります。

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

明らかに、これは機能しません。なぜなら、パスは (A.west) から進み、ボックスにぶつかるだけだからです。

答え1

以下に示す 2 つのオプションはどちらも次のものを生成します。

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

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\begin{document}
% first option
\begin{tikzpicture}
\draw (0,0) node[left] {$x(t)$} circle[radius=2pt] -- node[draw,fill=white]{$h(t)$} (3,0) circle[radius=2pt] node[right] {$y(t) = h(t) \ast x(t)$};
\end{tikzpicture}
% second option
\begin{tikzpicture} % four lines just to easier see what happens, you can write it in one
\draw (0,0) circle[radius=2pt] -- (3,0) circle[radius=2pt]
   node[pos=0,left] {$x(t)$} 
   node[midway,draw,fill=white]{$h(t)$} 
   node[pos=1,right] {$y(t) = h(t) * x(t)$};
\end{tikzpicture}
\end{document}

少し異なるアプローチ:

\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw node (a) [draw] {$h(t)$} (a.west) -- ++(-1,0) node[left] {$x(t)$} circle[radius=2pt] (a.east) -- ++(1,0) node[right] {$y(t)=h(t)*x(t)$} circle[radius=2pt];
\end{tikzpicture}
\end{document}

関連情報