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}

Diaa
  • 9,599
  • 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 https://tex.stackexchange.com/questions/544495/problem-with-scaling-entire-tikzpicture-with-transform-canvas – Rmano Dec 25 '20 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 '20 at 12:21
  • @Rmano What about the flow arrow length? How can I manually add to its length? – Diaa Dec 25 '20 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 '20 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 https://tex.stackexchange.com/a/549354/38080 See also https://tex.stackexchange.com/questions/574576/circuitikz-straight-voltage-arrows-with-fixed-length for an example application – Rmano Dec 25 '20 at 18:39

1 Answers1

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

John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • 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 '20 at 18:51
  • I revised the solution. – John Kormylo Dec 24 '20 at 21:09
  • Is it possible to replace 0.5pt of the linewidthwith the saved value so that it goes in sync when using the options ofthick,very thick`, etc.? – Diaa Dec 24 '20 at 21:39
  • Also, is it possible to get everything done by only writing the font size command (e.g. \tiny) without the need for the extra steps of \ctikzset{bipoles/thickness=\tinyscale} and line width={\tinyscale*0.5pt}? I mean that everything should be automated once I type the font size command. – Diaa Dec 24 '20 at 23:48
  • 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). – John Kormylo Dec 25 '20 at 02:06
  • @JohnKormylo (nice answer, +1) bipoles/thickness is the thickness relative to the linewidth, so you just have to put it to 1 for every example (check it!). – Rmano Dec 25 '20 at 12:10
  • Is it possible to edit the length of the flow current arrow? For example, I need to scale its length by 1.2 and its head size by 0.8. – Diaa Dec 25 '20 at 17:48
  • 1
    See https://tex.stackexchange.com/questions/395372/circuitikz-change-current-arrow-color-and-label-color-at-once/396801?r=SearchResults&s=2|42.9985#396801 to see what is involved. Worse, circuitikz keeps changing how things are done, and fixes like this only work for awhile. – John Kormylo Dec 26 '20 at 03:40