How to draw a horizontal arrow between 2 nodes in LaTex? - latex

I am new to latex. My issue is that I would like the arrow from the "perceived" to the "distress" node to be horizontal. As you can see in the picture attached below, the arrow is not completely horizontal. Thanks in advance.
[1]: https://i.stack.imgur.com/gq17O.png
\documentclass[jou]{apa7}
\usepackage{tikz}
\usetikzlibrary{shapes, shadows, arrows}
\usetikzlibrary{positioning}
\tikzset{mynode/.style={align=center}
}
\begin{document}
[\begin{tikzpicture}
\node\[mynode\] (mental){\begin{tabular}{c} Mental health \\ support \end{tabular}};
\node\[mynode,below left=of mental\](family) {\begin{tabular}{c} Perceived family \\ support \end{tabular}};
\node\[mynode,below right=of mental\](distress) {Distress};
\draw\[-latex\] (family.north) -- node\[auto,\] {.2395} (mental.west);
\draw\[-latex\] (mental.east) -- node\[auto,\] {1.4509} (distress.north);
\draw\[-latex\] (family.east) -- node\[below=3mm, align=center\] {$-.0453$$^*$} (distress.west);
\draw\[-latex\] (family.east) -- node\[above=3mm, align=center\] {$-.0248$$^*$} (distress.west);
\end{tikzpicture}
\end{document}

\documentclass[jou]{apa7}
\usepackage{tikz}
\usetikzlibrary{shapes, shadows, arrows}
\usetikzlibrary{positioning}
\tikzset{mynode/.style={align=center,text width=3cm}
}
\begin{document}
\begin{tikzpicture}
\node[mynode] (mental){Mental health \\ support};
\node[below= of mental] (dummy) {};
\node[mynode,left=2cm of dummy](family) {Perceived family \\ support};
\node[mynode,right=2cm of dummy](distress) {Distress};
\draw[-latex] (family.north) -- node[auto,] {.2395} (mental.west);
\draw[-latex] (mental.east) -- node[auto,] {1.4509} (distress.north);
\draw[-latex] (family.east) -- node[below=3mm, align=center] {$-.0453$$^*$} (distress.west);
\draw[-latex] (family.east) -- node[above=3mm, align=center] {$-.0248$$^*$} (distress.west);
\end{tikzpicture}
\end{document}

Related

Latex beamer error: argument of \language#active#arg" has an extra }. \end{frame}

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}

Problem with putting two tikzpictures next to each other [duplicate]

This question already has answers here:
Place two tikzpictures next to eachother LaTeX
(2 answers)
Closed 10 months ago.
I have a problem with putting two tikzpictures next to each other.
I have tried using minipages too, but that ain't working too.
\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[left = 23mm, bottom = 24mm, top = 24mm, right = 29mm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{circuitikz}
\usetikzlibrary{arrows,shapes,positioning}
\usepackage{subfig}
\begin{figure}[h]
\centering
\begin{subfloat}[lfig1] {
\centering
\begin{tikzpicture}
\draw[thin, ->] (1.2,0) -- (1.2,5.4) node[below left]{$\phi_2(t)$};
\draw[thin, ->] (0,1.2) -- (5.4,1.2) node[below left]{$\phi_1(t)$};
\draw[very thick, blue, ->] (1.2,1.2) -- (1.2,4.15) node[black][midway, right=1mm]{$s_2$};
\draw[very thick,red,->] (1.2,1.2) -- (4.15,1.2) node[black][midway, above=1mm]{$s_1$};
\draw[thin, dashed] (1.2,4.2) -- (4.2,1.2) node[midway, above right]{$\sqrt{2E_b}$};
\end{tikzpicture}
}
\end{subfloat}
\hspace{10pt}
\begin{subfloat}[lfig2] {
\centering
\begin{tikzpicture}
\draw[thin, ->] (0,1.2) -- (8.4,1.2) node[below left]{$\phi_1(t)$};
\draw[thin, ->] (4.2,0) -- (4.2,3.4) node[below left]{$\phi_2(t)$};
\draw[thick, blue, ->] (4.2,1.2) -- (1.25,1.2) node[midway, above=1mm]{$s_2$};
\draw[thick, red, ->] (4.2,1.2) -- (7.15,1.2) node[midway, above=1mm]{$s_1$};
\end{tikzpicture}
}
\end{subfloat}
\caption{captionfig1}
\label{Slika:fig1}
\end{figure}
So, I need to put these two graphs in the same 'row'. I have tried using minipages with different sized \linewidth, but that lead me nowhere.
I need it to be shown like this: https://prnt.sc/CM8kFW-DvRQZ
Empty lines in latex denote the end of a paragraph. If you don't want a line break, don't end the current paragraph by adding all these empty lines.
\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[left = 23mm, bottom = 24mm, top = 24mm, right = 29mm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{circuitikz}
\usetikzlibrary{arrows,shapes,positioning}
\usepackage{subfig}
\begin{document}
\begin{figure}[h]
\centering
\begin{subfloat}[lfig1] {
\centering
\begin{tikzpicture}
\draw[thin, ->] (1.2,0) -- (1.2,5.4) node[below left]{$\phi_2(t)$};
\draw[thin, ->] (0,1.2) -- (5.4,1.2) node[below left]{$\phi_1(t)$};
\draw[very thick, blue, ->] (1.2,1.2) -- (1.2,4.15) node[black][midway, right=1mm]{$s_2$};
\draw[very thick,red,->] (1.2,1.2) -- (4.15,1.2) node[black][midway, above=1mm]{$s_1$};
\draw[thin, dashed] (1.2,4.2) -- (4.2,1.2) node[midway, above right]{$\sqrt{2E_b}$};
\end{tikzpicture}
}
\end{subfloat}
\hspace{10pt}
\begin{subfloat}[lfig2] {
\centering
\begin{tikzpicture}
\draw[thin, ->] (0,1.2) -- (8.4,1.2) node[below left]{$\phi_1(t)$};
\draw[thin, ->] (4.2,0) -- (4.2,3.4) node[below left]{$\phi_2(t)$};
\draw[thick, blue, ->] (4.2,1.2) -- (1.25,1.2) node[midway, above=1mm]{$s_2$};
\draw[thick, red, ->] (4.2,1.2) -- (7.15,1.2) node[midway, above=1mm]{$s_1$};
\end{tikzpicture}
}
\end{subfloat}
\caption{captionfig1}
\label{Slika:fig1}
\end{figure}
\end{document}

Place boundary of two adjacent nodes on top of each other

If I place two nodes adjacent to each other the resulting boundary between the nodes is doubled making it more thick than other boundarys. Is it possible to place them on top of each other in order to keep the original thickness?
Here my code and below some example pictures:
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{figure}
\begin{center}
\begin{tikzpicture}
\tikzstyle{node} = [draw, rectangle, minimum width=1cm]
\node [node] (n_one) {node 1};
\node [node, right = 0cm of n_one.north east, anchor = north west] (n_two) {node 2};
\end{tikzpicture}
\end{center}
\end{figure}
\end{document}
You can shift the right node by one line width:
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{figure}
\begin{center}
\begin{tikzpicture}
\tikzstyle{node} = [draw, rectangle, minimum width=1cm]
\node [blue,node] (n_one) {node 1};
\node [red,node, right = -\the\pgflinewidth of n_one.north east, anchor = north west] (n_two) {node 2};
\end{tikzpicture}
\end{center}
\end{figure}
\end{document}
Or you could draw only a single node:
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{shapes.multipart}
\begin{document}
\begin{figure}
\begin{center}
\begin{tikzpicture}
\node[
rectangle split,
rectangle split parts=2,
draw,
rectangle split horizontal,
rectangle split part align={center, top, bottom}
] at (0,0) {node 1\nodepart{two}node 2};
\end{tikzpicture}
\end{center}
\end{figure}
\end{document}

How do I to fill the regions of the petals?

The original images that I want:
Left me to fill the regions. Can somebody help me? My LaTeX code:
\documentclass[border=5mm]{standalone}
\usepackage[svgnames,x11names,dvispnames]{xcolor}
\usepackage{tikz,tkz-base,tkz-euclide,tkz-fct}
\begin{document}
\begin{tikzpicture}
\tkzDefPoints{0/0/A, 6/0/B}
\tkzDefSquare(A,B) \tkzGetPoints{C}{D}
\tkzDrawPolygon(A,B,C,D)
\tkzDefMidPoint(A,B) \tkzGetPoint{M}
\tkzDefMidPoint(A,D) \tkzGetPoint{N}
\tkzDefMidPoint(B,C) \tkzGetPoint{O}
\tkzDefMidPoint(C,D) \tkzGetPoint{P}
\tkzDrawSemiCircle(M,B)
\tkzDrawSemiCircle(N,A)
\tkzDrawSemiCircle(O,C)
\tkzDrawSemiCircle(P,D)
%\tkzLabelPoints(A,B,C,D,M,N,O,P)
\end{tikzpicture}
\end{document}
\documentclass[border=5mm]{standalone}
\usepackage[svgnames,x11names,dvispnames]{xcolor}
\usepackage{tikz,tkz-base,tkz-euclide,tkz-fct}
\begin{document}
\begin{tikzpicture}
\tkzDefPoints{0/0/A, 6/0/B}
\tkzDefSquare(A,B) \tkzGetPoints{C}{D}
\tkzDrawPolygon(A,B,C,D)
\tkzDefMidPoint(A,B) \tkzGetPoint{M}
\tkzDefMidPoint(A,D) \tkzGetPoint{N}
\tkzDefMidPoint(B,C) \tkzGetPoint{O}
\tkzDefMidPoint(C,D) \tkzGetPoint{P}
\begin{pgfinterruptboundingbox}
\begin{scope}
\tkzClipCircle(N,A)
\tkzDrawSemiCircle[fill=blue,draw=none](M,B)
\tkzDrawSemiCircle[fill=yellow,draw=none](P,D)
\end{scope}
\begin{scope}
\tkzClipCircle(O,B)
\tkzDrawSemiCircle[fill=red,draw=none](M,B)
\tkzDrawSemiCircle[fill=green,draw=none](P,D)
\end{scope}
\end{pgfinterruptboundingbox}
\tkzLabelPoints(A,B,C,D,M,N,O,P)
\end{tikzpicture}
\end{document}

How do I get rid of polarity signs of source?

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}

Resources