2

Consider the following MWE

\documentclass[border=0pt]{standalone}
\usepackage{tikz}
\usepackage{circuitikz}
\begin{document}

\begin{circuitikz} \draw (0,0) node[twoportshape, t=$\frac{T_s , (z+1)}{2 , (z-1)}$] (int1) {}; \end{circuitikz} \end{document}

enter image description here

How can I adjust the length of the twoportshape such that the text fits in it without changing its height?

This seems like a very basic thing, but I was unable to find a solution in the documentation.

The documentation suggests using

\ctikzset{bipoles/length=1.4cm}

But this does increase both, the length and the height of the blocks. Also, it is applied globally to all blocks and not just a single one.

Thank you for your help.

Rmano
  • 40,848
  • 3
  • 64
  • 125
snuff
  • 79
  • 1
    One should note that a major difference between circuitikz and tikz circuits is that tikz enlarges all of its nodes to fit the contents. Circuitikz does not. – John Kormylo Feb 10 '21 at 15:49

2 Answers2

2

Why you not draw your box as ordinary tikz box?

\documentclass[border=0pt]{standalone}
\usepackage{tikz}
\usepackage{circuitikz}
\begin{document}

\begin{circuitikz} \draw (0,0) node[draw, thick, minimum size=9mm] (int1) {$\frac{T_s(z+1)}{2(z-1)}$}; \end{circuitikz} \end{document}

enter image description here

Zarko
  • 296,517
1

Basically the idea between the twoports is to have a nice group of blocks all the same size --- in case you want just to draw blocks around generic text or formulas, the answer given by Zarko is the correct one --- pure TikZ suffices and it's more flexible.

Anyway, if your bigger block is the odd one, you can change its width with the undocumented key bipoles/twoport/width (default 0.7, relative to the base length). Notice that if you use the node form you need to add the circuitikz part in front.

\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usepackage{circuitikz}
\begin{document}

\begin{circuitikz} \draw (0,0) node[twoportshape, t=$\frac{T_s , (z+1)}{2 , (z-1)}$, circuitikz/bipoles/twoport/width=1.0] (int1) {}; \end{circuitikz} \end{document}

enter image description here

When used (more naturally) as a path element, you have for example:

\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usepackage{circuitikz}
\begin{document}

\begin{circuitikz} \draw (0,0) to[twoport, t=$\frac{T_s , (z+1)}{2 , (z-1)}$, bipoles/twoport/width=1.0, >] ++(3,0) to[amp, box, , >, -o] ++(2,0) ; \end{circuitikz} \end{document}

enter image description here

Rmano
  • 40,848
  • 3
  • 64
  • 125