CircuiTikZ 在 png 影像上

CircuiTikZ 在 png 影像上

我想在 .png 圖像上繪製簡單的 CircuiTikZ 符號。這就是我要的:

通緝

這是我目前得到的:

結果

這是我的程式碼:

\begin{figure} [!ht]
\begin{tikzpicture}[x=1cm,y=1cm]
\node at (0,0) {\includegraphics[trim={40cm 55cm 40cm 55cm},clip,height=10cm]{images/MecanismoEscala_primer_ensayo_Variables.png}};
\node at (-3.7634,-1.5117){
\begin{circuitikz}
\draw
 (0,0) --++ (-1.0778,0)
        to [open,v=$v$,o-o] ++(0,0.7012)
        to[short,i=$i_{a}$] ++(1.0663,0);
\end{circuitikz}
};
\end{tikzpicture}
\end{figure}\FloatBarrier

我還想$v$在終端機旁邊寫上 +- 符號(這兩個符號彼此分開一點,不像我得到的結果)。

答案1

首先。絕不巢 tikz 圖片!並發布基本圖片,在本例中我設法使用 GIMP 製作並保存為uffa.png.

在此輸入影像描述

我的方法是:

  1. 將圖像作為節點載入到 的開頭tikzpicture,以便您可以在其上寫入。
  2. 設定某種網格以方便參考。
  3. 畫出你想要的任何東西,微調座標。
  4. 移除網格。

讓我們看看:步驟 1 和 2 是這樣的:

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0) {%
        \includegraphics[width=10cm]{uffa.png}};
        \draw[red,thin] (0,0) grid[step=1] (10,5);
\end{tikzpicture}
\end{document}

有網格的圖片

你有0,0左下角的點,每個網格步長是 1 公分。現在,背景不是白色的(我希望你不要列印它,否則,改變它),所以我選擇了顏色,結果是非常深的藍灰色,RGB為33,40,48(任何顏色選擇器都會做)。

現在我繪製電路,將藍灰色設定為開路極點的填充。

\documentclass[tikz]{standalone}
\usepackage[RPvoltages, american]{circuitikz}
\begin{document}
\begin{tikzpicture}[color=white]% write in white
    \node[anchor=south west,inner sep=0] (image) at (0,0) {%
        \includegraphics[width=10cm]{uffa.png}};
        \draw[red,thin] (0,0) grid[step=1] (10,5);
        \definecolor{mybg}{RGB}{33,40,48}% with a color picker
        \ctikzset{open poles fill=mybg}% tell circuitikz what is background for you
        \draw (4,4) coordinate(a) to[short, i=$i_a$, o-]  ++(1.8,0);
        \draw (a) ++(0,-1) to[short, o-] ++(1.7,0);
        \draw (a) ++(-0.3,0) to[open, v=$v$] ++(0,-1);
\end{tikzpicture}
\end{document}

帶閘極和電路

我嘗試盡可能使用相對座標和命名座標,以最大程度地減少需要調整以獲得結果的數字數量。然後,刪除網格,您將獲得:

最終輸出

相關內容