为什么我的 tikz 代码无法在 Overleaf 中编译

为什么我的 tikz 代码无法在 Overleaf 中编译

我正在为研究论文编写乳胶代码。我对乳胶的经验有限,但我知道基础知识。

我的代码如下所示。在文档中,我尝试包含图像的 tikz 代码。(我使用 matcha.io 创建了此代码)。但是,它似乎无法在 overleaf 中编译。有人能指出问题所在吗?

\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
% The preceding line is only needed to identify funding in the first footnote. If that is unneeded, please comment it out.
\let\oldvec\vec
\usepackage{xcolor}
\usepackage{breqn}
\usepackage{multirow}
\usepackage{float}
\usepackage[compact]{titlesec}
\titlespacing{\section}{10pt}{3pt}{3pt}
\usepackage{relsize}
\usepackage{interval}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{amsmath,etoolbox}
\usepackage[ruled,vlined]{algorithm2e}
\usepackage{cite}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{algorithmic}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage{xcolor}
\usepackage{enumitem}
\usepackage{amsthm}
\setlist{nolistsep,leftmargin=.6cm}
\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
    T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
\usepackage{amsmath, amssymb, bm, cite, epsfig, psfrag}
\usepackage{graphicx}
\usepackage{cuted}
\usepackage{soul} %didn't have package _ojas
\usepackage[left=0.65in, right=0.65in, bottom=0.99in, top=0.66in]{geometry}
\usepackage{dblfloatfix}
\usepackage{array}
\usepackage{lipsum}%didn't have package _ojas
%\usepackage{ragged2e}
\newcolumntype{P}[1]{>{\centering\hspace{0pt}}p{#1}}
\newcolumntype{M}[1]{>{\centering\hspace{0pt}}m{#1}}
\newcolumntype{L}{>{\centering\arraybackslash}m{3cm}}
\usepackage[font=small]{caption}
\usepackage{epstopdf}   
\usepackage{longtable}
\usepackage{supertabular,booktabs}
\usepackage{bbm}%didn't have package _ojas
\usepackage{multirow}
%\usepackage[usenames,dvipsnames]{xcolor}
\renewcommand{\arraystretch}{1.5}
\usepackage{subfigure}%didn't have package _ojas
\usepackage{etoolbox}
\usepackage{pbox}
\usepackage{fixltx2e}
\usepackage{tabu}   %didn't have package _ojas
\usepackage{filecontents}
\usepackage{enumerate}
\usepackage{textcomp}

\usepackage{colortbl}
\usepackage{fancyhdr}
\def\PL{\mathrm{PL}}
\def\dB{\mathrm{dB}}

\usepackage{tikz}



\pagestyle{fancy}
\fancyhead[C]{Confidential}
\usepackage{bm}
%\linespread{2}
\newtoggle{conference}
%\toggletrue{conference} % Use for GC version -- also change documentclass above
\togglefalse{conference} % Use for arxiv version -- also change documentclass
\interdisplaylinepenalty=2500

\def\del{\partial}
\def\ds{\displaystyle}
\def\ts{\textstyle}
\def\nn{\no}
\def\binomial{\mathop{\mathrm{binomial}}}
\def\half{{\ts\frac{1}{2}}}
\def\Half{{\frac{1}{2}}}
\def\N{{\mathbb{N}}}
\def\Z{{\mathbb{Z}}}
\def\Q{{\mathbb{Q}}}
\def\R{{\mathbb{R}}}
\def\C{{\mathbb{C}}}
\def\argmin{\mathop{\mathrm{arg\,min}}}
\def\argmax{\mathop{\mathrm{arg\,max}}}
%\def\span{\mathop{\mathrm{span}}}
\def\diag{\mathop{\mathrm{diag}}}
\def\x{\times}
\def\limn{\lim_{n \rightarrow \infty}}
\def\liminfn{\liminf_{n \rightarrow \infty}}
\def\limsupn{\limsup_{n \rightarrow \infty}}
\def\MID{\,|\,}
\def\MIDD{\,;\,}
\newcommand{\leqn}[1]{{\overset{\mathrm{(#1)}}{\leq}}}

\makeatletter
\newsavebox\myboxA
\newsavebox\myboxB
\newlength\mylenA
\newcommand*\xoverline[2][0.75]{%
    \sbox{\myboxA}{$\m@th#2$}%
    \setbox\myboxB\null% Phantom box
    \ht\myboxB=\ht\myboxA%
    \dp\myboxB=\dp\myboxA%
    \wd\myboxB=#1\wd\myboxA% Scale phantom
    \sbox\myboxB{$\m@th\overline{\copy\myboxB}$}%  Overlined phantom
    \setlength\mylenA{\the\wd\myboxA}%   calc width diff
    \addtolength\mylenA{-\the\wd\myboxB}%
    \ifdim\wd\myboxB<\wd\myboxA%
       \rlap{\hskip 0.5\mylenA\usebox\myboxB}{\usebox\myboxA}%
    \else
        \hskip -0.5\mylenA\rlap{\usebox\myboxA}{\hskip 0.5\mylenA\usebox\myboxB}%
    \fi}

\newtheorem{proposition}{Proposition}
\newtheorem{definition}{Definition}
\newtheorem{lemma}{Lemma}
\newtheorem*{theorem*}{Theorem}
\newtheorem{theorem}{Theorem}
\newtheorem{corollary}{Corollary}
\newtheorem{assumption}{Assumption}
\newtheorem{claim}{Claim}
\def\qed{\mbox{} \hfill $\Box$}
\setlength{\unitlength}{1mm}

\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}




\begin{document}

\tikzset{every picture/.style={line width=0.75pt}} %set default line width to 0.75pt        

\begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1]
%uncomment if require: \path (0,353); %set diagram left start at 0, and has height of 353


%Shape: Rectangle [id:dp22457526275614637] 
\draw   (59.67,69.83) -- (92.5,69.83) -- (92.5,96.23) -- (59.67,96.23) -- cycle ;
%Shape: Rectangle [id:dp3289801767420759] 
\draw   (59.67,110.83) -- (92.5,110.83) -- (92.5,137.32) -- (59.67,137.32) -- cycle ;
%Shape: Rectangle [id:dp6068291618082182] 
\draw   (59.67,217.6) -- (92.5,217.6) -- (92.5,242.83) -- (59.67,242.83) -- cycle ;
%Straight Lines [id:da8811710099492369] 
\draw  [dash pattern={on 0.84pt off 2.51pt}]  (76.21,142.88) -- (76.74,213.84) ;

%Straight Lines [id:da33012444847161304] 
\draw    (93,125) -- (146.67,125.8) ;
\draw [shift={(148.67,125.83)}, rotate = 180.86] [color={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.75]    (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;
%Straight Lines [id:da34696364935690194] 
\draw    (92,230) -- (145.67,230.8) ;
\draw [shift={(147.67,230.83)}, rotate = 180.86] [color={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.75]    (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;
%Straight Lines [id:da6237546399599201] 
\draw    (93,83) -- (146.67,83.8) ;
\draw [shift={(148.67,83.83)}, rotate = 180.86] [color={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.75]    (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;
%Shape: Rectangle [id:dp7773352348344063] 
\draw   (157,52.83) -- (264.67,52.83) -- (264.67,252.83) -- (157,252.83) -- cycle ;
%Straight Lines [id:da6109689652801984] 
\draw    (266,71) -- (288,70.85) ;
\draw [shift={(290,70.83)}, rotate = 179.6] [color={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.75]    (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;
%Straight Lines [id:da047951388292807096] 
\draw    (266,93) -- (288,92.85) ;
\draw [shift={(290,92.83)}, rotate = 179.6] [color={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.75]    (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;
%Straight Lines [id:da34839111835378] 
\draw    (266,242) -- (288,241.85) ;
\draw [shift={(290,241.83)}, rotate = 179.6] [color={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.75]    (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;
%Straight Lines [id:da41060400275269915] 
\draw  [dash pattern={on 0.84pt off 2.51pt}]  (314,116.83) -- (314,127.83) -- (314,139.83) ;
%Shape: Circle [id:dp762871092762504] 
\draw   (474,80) .. controls (474,66.19) and (485.19,55) .. (499,55) .. controls (512.81,55) and (524,66.19) .. (524,80) .. controls (524,93.81) and (512.81,105) .. (499,105) .. controls (485.19,105) and (474,93.81) .. (474,80) -- cycle ;
%Shape: Circle [id:dp7600420357208382] 
\draw   (476,226) .. controls (476,212.19) and (487.19,201) .. (501,201) .. controls (514.81,201) and (526,212.19) .. (526,226) .. controls (526,239.81) and (514.81,251) .. (501,251) .. controls (487.19,251) and (476,239.81) .. (476,226) -- cycle ;
%Straight Lines [id:da8115776943587054] 
\draw    (325,64.83) -- (478.69,241.33) ;
\draw [shift={(480,242.83)}, rotate = 228.95] [color={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.75]    (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;
%Straight Lines [id:da2518078601190321] 
\draw    (326,94.83) -- (478.56,241.45) ;
\draw [shift={(480,242.83)}, rotate = 223.86] [color={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.75]    (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;
%Straight Lines [id:da22053870828697608] 
\draw    (328,242.83) -- (478,242.83) ;
\draw [shift={(480,242.83)}, rotate = 180] [color={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.75]    (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;
%Straight Lines [id:da7218928617499938] 
\draw    (326,94.83) -- (478.04,65.22) ;
\draw [shift={(480,64.83)}, rotate = 168.98] [color={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.75]    (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;
%Straight Lines [id:da4943900420018965] 
\draw    (325,64.83) -- (478,64.83) ;
\draw [shift={(480,64.83)}, rotate = 180] [color={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.75]    (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;
%Straight Lines [id:da8267005947489428] 
\draw    (328,242.83) -- (478.7,66.35) ;
\draw [shift={(480,64.83)}, rotate = 130.5] [color={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.75]    (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;
%Shape: Rectangle [id:dp7502542452092797] 
\draw   (304,52.83) -- (323,52.83) -- (323,252.83) -- (304,252.83) -- cycle ;
%Straight Lines [id:da4833542395072692] 
\draw  [dash pattern={on 0.84pt off 2.51pt}]  (314,186.83) -- (314,197.83) -- (313,223.83) ;
%Straight Lines [id:da6527936483027117] 
\draw    (326,154.83) -- (478.27,65.84) ;
\draw [shift={(480,64.83)}, rotate = 149.7] [color={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.75]    (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;
%Straight Lines [id:da20897174921677264] 
\draw    (326,154.83) -- (478.26,241.84) ;
\draw [shift={(480,242.83)}, rotate = 209.74] [color={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.75]    (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;

% Text Node
\draw (63,72.4) node [anchor=north west][inner sep=0.75pt]  [font=\small]  {$X_{t}^{a_{1}}$};
% Text Node
\draw (65,216.4) node [anchor=north west][inner sep=0.75pt]  [font=\small]  {$X_{t}^{a_{k}}$};
% Text Node
\draw (61.67,114.23) node [anchor=north west][inner sep=0.75pt]  [font=\small]  {$X_{t}^{a_{2}}$};
% Text Node
\draw (169,68.4) node [anchor=north west][inner sep=0.75pt]  [font=\LARGE]  {$\sum _{i=1}^{k} X_{t}^{a_{i}}$};
% Text Node
\draw (168,191) node [anchor=north west][inner sep=0.75pt]   [align=left] {{\scriptsize Hamming weight }\\{\scriptsize  \ \ \ computation}};
% Text Node
\draw (37,4) node [anchor=north west][inner sep=0.75pt]   [align=left] {{\footnotesize Channel input}\\{\footnotesize  $\displaystyle \ \ \ \ \ \ \ \ C_{in}$}};
% Text Node
\draw (309,62.4) node [anchor=north west][inner sep=0.75pt]    {$0$};
% Text Node
\draw (309,87.4) node [anchor=north west][inner sep=0.75pt]    {$1$};
% Text Node
\draw (310,232.4) node [anchor=north west][inner sep=0.75pt]    {$k$};
% Text Node
\draw (493,66.4) node [anchor=north west][inner sep=0.75pt]  [font=\Large]  {$0$};
% Text Node
\draw (493,211.4) node [anchor=north west][inner sep=0.75pt]  [font=\Large]  {$1$};
% Text Node
\draw (453,7) node [anchor=north west][inner sep=0.75pt]   [align=left] {{\footnotesize Channel Output}\\{\footnotesize  $\displaystyle \ \ \ \ \ \ \ \ \ \ Z_{t}$}};
% Text Node
\draw (49,281.4) node [anchor=north west][inner sep=0.75pt]  [font=\footnotesize]  {$active\ device\ set:\ \{a_{1} ,a_{2} ,\dotsc ,a_{k} \}$};
% Text Node
\draw (310,151.4) node [anchor=north west][inner sep=0.75pt]    {$i$};
% Text Node
\draw (331.9,130.78) node [anchor=north west][inner sep=0.75pt]  [font=\scriptsize,rotate=-332.77]  {$p_{i}$};
% Text Node
\draw (333.36,161.54) node [anchor=north west][inner sep=0.75pt]  [font=\scriptsize,rotate=-29.2]  {$1-p_{i}$};
% Text Node
\draw (49,301.4) node [anchor=north west][inner sep=0.75pt]  [font=\scriptsize]  {$X_{t}^{a_{i}} \in \{0,1\}$};
% Text Node
\draw (353,279.4) node [anchor=north west][inner sep=0.75pt]  [font=\scriptsize]  {$p_{i} =1-e^{-\frac{\tau ^{2}}{i\sigma ^{2} +\sigma _{w}^{2}}}$};


\end{tikzpicture}
\end{document}

答案1

你真的需要所有这些包吗?你的前言太乱了。

  • 在序言中,你几乎加载了所有的包两次或更多次,更糟糕的是,其中一些包有不同的选项!彻底清理它!
  • 有些软件包,如subfigurefilecontents已经过时
  • 该软件包titlesec与 IEEEtran 文档类不兼容
  • 软件包caption与 IEEEtran 文档类不兼容
  • 不要在同一个文档中使用enumitem和打包enumerate

编辑(2): 尝试清理文档前言,考虑到上述内容,请参见以下 MWE。此时,我想知道这篇文章是否打算发表在某些 IEEE 期刊上。如果是,则需要进一步清理,您需要删除所有所需格式的重新设计,即删除包geometryfancyhdrtitlesec等...在 IEEEtran 文章的设计中,请考虑可在加拿大运输安全局

现在,它可以在(免费帐户)Overleaf 中以及在我本地安装的 MiKTeX 中使用您的图像代码进行无错误编译。但是,由于它很糟糕(由 创建时的预期结果matcha.io),我从头开始重新绘制它,目标是使其更清晰、一致且更简短。当然,图像代码及其设计的进一步改进仍然是可能的,但现在它可以作为一个很好的起点:

\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts              
\usepackage[hmargin=0.65in,vmargin={0.66in,0.99in}]{geometry}

\usepackage{textcomp}
\usepackage{float}
\usepackage[compact]{titlesec}
\titlespacing{\section}{10pt}{3pt}{3pt}
\usepackage{relsize}
\usepackage{interval}
\usepackage{booktabs, longtable, multirow, supertabular, tabularx}
\renewcommand{\arraystretch}{1.5}
    \newcolumntype{P}[1]{>{\centering\hspace{0pt}\arraybackslash}p{#1}}
    \newcolumntype{M}[1]{>{\centering\hspace{0pt}\arraybackslash}m{#1}}
    \newcolumntype{L}{>{\centering\arraybackslash}m{3cm}}
\usepackage{etoolbox}
\usepackage[ruled,vlined]{algorithm2e}
\usepackage{algorithmic}
\usepackage{cite}
\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
    T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
\usepackage[table]{xcolor}
\usepackage{enumitem}
\setlist{nolistsep,leftmargin=.6cm}
\usepackage{bbm, bm}
\usepackage{breqn}
\usepackage{amsmath, amssymb, amsthm}
\usepackage{psfrag}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                fit,
                positioning,
                quotes}

\usepackage{cuted}
\usepackage{soul} 
\usepackage{pbox}
\usepackage{filecontents}
\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhead[C]{Confidential}

\usepackage{lipsum}

\begin{document}
\lipsum[1]

\begin{figure}[ht]
    \begin{tikzpicture}[
  node distance = 4mm and 8mm,
              > = Straight Barb,
     arr/.style = {very thick, loosely dotted, shorten <=2mm, shorten >=2mm},
every edge quotes/.append style = {auto, inner sep=2pt,
                                   font=\scriptsize, sloped, pos=0.7},
       N/.style = {draw, minimum size=1.3em, semithick},
FIT/.style args = {#1/#2}{fit=#2,
                          text width=#1,anchor=west,
                          inner ysep=0pt, outer sep=0pt,
                          draw},
every label/.append style = {inner ysep=1ex, align=center}
                        ]
\node (n1) [N]                  {$X_t^{a_1}$};
\node (n2) [N,below=of n1]      {$X_t^{a_2}$};
\node (n3) [N,below=12mm of n2] {$X_t^{a_k}$};
\draw[arr]  (n2) -- (n3);
%
\node[align=center, above=of n1] {Channel input\\$C_{\text{in}}$};
\node[align=center, below=of n3] {active device set:\\
                                  $\{a_1,a_2,\dotsc,a_k$\},\\
                                  $X_t^{a_i}\in\{0,1\}$};
%
\coordinate[right=of n1.north east] (aux1);    
\coordinate[right=of n3.south east] (aux2);
\node (f1) [FIT=5em/(aux1) (aux2), 
            label={[anchor=north]north:$\displaystyle\sum_i^k X_t^{a_i}$},
            label={[anchor=south]south:Hamming\\ weight\\ computation}
            ] {};
\foreach \i in {1,2,3}
    \draw[->]  (n\i) -- (n\i -| f1.west);             
%
\coordinate[right=of f1.north east] (aux3);
\coordinate[right=of f1.south east] (aux4);
\node (f2) [FIT=2em/(aux3) (aux4),
            label={[name=f2a,anchor=north]north:0},
            label={[name=f2b,anchor=north,yshift=-1em]north:1},
            label={[name=f2c]center:$i$},
            label={[name=f2d,anchor=south]south:$k$}
            ] {};
\draw[arr]  (f2b) -- (f2c) -- (f2d);
%
\node[align=center, below=of f2] 
    {$p_i=1-\exp\left(-\frac{\tau^2}{i\sigma^2 + \sigma_{\omega}^2}\right)$};
%
\foreach \i in {a,...,d}
    \draw[->]  (f2\i -| f1.east) -- (f2\i -| f2.west);
%
\node (c1)  [circle,draw, right=12mm of f2a -| f2.east] {0};
\node (c2)  [circle,draw, right=12mm of f2d -| f2.east] {1};
%
\node[align=center, above=of c1] {Channel ouput\\$Z_t$};
\foreach \i in {a,b,d}
{
    \draw[->] (f2\i -| f2.east) -- (c1);
    \draw[->] (f2\i -| f2.east) -- (c2);
}
    \draw[->] (f2c -| f2.east) to ["$p_i$"]     (c1);
    \draw[->] (f2c -| f2.east) to ["$1-p_i$" '] (c2);

    \end{tikzpicture}
\end{center}
\lipsum[2-8]
\end{document}

在此处输入图片描述

编辑(1): 如果您喜欢用阴影矩形覆盖图像,请在图像代码末尾添加:

   \begin{tikzpicture}[
% existed image code
\draw[dashed, fill=gray!30, semitransparent]  % <--- new
    (current bounding box.south west) rectangle (current bounding box.north east);
    \end{tikzpicture}

这样得到的图像将变成如下形式:

在此处输入图片描述

不过,我猜你可能喜欢用这个矩形作为图像背景。在这种情况下,你需要添加 TiZ 库backgrounds 和图像代码末尾:

\scoped[on background layer]
\draw[dashed, fill=gray!15] 
    (current bounding box.south west) rectangle (current bounding box.north east);

现在图像将呈现以下外观:

在此处输入图片描述

还有一种可能,图像有灰色背景,但节点是白色的。在这种情况下,您需要fill=white向所有节点添加样式定义或重写图像代码,如下所示:

\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts              
\usepackage[hmargin=0.65in,vmargin={0.66in,0.99in}]{geometry}

\usepackage{textcomp}
\usepackage{amsmath, amssymb, amsthm}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                backgrounds,
                fit,
                positioning,
                quotes}

\begin{document}
\begin{center}
    \begin{tikzpicture}[
  node distance = 4mm and 8mm,
              > = Straight Barb,
     arr/.style = {very thick, loosely dotted, shorten <=2mm, shorten >=2mm},
every edge quotes/.append style = {auto, inner sep=2pt,
                                   font=\scriptsize, sloped, pos=0.7},
    base/.style = {draw, fill=white, semithick},
       C/.style = {circle, base},
       N/.style = {base, minimum size=1.3em},
FIT/.style args = {#1/#2}{fit=#2,
                          text width=#1,anchor=west,
                          inner ysep=0pt, outer sep=0pt,
                          base},
every label/.append style = {inner ysep=1ex, align=center}
                        ]
\node (n1) [N]                  {$X_t^{a_1}$};
\node (n2) [N,below=of n1]      {$X_t^{a_2}$};
\node (n3) [N,below=12mm of n2] {$X_t^{a_k}$};
\draw[arr]  (n2) -- (n3);
%
\node[align=center, above=of n1] {Channel input\\$C_{\text{in}}$};
\node[align=center, below=of n3] {active device set:\\
                                  $\{a_1,a_2,\dotsc,a_k$\},\\
                                  $X_t^{a_i}\in\{0,1\}$};
%
\coordinate[right=of n1.north east] (aux1);    
\coordinate[right=of n3.south east] (aux2);
\node (f1) [FIT=5em/(aux1) (aux2), 
            label={[anchor=north]north:$\displaystyle\sum_i^k X_t^{a_i}$},
            label={[anchor=south]south:Hamming\\ weight\\ computation}
            ] {};
\foreach \i in {1,2,3}
    \draw[->]  (n\i) -- (n\i -| f1.west);             
%
\coordinate[right=of f1.north east] (aux3);
\coordinate[right=of f1.south east] (aux4);
\node (f2) [FIT=2em/(aux3) (aux4),
            label={[name=f2a,anchor=north]north:0},
            label={[name=f2b,anchor=north,yshift=-1em]north:1},
            label={[name=f2c]center:$i$},
            label={[name=f2d,anchor=south]south:$k$}
            ] {};
\draw[arr]  (f2b) -- (f2c) -- (f2d);
%
\node[align=center, below=of f2] 
    {$p_i=1-\exp\left(-\frac{\tau^2}{i\sigma^2 + \sigma_{\omega}^2}\right)$};
%
\foreach \i in {a,...,d}
    \draw[->]  (f2\i -| f1.east) -- (f2\i -| f2.west);
%
\node (c1)  [C, right=12mm of f2a -| f2.east] {0};
\node (c2)  [C, right=12mm of f2d -| f2.east] {1};
%
\node[align=center, above=of c1] {Channel ouput\\$Z_t$};
\foreach \i in {a,b,d}
{
    \draw[->] (f2\i -| f2.east) -- (c1);
    \draw[->] (f2\i -| f2.east) -- (c2);
}
    \draw[->] (f2c -| f2.east) to ["$p_i$"]     (c1);
    \draw[->] (f2c -| f2.east) to ["$1-p_i$" '] (c2);
\scoped[on background layer]
\draw[dashed, fill=gray!15] 
    (current bounding box.south west) rectangle (current bounding box.north east);
    \end{tikzpicture}
\end{center}
\end{document}

在此处输入图片描述

相关内容