I am trying to draw the number line but the more I add variables the more the numbers FADE AWAY and some are even DISAPPEARING COMPLETELY. Below is the code I have used, and the results are as shown in the image below. Anyone who can see the problem in this code?Thanks.
\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}[thick,time/.style={minimum height=5mm,minimum width=6mm,fill=#1,text=black}]
\def\0{0}
\def\1{1}
\def\2{2}
\def\3{3}
\def\4{4}
\def\5{5}
\def\6{6}
\def\7{7}
\def\8{8}
\def\9{9}
\def\n{10}
\draw[black,-latex] (0,0)--(11,0);
\draw[black] (0,.2)--(0,-.2)
(\0,.2) node[above=2mm,time=white]{$ 2X$}
(\0,-.2) node[below=2mm,time=white]{$0$}
(\1,.2) node[above=2mm,time=white] (x) {$ $}--
(\1,-.2) node[below=2mm,time=white]{$ 1$}
(\2,.2) node[above=2mm,time=white] (x) {$ $}--
(\2,-.2) node[below=2mm,time=white]{$2 $}
(\3,.2) node[above=2mm,time=white] (x) {$ $}--
(\3,-.2) node[below=2mm,time=white]{$ 3 $}
(\4,.2) node[above=2mm,time=white] (x) {$ $}--
(\4,-.2) node[below=2mm,time=white]{$4 $}
(\5,.2) node[above=2mm,time=white] (x) {$ $}--
(\5,-.2) node[below=2mm,time=white]{$5 $}
(\6,.2) node[above=2mm,time=white] (x) {$ $}--
(\6,-.2) node[below=2mm,time=white]{$6 $}
(\7,.2) node[above=2mm,time=white] (x) { $ $}--
(\7,-.2) node[below=2mm,time=white]{$7 $}
(\8,.2) node[above=2mm,time=white] (x) {$ $}--
(\8,-.2) node[below=2mm,time=white]{$8 $}
(\9,.2) node[above=2mm,time=white] (x) {$2X(1-\frac{0.12}{12})^{-4\times12}(1+\frac{0.10}{2})^{5\times2} $}--
(\9,-.2) node[below=2mm,time=white]{$9 $}
(\n,.2) node[above=2mm,time=white] (x) {$ $}--
(\n,-.2) node[below=2mm,time=white]{$10 $};
\draw[->] (0.2,0.7)--(3.98,0.7);
\draw[->] (4.1,0.7)--(6.5,0.7);
\end{tikzpicture}
\end{document}
Use foreach to save code:
\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}[thick,
time/.style={minimum height=5mm,minimum width=6mm,fill=#1,text=black},
%every node/.style={draw},
]
\draw[black,-latex] (0,0)--(11,0);
\def\dx{1}
\foreach \i in {0,...,10} {
\ifnum\i>0
\def\ann{$ $}
\else
\def\ann{$ 2X$}
\fi
\draw[] (\i*\dx,.2) -- (\i*\dx,-.2)
node[pos=0,above=2mm,time=white] (P\i) {\ann}
node[pos=1,below=2mm,time=white] (Q\i) {$\i$};
}
\node[time=white] at (P9) (x) {$2X(1-\frac{0.12}{12})^{-4\times12}(1+\frac{0.10}{2})^{5\times2} $};
\draw[-latex] (P0)--(P4.center);
\draw[-latex] ([xshift=1mm]P4.center)--(P6.east);
\end{tikzpicture}
\end{document}
Related
I'm trying to put together a presentation using latex beamer. I drew a triangle using the tikz package but I can't put the names on the angles. When executing the code, the following error appears: "Argument of \language#active#arg" has an extra }. \end{frame}"
The code is:
\documentclass[xcolor=dvipsnames,10pt,serif]{beamer} % serif, mathserif
\usepackage[english,brazil]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{ae}
\setbeamertemplate{caption}[numbered]
\setlength\abovecaptionskip{-3pt}
\setbeamertemplate{caption}[numbered]
\setbeamerfont{caption}{size=\scriptsize}
\usefonttheme[onlymath]{serif}
\usepackage{color}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amstext}
\usepackage{mathrsfs}
\usepackage{icomma}
\usepackage{bm}
\usepackage{steinmetz}
\usepackage{tikz}
\usepackage{adjustbox}
\usepackage{subfigure}
\usepackage{ragged2e}
\usepackage{tkz-euclide}
\usetikzlibrary{angles,quotes,babel}
\DeclareMathOperator{\sen}{sen}
\mode<presentation>
{
\usetheme{CambridgeUS}
}
\begin{document}
\begin{frame}{Frame Title}
\begin{figure}
\begin{tikzpicture}
\coordinate (C) at (-1.5,-1);
\coordinate (A) at (1.5,-1);
\coordinate (B) at (1.5,1);
\coordinate (D) at (1.5,-3);
\node [below] at (3,-1) {$\Re$};
\node [above] at (-1.5,2) {$\Im$};
%draw cartesian plane
\draw[stealth-stealth] (-1.5,-4) -- (-1.5,2) coordinate (y axis);
\draw[-stealth] (C) -- (3,-1) coordinate (x axis);
\draw[very thick,-{Stealth[length=3mm, width=1.5mm]}] (C) --
node[font=\Large,sloped,above] {$S_{abc}$} (B);
\draw[very thick,-{Stealth[length=3mm, width=1.5mm]}](A) --
node[font=\Large,pos=0.7,right] {$Q_{abc}$} (B);
\draw[very thick,-{Stealth[length=3mm, width=1.5mm]}](C) --
node[font=\Large,pos=0.8,above] {$P_{abc}$} (A);
\draw[very thick,-{Stealth[length=3mm, width=1.5mm]}](C) --
node[font=\Large,sloped,below] {$S_{abc}$} (D);
\draw[very thick,{Stealth[length=3mm, width=1.5mm]}-](D)--
node[font=\Large,pos=0.3,right] {$-Q_{abc}$} (A) ;
\pic[thick,"$\theta$", draw=blue,-stealth, angle eccentricity=1.2, angle radius=1cm]
{angle=A--C--B};
\pic[thick,"$\theta$", draw=red, stealth-, angle eccentricity=1.2, angle radius=0.9cm]
{angle=D--C--A};
\end{tikzpicture}
\end{figure}
\end{frame}
\end{document}
Can anybody help me?
If you have fragile content in your frame, like certain tikz pictures, use the fragile frame option.
Some other comments:
the serif class option is obsolete. A warning in the log file will tell you to use the serif font theme instead, but as you already do this, there is really no reason to use this class option
if your tex distribution isn't terrible outdated, you no longer need \usepackage[utf8]{inputenc}
there are two \setbeamertemplate{caption}[numbered]
you don't need color and the ams* packages, beamer already loads them for you
\documentclass[xcolor=dvipsnames,10pt]{beamer} % serif, mathserif
\usepackage[english,brazil]{babel}
%\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{ae}
\setbeamertemplate{caption}[numbered]
\setlength\abovecaptionskip{-3pt}
%\setbeamertemplate{caption}[numbered]
\setbeamerfont{caption}{size=\scriptsize}
\usefonttheme[onlymath]{serif}
%\usepackage{color}
%\usepackage{amsmath}
%\usepackage{amsfonts}
%\usepackage{amssymb}
%\usepackage{amstext}
\usepackage{mathrsfs}
\usepackage{icomma}
\usepackage{bm}
\usepackage{steinmetz}
\usepackage{tikz}
\usepackage{adjustbox}
\usepackage{subfigure}
\usepackage{ragged2e}
\usepackage{tkz-euclide}
\usetikzlibrary{angles,quotes,babel}
\DeclareMathOperator{\sen}{sen}
\mode<presentation>
{
\usetheme{CambridgeUS}
}
\begin{document}
\begin{frame}[fragile]
\frametitle{Frame Title}
\begin{figure}
\begin{tikzpicture}
\coordinate (C) at (-1.5,-1);
\coordinate (A) at (1.5,-1);
\coordinate (B) at (1.5,1);
\coordinate (D) at (1.5,-3);
\node [below] at (3,-1) {$\Re$};
\node [above] at (-1.5,2) {$\Im$};
%draw cartesian plane
\draw[stealth-stealth] (-1.5,-4) -- (-1.5,2) coordinate (y axis);
\draw[-stealth] (C) -- (3,-1) coordinate (x axis);
\draw[very thick,-{Stealth[length=3mm, width=1.5mm]}] (C) --
node[font=\Large,sloped,above] {$S_{abc}$} (B);
\draw[very thick,-{Stealth[length=3mm, width=1.5mm]}](A) --
node[font=\Large,pos=0.7,right] {$Q_{abc}$} (B);
\draw[very thick,-{Stealth[length=3mm, width=1.5mm]}](C) --
node[font=\Large,pos=0.8,above] {$P_{abc}$} (A);
\draw[very thick,-{Stealth[length=3mm, width=1.5mm]}](C) --
node[font=\Large,sloped,below] {$S_{abc}$} (D);
\draw[very thick,{Stealth[length=3mm, width=1.5mm]}-](D)--
node[font=\Large,pos=0.3,right] {$-Q_{abc}$} (A) ;
\pic[thick,"$\theta$", draw=blue,-stealth, angle eccentricity=1.2, angle radius=1cm]
{angle=A--C--B};
\pic[thick,"$\theta$", draw=red, stealth-, angle eccentricity=1.2, angle radius=0.9cm]
{angle=D--C--A};
\end{tikzpicture}
\end{figure}
\end{frame}
\end{document}
I want to center two tikzpictures which are both in a own subfloat on a landscape page. With my example code the begin of the second timeline is shifted. You can see the shift in the picture. I want to have the beginnigs of the two timelines on the same horizontal line.
\documentclass[a4paper,11pt,smallchapters,blue,extramargin,lnum]{article}
\usepackage{lscape}
\usepackage{subfig}
\usepackage{graphicx}
\usepackage{tikz}
\begin{document}
\begin{landscape}
\vspace*{\fill}
\begin{figure}[h]
\begin{center}
\subfloat[Situation 1 \label{fig:situationen-2.impl-exp3:situation1}] {
\begin{tikzpicture}
% draw horizontal line
\draw (0,0) -- (15,0);
% draw vertical lines
\foreach \x in {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}
\draw (\x cm,3pt) -- (\x cm,-3pt);
% draw nodes
\draw (0,0) node[below=3pt] {$ 0s $} node[above=15pt] {Raspberry Pi} node[above=1pt] {sendet};
\draw (10,0) node[below=3pt] {$ 50s $} node[above=12pt] {Beginn} node[above=1pt] {Zustandswechsel};
\draw (15,0) node[below=3pt] {$ 150s $} node[above=3pt] {Ende};
\end{tikzpicture}
}
\newline
\subfloat[Situation 2 \label{fig:situationen-2.impl-exp3:situation2}] {
\begin{tikzpicture}
% draw horizontal line
\draw (0,0) -- (15,0);
% draw vertical lines
\foreach \x in {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}
\draw (\x cm,3pt) -- (\x cm,-3pt);
% draw nodes
\draw (0,0) node[below=3pt] {$ 0s $} node[above=15pt] {Raspberry Pi} node[above=1pt] {sendet};
\draw (5,0) node[below=3pt] {$ 50s $} node[above=12pt] {Beginn} node[above=1pt] {Zustandswechsel};
\draw (10,0) node[below=3pt] {$ 100s $} node[above=12pt] {Senderate} node[above=1pt] {kleiner};
\draw (15,0) node[below=3pt] {$ 150s $} node[above=3pt] {Ende};
\end{tikzpicture}
}
\caption{Untersuchte Situationen in Experiment 3 der 2.Implementierung} \label{fig:situationen-2.impl-exp2}
\end{center}
\end{figure}
\vspace*{\fill}
\end{landscape}
\end{document}
The problem is caused by the combination of centred text and the forced line break from \newline. You can avoid this by simply leaving an empty line to start a new paragraph:
\documentclass[a4paper,11pt,smallchapters,blue,extramargin,lnum]{article}
\usepackage{lscape}
\usepackage{subfig}
\usepackage{graphicx}
\usepackage{tikz}
\begin{document}
\begin{landscape}
\vspace*{\fill}
\begin{figure}[h]
\centering
% \begin{center}
\subfloat[Situation 1 \label{fig:situationen-2.impl-exp3:situation1}] {
\begin{tikzpicture}
% draw horizontal line
\draw (0,0) -- (15,0);
% draw vertical lines
\foreach \x in {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}
\draw (\x cm,3pt) -- (\x cm,-3pt);
% draw nodes
\draw (0,0) node[below=3pt] {$ 0s $} node[above=15pt] {Raspberry Pi} node[above=1pt] {sendet};
\draw (10,0) node[below=3pt] {$ 50s $} node[above=12pt] {Beginn} node[above=1pt] {Zustandswechsel};
\draw (15,0) node[below=3pt] {$ 150s $} node[above=3pt] {Ende};
\end{tikzpicture}
}
\subfloat[Situation 2 \label{fig:situationen-2.impl-exp3:situation2}] {
\begin{tikzpicture}
% draw horizontal line
\draw (0,0) -- (15,0);
% draw vertical lines
\foreach \x in {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}
\draw (\x cm,3pt) -- (\x cm,-3pt);
% draw nodes
\draw (0,0) node[below=3pt] {$ 0s $} node[above=15pt] {Raspberry Pi} node[above=1pt] {sendet};
\draw (5,0) node[below=3pt] {$ 50s $} node[above=12pt] {Beginn} node[above=1pt] {Zustandswechsel};
\draw (10,0) node[below=3pt] {$ 100s $} node[above=12pt] {Senderate} node[above=1pt] {kleiner};
\draw (15,0) node[below=3pt] {$ 150s $} node[above=3pt] {Ende};
\end{tikzpicture}
}
\caption{Untersuchte Situationen in Experiment 3 der 2.Implementierung} \label{fig:situationen-2.impl-exp2}
% \end{center}
\end{figure}
\vspace*{\fill}
\end{landscape}
\end{document}
(I'm using \centering instead of the center environment to avoid additional vertical spacing, but for your use case that's not really important)
I am trying to draw an arrow to link these two pictures and demonstrate the rotation. Can I do this with this minipage idea or do I need to draw them differently?
\begin{minipage}{0,5\textwidth}
\begin{center}
\begin{tikzpicture}
\draw (0,2)--(0,-2);
\draw (-2,0)--(2,0);
\newdimen\R
\R=1.5cm
\draw (36:\R)
\foreach \x in {36,108,180,252,324} { -- (\x:\R) }
-- cycle (36:\R) node[right] {4}
-- cycle (108:\R) node[above] {5}
-- cycle (180:\R) node[below] {1}
-- cycle (252:\R) node[below] {2} -- cycle (324:\R) node[right] {3};
\end{tikzpicture}
\end{center}
\end{minipage}
\begin{minipage}{0,5\textwidth}
\begin{center}
\begin{tikzpicture}
\draw (0,2)--(0,-2);
\draw (-2,0)--(2,0);
\newdimen\R
\R=1.5cm
\draw (36:\R)
\foreach \x in {36,108,180,252,324} { -- (\x:\R) }
-- cycle (36:\R) node[right] {3}
-- cycle (108:\R) node[above] {4}
-- cycle (180:\R) node[below] {5}
-- cycle (252:\R) node[below] {1} -- cycle (324:\R) node[right] {2};
\end{tikzpicture}
\end{center}
\end{minipage}
In theory you could use the tikzmark library to draw arrows between your two minipages, but I think it is easier to just put both drawing in a single tikzpicture:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{scope}
\draw (0,2)--(0,-2);
\draw (-2,0)--(2,0);
\newdimen\R
\R=1.5cm
\draw (36:\R)
\foreach \x in {36,108,180,252,324} { -- (\x:\R) }
-- cycle (36:\R) node[right] {4}
-- cycle (108:\R) node[above] {5}
-- cycle (180:\R) node[below] {1}
-- cycle (252:\R) node[below] {2} -- cycle (324:\R) node[right] {3};
\end{scope}
\begin{scope}[xshift=6cm]
\draw (0,2)--(0,-2);
\draw (-2,0)--(2,0);
\newdimen\R
\R=1.5cm
\draw (36:\R)
\foreach \x in {36,108,180,252,324} { -- (\x:\R) }
-- cycle (36:\R) node[right] {3}
-- cycle (108:\R) node[above] {4}
-- cycle (180:\R) node[below] {5}
-- cycle (252:\R) node[below] {1} -- cycle (324:\R) node[right] {2};
\end{scope}
\draw[red,<->] (2.3,0) -- (3.8,0);
\end{tikzpicture}
\end{center}
\end{document}
My code
\documentclass[11pt,twoside]{report}
\usepackage[american]{circuitikz}
\begin{document}
\begin{circuitikz}
\draw
(0,0)
to[sV, v<=$V$] ++(0,2.5)
to[R, l=$R$,i=$i$,-o] ++(3.5,0)
to[open, v^=$~~U$] ++(0,-2.5)
to[short,-o] ++(0,0)
--(0,0)
;
\end{circuitikz}
\end{document}
Gives me
I want
How do I remove polarity signs from the voltage source?
\documentclass{standalone}
\usepackage[
american,
]{circuitikz}
\begin{document}
\begin{circuitikz}[]
\draw
(0,0)
to[sV, voltage/american plus/.initial={}, voltage/american minus/.initial={}, v<=$V$] ++(0,2.5)
to[R, l=$R$,i=$i$,-o] ++(3.5,0)
to[open, v^=$~~U$] ++(0,-2.5)
to[short,-o] ++(0,0)
--(0,0)
;
\end{circuitikz}
\end{document}
I had tried this code and I want the braces in the figure as there are in the attached picture.
\begin{figure}[hbt!]
\begin{center}
\begin{tikzpicture}[
thick,
acteur/.style={
circle,
fill=black,
thick,
inner sep=2pt,
minimum size=0.2cm
}
]
\node (a1) at (-0.3,0.65) [acteur,label=below :\scriptsize{}]{};
\node (a2) at (1,0)[acteur,label=below:\scriptsize{\hspace{0.3cm}$x_{0}$}]{};
\node (a3) at (2,0) [acteur,label=below:\scriptsize{$x_{1}$}]{};
\node (a4) at (3,0) [acteur,label=below:\scriptsize{$x_{2}$}]{};
\node (a5) at (4,0) [acteur,label=above :\scriptsize{}]{};
\node (a6) at (5,0) [acteur,label=below right :\scriptsize{\hspace{-0.9cm}$x_{k-s-t}$}]{};
\node (a7) at (6.5,0) [acteur,label=below:\scriptsize{}]{};
\node (a8) at (-0.3,-0.65) [acteur,label=above:\scriptsize{}]{};
\node (a9) at (0.4,1.3) [acteur,label=above:\scriptsize{}]{};
\node (a10) at (0.4,-1.3) [acteur,label=below:\scriptsize{}]{};
\node (a11) at (6,1) [acteur,label=below:\scriptsize{}]{};
\node (a12) at (6,-1) [acteur,label=below:\scriptsize{}]{};
\node (a13) at (5.3,1.3) [acteur,label=below:\scriptsize{}]{};
\node (a14) at (5.3,-1.3) [acteur,label=below:\scriptsize{}]{};
\draw (a1) -- (a2);
\draw (a2) -- (a9);
\draw (a2) -- (a8);
\draw (a2) -- (a10);
\draw (a2) -- (a3);
\draw (a3) -- (a4);
\draw [dashed] (a4) -- (a5);
\draw (a5) -- (a6);
\draw (a6) -- (a7);
\draw (a6) -- (a11);
\draw (a6) -- (a13);
\draw (a6) -- (a12);
\draw (a6) -- (a14);
\end{tikzpicture}
\end{center}
\caption{\small{The graph $\mathcal{P}(k,s,t)$}}
\end{figure}
You can use the decorations library
\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{figure}[hbt!]
\begin{center}
\begin{tikzpicture}[
thick,
acteur/.style={
circle,
fill=black,
thick,
inner sep=2pt,
minimum size=0.2cm
}
]
\node (a1) at (-0.3,0.65) [acteur,label=below :\scriptsize{}]{};
\node (a2) at (1,0)[acteur,label=below:\scriptsize{\hspace{0.3cm}$x_{0}$}]{};
\node (a3) at (2,0) [acteur,label=below:\scriptsize{$x_{1}$}]{};
\node (a4) at (3,0) [acteur,label=below:\scriptsize{$x_{2}$}]{};
\node (a5) at (4,0) [acteur,label=above :\scriptsize{}]{};
\node (a6) at (5,0) [acteur,label=below right :\scriptsize{\hspace{-0.9cm}$x_{k-s-t}$}]{};
\node (a7) at (6.5,0) [acteur,label=below:\scriptsize{}]{};
\node (a8) at (-0.3,-0.65) [acteur,label=above:\scriptsize{}]{};
\node (a9) at (0.4,1.3) [acteur,label=above:\scriptsize{}]{};
\node (a10) at (0.4,-1.3) [acteur,label=below:\scriptsize{}]{};
\node (a11) at (6,1) [acteur,label=below:\scriptsize{}]{};
\node (a12) at (6,-1) [acteur,label=below:\scriptsize{}]{};
\node (a13) at (5.3,1.3) [acteur,label=below:\scriptsize{}]{};
\node (a14) at (5.3,-1.3) [acteur,label=below:\scriptsize{}]{};
\draw (a1) -- (a2);
\draw (a2) -- (a9);
\draw (a2) -- (a8);
\draw (a2) -- (a10);
\draw (a2) -- (a3);
\draw (a3) -- (a4);
\draw [dashed] (a4) -- (a5);
\draw (a5) -- (a6);
\draw (a6) -- (a7);
\draw (a6) -- (a11);
\draw (a6) -- (a13);
\draw (a6) -- (a12);
\draw (a6) -- (a14);
\draw[decorate,decoration={brace,amplitude=10pt}]
(-0.5, -1) -- (-0.5, 1) node[left, midway, xshift = -10pt]{$s$ vertices};
\draw[decorate,decoration={brace,amplitude=10pt}]
(6.5, 1) -- (6.5, -1) node[right, midway, xshift = 10pt]{$t$ vertices};
\end{tikzpicture}
\end{center}
\caption{\small{The graph $\mathcal{P}(k,s,t)$}}
\end{figure}
\end{document}