tikz 中的奇怪错误

tikz 中的奇怪错误

我正在尝试使用 tikz 绘制流程图。以下是我的尝试。我遇到了一些奇怪的错误。你能帮助我吗?

\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}

答案1

借助tikzset和改变namemyname(也nidhin 建议在评论中):

在此处输入图片描述

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


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


\tikzset{
    process/.style = {rectangle, 
                      minimum width=5cm, 
                      text width=5cm, 
                      minimum height=1cm, 
                      draw=black},
    myname/.style={rectangle,
                  draw=black,
                  minimum width=5cm,
                  text width=5cm,
                  minimum height=1cm}, 
    arrow/.style = {thick,
                    ->,
                    >=stealth},
        }


\begin{document}
    \begin{tikzpicture}[node distance = 1cm]
        \node[myname](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

  • 您的节点样式processname相同。我宁愿只定义一个,例如名为box
  • 你的真实图像的上下文是未知的,但你可以通过使用chains库将这两个框链接起来`
  • 考虑到上述情况,真正的 MWE 可以是:
\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}, % where is used?
        }

\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}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容