1

I am trying to draw a flowchart with tikz. Below is my try. I would like the vertical arrow with superscript "a" to be connected with the horizontal arrow with superscript "n" and be more centered in the middle of the node "Step 3". Could you please tell me how I can do that?

\documentclass[a4paper, 11pt]{article}
\usepackage[a4paper,left=3cm,right=3cm,top=3cm,bottom=3cm]{geometry}



\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{clrscode}
\usepackage{enumitem}
\usepackage{fancyhdr}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage{latexsym}
\usepackage{lmodern}
\usepackage{mathtools}
\usepackage{mdframed}
\usepackage{pgf}
\usepackage{tcolorbox}
\usepackage{tikz}
\usepackage{tikzpeople}
\usepackage[absolute,overlay]{textpos}
\usepackage{xcolor}



\usetikzlibrary{arrows}
\usetikzlibrary{positioning} 
\usetikzlibrary{shapes.multipart}
\usetikzlibrary{shapes.geometric}

\tikzstyle{process} = [rectangle, minimum width=5cm, text width=5cm, minimum             height=1cm, draw=black]
\tikzstyle{arrow} = [thick,->,>=stealth]
\tikzstyle{name} = [rectangle, minimum width=5cm, text width=5cm, minimum     height=1cm, draw=black]

\DeclareGraphicsExtensions{.pdf,.png,.jpg, .tif}


\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
  \fancyfoot[LE,RO]{\thepage}
  \renewcommand{\familydefault}{\sfdefault}


\newcommand{\legendre}[2]{\genfrac{(}{)}{}{}{#1}{#2}}
\newcommand{\jacobi}[2]{\genfrac{(}{)}{}{}{#1}{#2}}
\newcommand{\congruent}[3]{$#1 \equiv #2 \text{ } \left( \text{mod } #3             \right)$}
\newcommand{\ZNZ}[1][n]{\mathbb{Z}/{#1}\mathbb{Z}}
\newcommand{\ZNZX}[1][n]{(\mathbb{Z}/{#1}\mathbb{Z})^\times}
\newcommand{\QR}[1][n]{\mathcal{QR}_{#1}}
\newcommand{\QNR}[1][n]{\mathcal{QNR}_{#1}}
\newcommand{\QNRP}{\mathcal{QNR}_n^{+1}}
\newcommand{\JNP}{\mathcal{J}_n^{+1}}
\newcommand{\JNM}{\mathcal{J}_n^{-1}}



\begin{document}
    \begin{tikzpicture}[node distance = 1cm]
        \node[name](alice){\textbf{Alice}};
        \node[process, below = of alice](step1){\textbf{Step 1:} Pick two     distinct large Blum primes $p$ and $q$ and set $n \coloneqq pq$.};


\end{tikzpicture}




\end{document}
2

Based on my answer to your previous question: just add macro join to box options.

\documentclass[a4paper, 11pt]{article}
\usepackage{mathtools}

\usepackage{tikz}
\usetikzlibrary{arrows.meta,
               chains,
               positioning}

\tikzset{
box/.style = {rectangle, draw,
              text width=5cm,
              minimum height=1cm},
arr/.style = {thick,-Stealth},
        }


\begin{document}
    \begin{tikzpicture}[
node distance = 1cm,
  start chain = going below
                        ]
    \begin{scope}[every node/.style = {box, on chain, join=by arr}] % <---
\node   (alice) {\textbf{Alice}};
\node   (step1) {\textbf{Step 1:} Pick two distinct large Blum primes 
                 $p$ and $q$ and set $n \coloneqq pq$.};
    \end{scope}
\end{tikzpicture}
\end{document}

enter image description here

However, you can draw arrows separately with \draw command:

\documentclass[a4paper, 11pt]{article}
\usepackage{mathtools}

\usepackage{tikz}
\usetikzlibrary{arrows.meta,
               chains,
               positioning}

\tikzset{
box/.style = {rectangle, draw,
              text width=5cm,
              minimum height=1cm},
arr/.style = {thick,-Stealth},
        }


\begin{document}
    \begin{tikzpicture}[
node distance = 1cm,
  start chain = going below
                        ]
    \begin{scope}[every node/.style = {box, on chain}] 
\node   (alice) {\textbf{Alice}};
\node   (step1) {\textbf{Step 1:} Pick two distinct large Blum primes 
                 $p$ and $q$ and set $n \coloneqq pq$.};
    \end{scope}
\draw[arr] (alice) -- (step1); % <---
\end{tikzpicture}
\end{document}
1

If all the nodes in the tikzpicture have the same style, i.e. use the same keys, you do not need to define a style for that. Rather, it suffices to say nodes={<keys>}.

\documentclass[a4paper, 11pt]{article}
\usepackage[a4paper,left=3cm,right=3cm,top=3cm,bottom=3cm]{geometry}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[node distance=1cm,
  nodes={rectangle,minimum width=5cm,text width=5cm,minimum height=1cm,draw=black}]
 \node(alice){\textbf{Alice}};
 \node[below=of alice](step1){\textbf{Step 1:} Pick two distinct large Blum
 primes $p$ and $q$ and set $n \coloneqq p\,q$.};
 \draw[thick,-stealth] (alice) -- (step1);
\end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.