Smooth connection of resistor to surrounding lines with circuitikz

665 Views Asked by At

I am using circuitikz to draw a small circuit as shown here, but the resistor R1 is not smoothly connected to the surounding lines.

enter image description here

The code used to generate this plot is

\documentclass[border=1mm]{standalone}

\usepackage{amsmath, amssymb, mathtools}
\usepackage{siunitx}

\usepackage[]{circuitikz}
\usetikzlibrary{positioning, calc}
\newcommand\myVoltageBuffer[2]{%
    %1: ID amplifier, %2 start coordinate
    \draw #2 coordinate(opamp#1-in)
        to[short]
            ++(1,0) node[op amp, noinv input up, anchor=+](opamp#1){$A_#1$}
            (opamp#1.-) -- ++(0,-1) coordinate(opamp#1-feedback)
            (opamp#1-feedback) -| (opamp#1.out)
        to [short, *-]
            ++(1,0) coordinate(opamp#1-out);
}

\newcommand\myDRL[6]{%
    %1: ID amplifier, %2 start coordinate, %3 R gain %4 R series, %5 C series, %6 R parallel
    \draw #2 coordinate(opamp#1-in)
        to[R=#3] ++(1,0)
        to [short]
            ++(1, 0) node[op amp, anchor=+](opamp#1){$A_#1$}

        (opamp#1.-) -- ++(0, 1) coordinate(opamp#1-feedback)
        to [short, -*] ++(0, 0)
        to [R=#4] ++(1.5, 0)
        to [C=#5] ++(1.5, 0)
        to [short, -*] ++(0, 0) coordinate(opamp#1-feedback-C-point)

        (opamp#1-feedback) -- ++(0, 1.5)
        to [R=#6] ++(3, 0) -| (opamp#1-feedback-C-point)
        to [short, -*] ++(0, -1.5) coordinate(opamp#1-last-bullet)

        (opamp#1.out) -- (opamp#1-last-bullet) -- ++(1, 0) coordinate(opamp#1-out);
}
\begin{document}
\begin{circuitikz}[american, transform shape, use fpu reciprocal,]
    \myVoltageBuffer{1}{ (0, 0) }{}{}
    \node [ocirc] at (opamp1-in) {};

    \myDRL{2}{ (opamp1-out) }{ $R_1$ }{ $R_s$ }{ $C_s$ }{ $R_{\parallel}$ }
    \node [ocirc] at (opamp2-out) {};
\end{circuitikz}
\end{document}
1

There are 1 best solutions below

0
On

You can tweak the coordinates of your DRL a bit to make the gap for the resistor big enough (e.g. at least one bipoles/length, which is 1.4 cm by default):

\documentclass[border=1mm]{standalone}

\usepackage{amsmath, amssymb, mathtools}
\usepackage{siunitx}

\usepackage[]{circuitikz}
\usetikzlibrary{positioning, calc}
\newcommand\myVoltageBuffer[2]{%
    %1: ID amplifier, %2 start coordinate
    \draw #2 coordinate(opamp#1-in)
        to[short]
            ++(1,0) node[op amp, noinv input up, anchor=+](opamp#1){$A_#1$}
            (opamp#1.-) -- ++(0,-1) coordinate(opamp#1-feedback)
            (opamp#1-feedback) -| (opamp#1.out)
        to [short, *-]
            ++(1,0) coordinate(opamp#1-out);
}

\newcommand\myDRL[6]{%
    %1: ID amplifier, %2 start coordinate, %3 R gain %4 R series, %5 C series, %6 R parallel
    \draw #2 coordinate(opamp#1-in)
        to[R=#3] ++(1.4,0)
        to [short]
            ++(1, 0) node[op amp, anchor=+](opamp#1){$A_#1$}

        (opamp#1.-) -- ++(0, 1) coordinate(opamp#1-feedback)
        to [short, -*] ++(0, 0)
        to [R=#4] ++(1.5, 0)
        to [C=#5] ++(1.5, 0)
        to [short, -*] ++(0, 0) coordinate(opamp#1-feedback-C-point)

        (opamp#1-feedback) -- ++(0, 1.5)
        to [R=#6] ++(3, 0) -| (opamp#1-feedback-C-point)
        to [short, -*] ++(0, -1.5) coordinate(opamp#1-last-bullet)

        (opamp#1.out) -- (opamp#1-last-bullet) -- ++(1, 0) coordinate(opamp#1-out);
}
\begin{document}
\begin{circuitikz}[american, transform shape, use fpu reciprocal,inner sep=0pt,outer sep=0pt]
    \myVoltageBuffer{1}{ (0, 0) }{}{}
    \node [ocirc] at (opamp1-in) {};

    \myDRL{2}{ (opamp1-out) }{ $R_1$ }{ $R_s$ }{ $C_s$ }{ $R_{\parallel}$ }
    \node [ocirc] at (opamp2-out) {};
\end{circuitikz}
\end{document}

enter image description here

Alternatively, you could use \ctikzset{resistors/scale=0.7} to make the resistors smaller so it will still fit in the tiny gap you give it.