下载 PDF 文件时未打印出电路线

下载 PDF 文件时未打印出电路线

基本上,我有这样的代码:

\begin{figure}
    \begin{circuitikz} [american voltages, american currents]
        \draw 
            (0,0) to (0, 0)
            to [ V = $V_g$, invert] (0, 2);
        \draw
            to (0, 2)
            to [ R, l_ = $R_1$ ] (2, 2);
        \path
            to (2, 2)
            to (0, 2);    
        \draw[dashed]
            to (0, 2)
            to (0, 4);
        \draw
            (0, 4)
            to [ voltmeter ] (2, 4);
        \draw[dashed]
            to (2, 4)
            to (2, 2);
        \path
            (2, 4);
        \draw
            (2, 4)
            to [ voltmeter ] (4, 4);
        \draw[dashed]
            to (4, 4)
            to (4, 2);
        \draw
            (4, 4)
            to [ voltmeter ] (6, 4);
        \draw[dashed]
            to (6, 4)
            to (6, 2);
        \path
            to (0, 4);
        \draw[dashed]
            to (0, 4)
            to (0, 6);
        \draw
            to (0, 6)
            to [ voltmeter ] (6, 6);
        \draw[dashed]
            to (6, 6)
            to (6, 4);
        \draw
            to (2, 2)
            to [ R, l_ = $R_2$ ] (4, 2)
            to [ R, l_ = $R_3$ ] (6, 2)
            to (6, 0);
        \path
            to (0, 0);
        \draw
            to (0, 0)
            to [ ammeter ] (6, 0);
        \end{circuitikz}
\end{figure}

哪个应该像这样打印出来(在 PDF 查看器上执行)。 编辑器内部看到的预览。

但相反,它在 PDF 文件上打印出来是这样的:

PDF 文件中的实际打印输出。

为什么会发生这种情况?我该如何解决?

答案1

让我们尝试简化这个问题。如果我编译这个小部分(我添加了红点以便引用(0,0)):

\documentclass[border=10pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz} [american voltages, american currents]
        \draw
        (0,0) to (0,0) node[circ,red]{}
            to [ V = $V_g$, invert] (0, 2);
        \draw
            to (0, 2)
            to [ R, l_ = $R_1$ ] (2, 2);
\end{circuitikz}
\end{document}

您有以下内容:

在此处输入图片描述

看到差距了吗?这是因为你的第二笔画使用\draw to (0,2)to 需求明确起始坐标。第一个(0,0) to (0,0)也没有做任何事情...

如果你将代码更改为

\documentclass[border=10pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz} [american voltages, american currents]
    \draw
    (0,0) node[circ,red]{}
    to [ V = $V_g$, invert] (0, 2);
    \draw
    (0, 2)
    to [ R, l_ = $R_1$ ] (2, 2);
\end{circuitikz}
\end{document}

你有正确的答案:

在此处输入图片描述

换句话说,当前点不会从一次绘制“提醒”到另一次绘制。顺便说一句,代码更容易编写(我删除了红点),如下所示:

\documentclass[border=10pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz} [american voltages, american currents]
    \draw
    (0,0)
    to [ V = $V_g$, invert] (0, 2)
    to [ R, l_ = $R_1$ ] (2, 2);
\end{circuitikz}
\end{document}

此外,这些\path元素在这里基本上没有任何作用。

奇怪的是,你对这些线条进行了预览...我在预览和打印时都出现了一致的白色间隙。

您的绘图的可能代码(但您应该尝试减少不同路径的数量)可能是:

\documentclass[border=10pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz} [american voltages, american currents]
    \draw (0,0)
    to [ V = $V_g$, invert] (0, 2)
    to [ R, l_ = $R_1$ ] (2, 2);
    \draw[dashed] (0, 2) -- (0, 4);
    \draw (0, 4) to [ voltmeter ] (2, 4);
    \draw[dashed] (2, 4) -- (2, 2);
    \draw (2, 4) to [ voltmeter ] (4, 4);
    \draw[dashed] (4, 4) to (4, 2);
    \draw (4, 4) to [ voltmeter ] (6, 4);
    \draw[dashed] (6, 4) -- (6, 2);
    \draw[dashed] (0, 4) -- (0, 6);
    \draw (0, 6) to [ voltmeter ] (6, 6);
    \draw[dashed] (6, 6) to (6, 4);
    \draw (2, 2) to [ R, l_ = $R_2$ ] (4, 2)
        to [ R, l_ = $R_3$ ] (6, 2)-- (6, 0);
    \draw (0, 0) to [ ammeter ] (6, 0);
\end{circuitikz}
\end{document}

在此处输入图片描述

答案2

还有一个版本说明如何在一个循环中正确绘制你的方案并单独添加虚线:

\documentclass[margin=3mm]{standalone}
\usepackage{circuitikz}

\begin{document}
    \begin{circuitikz}[american voltages, american currents]
\draw   (0,0)   to [V = $Vg$, invert]  (0,2)
                to [R = $R_1$ ] (2,2)
                to [R = $R_2$ ] (4,2)
                to [R = $R_3$ ] (6,2)
                to [short]      (6,0)
                to [ammeter, invert, mirror]    (0,0)
        (0,4)   to [voltmeter]  (2,4)
                to [voltmeter]  (4,4)
                to [voltmeter]  (6,4)
        (0,6)   to [voltmeter]  (6,6);
\draw[dash pattern=on 2mm off 1mm]
        (0,2) -- (0,6)
        (2,2) -- (2,4)
        (4,2) -- (4,4)
        (6,2) -- (6,6);
    \end{circuitikz}
\end{document}

在此处输入图片描述

相关内容