한 줄짜리: 선 -> 노드 -> 선

한 줄짜리: 선 -> 노드 -> 선

TikZ의 한 줄만으로 이 다이어그램을 그릴 수 있는 방법이 있습니까?

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

이것은 다음과 같이 그려졌습니다.

\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)$};

하지만 한 줄로 최적화할 수 있는 방법을 찾고 있습니다(현재 코드는 상당히 중복됩니다). 내 시도는 다음과 같습니다

\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

아래에 설명된 두 가지 옵션은 모두 다음을 생성합니다.

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

\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}

관련 정보