
我正在嘗試將 LaTeX 中的圖表從 PNG 轉換為 TikZ。我想要有兩個指向圓的箭頭,分別指向水平方向和指向圓的邊緣。我幾乎透過使用.west
座標來實現這一點,但它並不完全對齊:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}
[engine/.style={circle,minimum size=6cm,draw=black,font=\large
}, block/.style={
rectangle,minimum size=10cm,draw=black,dashed,font=\large
}, point/.style={
circle,inner sep=0pt,minimum size=0pt,fill=none
}
]
% Draw the rectangle containing the block diagram
\node (block) [block] at (0,0) {};
% Put a label at the top of the box
\node (blockname) [point] at (0, 4.5) {\large Module};
% A circle representing the engine
\node (engine) [engine] at (1,-1) {Engine};
% Inputs representing the network ports
\node (input1) [point] at (-6,-3) {};
\path (input1) edge [->] node [below] {Network A} (input1-|engine.west);
\node (input2) [point] at (-6,-0.5) {};
\path (input2) edge [->] node [above] {Network B} (input2-|engine.west);
% Output
\node (output) [point] at (-6,3) {};
\node (outputup) [point] at (1,3) {};
\path (outputup) edge [->,dashed]
node [above] {Management}
node [below] {Output}
(output);
\path (outputup) edge [->,dashed] (engine);
\end{tikzpicture}
\end{document}
這就是我所擁有的:
答案1
我認為你可以使用“相交路徑”,TikZ手冊第34頁和第35頁對此進行了描述(http://www.texample.net/media/pgf/builds/pgfmanualCVS2012-11-04.pdf)。
編輯
抱歉,由於缺乏時間,我的第一條評論...這是一個完整的示例,您的程式碼顯示瞭如何實現這一目標:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows, intersections}
\begin{document}
\begin{tikzpicture}
[engine/.style={circle,minimum size=6cm,draw=black,font=\large
}, block/.style={
rectangle,minimum size=10cm,draw=black,dashed,font=\large
}, point/.style={
circle,inner sep=0pt,minimum size=0pt,fill=none
}
]
% Draw the rectangle containing the block diagram
\node (block) [block] at (0,0) {};
% Put a label at the top of the box
\node (blockname) [point] at (0, 4.5) {\large Module};
% A circle representing the engine
\node (engine) [name path=engine, engine] at (1,-1) {Engine};
% Inputs representing the network ports
\node (input1) [point] at (-6,-3) {};
\path [name path=refline] (-6,-3) -- (6,-3);
\node (intersect) [name intersections={of=engine and refline, by=x}] at (intersection-1) {};
\path (input1) edge [->] node [below] {Network A} (input1-|intersect);
\node (input2) [point] at (-6,-0.5) {};
\path (input2) edge [->] node [above] {Network B} (input2-|engine.west);
% Output
\node (output) [point] at (-6,3) {};
\node (outputup) [point] at (1,3) {};
\path (outputup) edge [->,dashed]
node [above] {Management}
node [below] {Output}
(output);
\path (outputup) edge [->,dashed] (engine);
為了實現它,我創建了一個代表要創建的線的節點,然後創建了另一個代表圓和線之間的第一個交點的節點,最後我將線與最後一個節點連結起來。為此,您還需要使用交集庫,由 : 載入\usetikzlibrary{intersections}
。
結果 :
我希望它能有所幫助。