0

For the following, I need to:

1- scale the components size, wires lengths, connection nodes according to the drawing scale set by the font size

2- make both the components and the wires have the same thickness that is dependent on the global relative unit length for every scale since the wires seem thinner

3- scale the flow arrow length so that it always (regardless of the drawing scale) covers the distance between the end of the resistor and the start of the inductor.

4- know if the connection nodes between the wires and resistor/inductor can be loosened or smoothed instead of this sharp connection.

enter image description here

\documentclass{article}
\usepackage[
american, 
siunitx , 
RPvoltages, 
]{circuitikz}
\begin{document}
    \tiny
    \begin{circuitikz}[x=3em, y=3em]
        \draw (0,2) to[R=$R_a$, o-] ++(2,0)
        to[short,f=$i_a$] ++(0.1,0) 
        to[L, cute inductor, l=$L_a$]  ++(2,0);
    \end{circuitikz}

    \normalsize
    \begin{circuitikz}[x=3em, y=3em]
        \draw (0,2) to[R=$R_a$, o-] ++(2,0)
        to[short,f=$i_a$] ++(0.1,0) 
        to[L, cute inductor, l=$L_a$]  ++(2,0);
    \end{circuitikz}

    \Large
    \begin{circuitikz}[x=3em, y=3em]
        \draw (0,2) to[R=$R_a$, o-] ++(2,0)
        to[short,f=$i_a$] ++(0.1,0) 
        to[L, cute inductor, l=$L_a$]  ++(2,0);
    \end{circuitikz}
\end{document}
5
  • 1
    The best way to scale "everything" (after getting the values as suggested by @john-kormylo in their answer) is using transform canvas (which has a problem with reference point, though) or, better, scalebox, see tex.stackexchange.com/questions/544495/…
    – Rmano
    Dec 25, 2020 at 12:20
  • Anyways, scaling linewidths down is really dangerous --- if you go subpixel, you are in the hand of the various antialiasing algorithm and everything can happen...
    – Rmano
    Dec 25, 2020 at 12:21
  • @Rmano What about the flow arrow length? How can I manually add to its length?
    – Diaa
    Dec 25, 2020 at 17:46
  • @Rmano For example, I need to scale its length by 1.2 and its head size by 0.8.
    – Diaa
    Dec 25, 2020 at 17:49
  • The flow arrow is not a TikZ arrow, it is a shape, so you can't scale its parts differently. You can use the "advanced flows" to build your own arrow, see the manual, section 4.8, around pag 158, and tex.stackexchange.com/a/549354/38080 See also tex.stackexchange.com/questions/574576/… for an example application
    – Rmano
    Dec 25, 2020 at 18:39

1 Answer 1

4

The first step is to determine the relative size of the fonts.

\documentclass{article}
\usepackage{pgfmath}

\newcommand{\scale}{}% reserve global name
\newcommand{\setscale}[1]{\sbox0{#1\strut}%
  \pgfmathdivide{\ht0}{\ht\strutbox}%
  \let\scale=\pgfmathresult}
  
\begin{document}
\setscale{\tiny}tiny \scale

\setscale{\scriptsize}scriptsize \scale

\setscale{\footnotesize}footnotesize \scale

\setscale{\small}small \scale

\setscale{\normalsize}normalsize \scale

\setscale{\large}large \scale

\setscale{\Large}Large \scale

\setscale{\huge}huge \scale

\end{document}

demo1


Then you need to apply it to several scale factors in circutikz.

\documentclass{article}
\usepackage[
american, 
siunitx , 
RPvoltages, 
]{circuitikz}

\newcommand{\tinyscale}{0.5}
\newcommand{\Largescale}{1.5}

\begin{document}
    \tiny
    \ctikzset{bipoles/thickness=\tinyscale}
    \begin{circuitikz}[scale=\tinyscale, transform shape, use fpu reciprocal, line width={\tinyscale*0.5pt}]
        \draw (0,2) to[R=$R_a$, o-] ++(2,0)
        to[short,f=$i_a$] ++(0.1,0) 
        to[L, cute inductor, l=$L_a$]  ++(2,0);
    \end{circuitikz}

    \normalsize
    \ctikzset{bipoles/thickness=1}
    \begin{circuitikz}
        \draw (0,2) to[R=$R_a$, o-] ++(2,0)
        to[short,f=$i_a$] ++(0.1,0) 
        to[L, cute inductor, l=$L_a$]  ++(2,0);
    \end{circuitikz}

    \Large
    \ctikzset{bipoles/thickness=\Largescale}
    \begin{circuitikz}[scale=\Largescale, transform shape, use fpu reciprocal, line width={\Largescale*0.5pt}]
        \draw (0,2) to[R=$R_a$, o-] ++(2,0)
        to[short,f=$i_a$] ++(0.1,0) 
        to[L, cute inductor, l=$L_a$]  ++(2,0);
    \end{circuitikz}
\end{document}

demo2

8
  • Thanks for your answer. However, I would like to have some automation without the need to have the skill of guessing the right numbers of thickness, line width and scale.
    – Diaa
    Dec 24, 2020 at 18:51
  • I revised the solution. Dec 24, 2020 at 21:09
  • Is it possible to replace 0.5pt of the line width` with the saved value so that it goes in sync when using the options of thick, very thick, etc.?
    – Diaa
    Dec 24, 2020 at 21:39
  • 1
    If that were the case, no one would be able to change just the font size and nothing else. You might be able to put everything into one macro using \ctikzset for the options. You might be able to do something with \pgflinewidth (length). Dec 25, 2020 at 2:06
  • 1
    See tex.stackexchange.com/questions/395372/… to see what is involved. Worse, circuitikz keeps changing how things are done, and fixes like this only work for awhile. Dec 26, 2020 at 3:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .