Is there some simple way to avoid shorting the pins of a FET?
\documentclass{standalone}
\usepackage{tikz}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz}
\draw (0,0)
to[I,I=$I_s$] (0,2) % The current source
to[short] (2,2);
\draw (2,0)
to node[nigfete]{FET} (2,2) % The FET transistor
to[short] (2,0) to[short] (0,0);
\draw (2,2)
to[short] (4,2)
to[R=$R$] (4,0)
to[short] (2,0);
\draw (4,2);
\draw node[rground]{};
\end{circuitikz}
\end{document}
I am not sure to understand what you want to achieve, but
use short only if you need to add poles or labels, otherwise -- is easier to type;
use the anchors of the components.
tikz is automatically loaded by circuitikz, and that one has a mandatory argument (the voltage direction standard, look at the manual and at the wanings! ;-).
So a first change could be this:
\documentclass[border=4pt] {standalone}
\usepackage[RPvoltages]{circuitikz}
\begin{document}
\begin{circuitikz}
\draw (0,0) node[rground]{}
to[I,I=$I_s$] (0,2) -- (2,2)
node[nigfete, anchor=D](F){FET} % The FET transistor
(F.S) to[short, -*] (2,0) -- (0,0);
\draw (2,2) -- (4,2)
to[R=$R$] (4,0) -- (2,0);
\draw node[rground]{};
\end{circuitikz}
\end{document}
which leads to:
then, in my opinion, it would be better to use relative positioning to make the circuit relocatable.
If you need/want the FET centered in the branch it could be better to start with it or use the calc TikZ library (already loaded by circuitikz). In the following circuit all the movement are relative, so you can move it by just changing the first (0,0):
\documentclass[border=4pt] {standalone}
\usepackage[RPvoltages]{circuitikz}
\begin{document}
\begin{circuitikz}
\draw (0,0) node[rground](GND){} to[I,I=$I_s$] ++(0,2)
-- ++(2,0) coordinate(top)
-- ++(2,0) to[R=$R$] ++(0,-2)
-- (GND-|top) coordinate(bottom)
-- (GND)
($(top)!0.5!(bottom)$) node[nigfete](F){FET}
(F.D) -- (top) (F.S) -- (bottom);
\end{circuitikz}
\end{document}
Related
I want to draw this image in a latex file using tikz and pgfplots. I have no idea I to do it. i just need the exact image shown in the image file in latex code
The code below produces this:
the output figure
\documentclass[dvipdfmx]{article}
\usepackage{tikz,bm}\usetikzlibrary{arrows.meta, angles, quotes}
\begin{document}
\begin{tikzpicture}[>=stealth, x=6mm, y=6mm, thick]
\draw (-5.5,0) -- (5.5,0) node[right] {$\boldsymbol{x}$};
\draw (0,-5.5) -- (0,5.5) node[above] {$\boldsymbol{y}$};
\draw (5,0.1) -- (5,-0.1) node[below] {$\boldsymbol{5}$};
\draw (0.1,5) -- (-0.1,5) node[left] {$\boldsymbol{5}$};
\draw (-5,0.1) -- (-5,-0.1) node[below] {$\boldsymbol{5}$};
\draw (0.1,-5) -- (-0.1,-5) node[left] {$\boldsymbol{5}$};
\draw[-{Stealth[length=3mm]}] (0,0) -- (4,-3);
\node[below] at (2,-1.5) {$\mathbf{A}$};
\draw[dotted] (4,0) -- (4,-3);
\draw[dotted] (0,-3) -- (4,-3);
\node[right] at (4,-2) {$\boldsymbol{-3}$};
\node[below] at (2,-3) {$\boldsymbol{4}$};
\coordinate (a) at (0,0); \coordinate (b) at (1,0); \coordinate (c) at (2,-1.5);
\draw pic[draw, angle radius=0.8cm, "$\boldsymbol{\alpha}$" shift={(0.2,-0.1)}] {angle=c--a--b};
\end{tikzpicture}
\end{document}
I want the line on the left to end right at the y-coordinate of the SPDT input so I can connect them seamlessly with a straight line. As you can see, the line on the left ends a bit lower than the SPDT input which causes the connecting line to be tilted
Is there a way to automatically adjust the length? I'd rather avoid inching towards an acceptable result by adjusting the length over and over again manually.
Here is the code
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{circuitikz}
\begin{document}
\begin{figure}
\begin{circuitikz}
\node [spdt, rotate=90] (S) {};
\draw
(S.in) to [C] ++(0,-2)
to ++(-2,0)
to [V] ++(0,3)
to(S.out 1);
\end{circuitikz}
\end{figure}
\end{document}
Instead of adjusting the length on the left, I would just make sure that it is above the switch and then use -| to connect it with first an horizontal segment and then a vertical segment:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{circuitikz}
\begin{document}
\begin{figure}
\begin{circuitikz}
\node [spdt, rotate=90] (S) {};
\draw
(S.in) to [C] ++(0,-2)
to ++(-2,0)
to [V] ++(0,3.5)
-| (S.out 1)
;
\end{circuitikz}
\end{figure}
\end{document}
Here is the diagram I am trying to make using tikz. Blocks A, B and C are inside a block (here, block with red background) and blocks E and F are inside another block. The two huge blocks (with red background) have labels on top (LabA and LabB). Moreover, I would like block E to be right and in the middle of the blocks A and B. And arrows going to block E should have some bending angle; so, not like in the one I have tried.
Here is my code.
\documentclass[varwidth,border=7]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,fit,calc}
\tikzstyle{block} = [draw=black, thick, text width=2cm, minimum height=1cm, align=center]
\tikzstyle{arrow} = [thick,->,>=stealth]
\begin{document}
\begin{tikzpicture}
\node[block] (a) {a};
\node[block, below=of a, yshift=0.7cm] (b) {b};
\node[block, below=of b, yshift=0.7cm] (c) {c};
\node[block, right=of c, xshift=0.7cm] (d) {d};
\node[block, right=of a, xshift=0.7cm, yshift=-0.4cm] (e) {e};
\draw [arrow] (a) -- (e);
\draw [arrow] (b) -- (e);
\draw [arrow] (c) -- (d);
\end{tikzpicture}
\end{document}
How could I add a rectangle over some nodes and write a label on top of it.
How to have the arrows here with a certain angle of inclination (not straight), and also to have the E block in the middle and in right of the A and B blocks. I though I could get the arrows with \draw [arrow] (a) -|- (e);, but it does not work.
Thank you in advance
I gave it a try in the hope of getting the requirements right:
\documentclass[varwidth,border=7]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,fit,calc}
\tikzstyle{block} = [draw=none, thick, text width=.4cm, minimum height=.5cm, align=center, fill=blue!50]
\tikzstyle{arrow} = [thick,->,>=stealth]
\begin{document}
\begin{tikzpicture}
\Large
%red rectangles
\node (r1) [draw=none, fill=red, minimum width=1.2cm,minimum height=3.5cm]{};
\node (r2) [right=2cm of r1.center, anchor=center, draw=none, fill=red, minimum width=1.2cm,minimum height=3.5cm]{};
\node (r1Label)[above=0cm of r1] {\textbf{LabA}};
\node (r2Label)[above=0cm of r2]{\textbf{LabB}};
%nodes
\node[block, below=3mm of r1.north, anchor=north] (a) {\color{white}A};
\node[block, below=4mm of a] (b) {\color{white}B};
\node[block, below=4mm of b] (c) {\color{white}C};
\node[block, right=2cm of c.center, anchor=center] (d) {\color{white}D};
\node at ($(a.south)+(2,-.2)$) [block] (e) {\color{white}E};
%arrows
\draw [arrow, rounded corners=2] (a) -- ($(a)+(1,0)$) |- ($(e.west)+(0,.1)$);
\draw [arrow, rounded corners=2] (b) -- ($(b)+(1,0)$) |- ($(e.west)+(0,-.1)$);
\draw [arrow] (c) -- (d);
\end{tikzpicture}
\end{document}
With this result:
Some explanations:
You can just draw rectangles in the back by defining them before the other nodes. There are more sophisticated ways using layers, but I think in this example it suffices.
I mostly used absolute distances like in the given example code. You may have to adjust... However, using these you can easily find out the middle between A and B (distance 4mm) to find the y-Position of E (a.south+ 2mm). Using ($(node1)+(node2)$) you can calculate node positions.
The -|- option you mentioned works in two steps. First draw -- to some anchor point (otherwise this is ambiguous), then |- to the target node.
The rounded corners option for draw takes the rounding radius as a parameter.
I'm trying to do a diagram with arrows. I have been able to produce the diagram but with no arrows using this code:
\begin{tikzpicture}
\node (a) at (0,0) {$a$};
\node (z1) at (3,2) {$z_1$};
\node (z2) at (3,0) {$z_2$};
\node (z3) at (3,-2) {$z_3$};
\draw (a) -- (z1);
\draw (a) -- (z2);
\draw (a) -- (z3);
\end{tikzpicture}
But I need the segments to be arrows and add tags to the segments but when I try this code:
\begin{tikzpicture}
\node (a) at (0,0) {$a$};
\node (z1) at (3,2) {$z_1$};
\node (z2) at (3,0) {$z_2$};
\node (z3) at (3,-2) {$z_3$};
\draw [->] (a) -- (z1) {$1/2$};
\draw [->] (a) -- (z2) {$1/4$};
\draw [->] (a) -- (z3) {$1/4$};
\end{tikzpicture}
I get an error in the first \draw line that says:
Argument of \language?#active#arg> has an extra }.
Runaway argument?
Missing \endcsname inserted.
And then in the \end{tikzpicture} line I get:
Extra }, or forgotten \endgroup.
Missing } inserted.
The complete code I'm using is this:
\documentclass[spanish]{article}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr} % Required for custom headers
\usepackage{lastpage} % Required to determine the last page for the footer
\usepackage{extramarks} % Required for headers and footers
\usepackage[usenames,dvipsnames]{color} % Required for custom colors
\usepackage{graphicx} % Required to insert images
\usepackage{listings} % Required for insertion of code
\usepackage{courier} % Required for the courier font
\usepackage{lipsum} % Used for inserting dummy 'Lorem ipsum' text into the template
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{natbib}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node (a) at (0,0) {$a$};
\node (z1) at (3,2) {$z_1$};
\node (z2) at (3,0) {$z_2$};
\node (z3) at (3,-2) {$z_3$};
\draw [->] (a) -- (z1) node[midway,above] {$1/2$};
\draw [->] (a) -- (z2) node[midway,above] {$1/4$};
\draw [->] (a) -- (z3) node[midway,above] {$1/4$};
\end{tikzpicture}
\end{document}
There are a couple of problems:
the \draw command does not take a label like the \node command. If you want to add text to the arrow there are several possibilities, for example \draw [->] (a) -- (z1) node[midway,above] {$1/2$};
then you are also loading the spanish babel package. This introduces a couple of shorthands to write spanish characters which interfere with tikz. Either switch these shorthands off or load the tikz babel library
please don't load packages more than once
have a look at the nicefrac package to get nicer fractions
\documentclass[spanish]{article}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
%\usepackage[utf8]{inputenc}
\usepackage{fancyhdr} % Required for custom headers
\usepackage{lastpage} % Required to determine the last page for the footer
\usepackage{extramarks} % Required for headers and footers
\usepackage[usenames,dvipsnames]{color} % Required for custom colors
\usepackage{graphicx} % Required to insert images
\usepackage{listings} % Required for insertion of code
\usepackage{courier} % Required for the courier font
\usepackage{lipsum} % Used for inserting dummy 'Lorem ipsum' text into the template
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{natbib}
%\usepackage{graphicx}
%\usepackage{amsmath}
%\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{babel}
\begin{document}
\begin{tikzpicture}
\node (a) at (0,0) {$a$};
\node (z1) at (3,2) {$z_1$};
\node (z2) at (3,0) {$z_2$};
\node (z3) at (3,-2) {$z_3$};
\draw [->] (a) -- (z1) node[midway,above] {$1/2$};
\draw [->] (a) -- (z2) node[midway,above] {$1/4$};
\draw [->] (a) -- (z3) node[midway,above] {$1/4$};
\end{tikzpicture}
\end{document}
Try edge command between the nodes
\begin{tikzpicture}
\node (a) at (0,0) {$a$};
\node (z1) at (3,2) {$z_1$};
\node (z2) at (3,0) {$z_2$};
\node (z3) at (3,-2) {$z_3$};
\draw [->] (a) edge (z1) (a) edge (z2) (a) edge (z3);
\end{tikzpicture}
Is there a simple way to increase the size of an arrow tip using something like:
\tikzset{myptr/.style=->, ????}
without designing a new arrow style from scratch?
One solution, very quick, to just scale the arrow head is number %2 in the following:
\documentclass[multi=false,tikz,border=2mm]{standalone}
\usetikzlibrary{arrows,decorations.markings}
\begin{document}
\begin{tikzpicture}
%1
\draw [->,>=stealth] (0,.5) -- (2,.5);
%2
\draw [decoration={markings,mark=at position 1 with
{\arrow[scale=3,>=stealth]{>}}},postaction={decorate}] (0,0) -- (2,0);
\end{tikzpicture}
\end{document}
This produces:
(sorry for excessive zoom).
Much more in the answers to this question and in this answer, that I used as a source.
Addendum
\tikzset approach. This code:
\documentclass[multi=false,tikz,border=2mm]{standalone}
\usetikzlibrary{arrows,decorations.markings}
\begin{document}
\begin{tikzpicture}
\tikzset{myptr/.style={decoration={markings,mark=at position 1 with %
{\arrow[scale=3,>=stealth]{>}}},postaction={decorate}}}
%1
\draw [->,>=stealth] (0,.5) -- (2,.5);
%2
\draw [myptr] (0,0) -- (2,0);
\end{tikzpicture}
\end{document}
produces the same output as the above one (source: PGF Manual, section 2.8).
Obviously you can use -Latex instead of stealth.
There is a new solution, see https://latexdraw.com/exploring-tikz-arrows/#t-1610685307397. It allows changing both the length and width of arrows:
\documentclass[border=1mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,arrows}
\begin{document}
\begin{tikzpicture}
\draw [-{Stealth[length=3mm, width=2mm]}] (0,0.5) -- (1,0.5);
\draw [-stealth] (0,0) -- (1,0);
\end{tikzpicture}
\end{document}