环境配置
- 下载 MikTex 环境(安装 TexLive 时一直报错
error writing "file4c3c5c8": broken pipe
),并将\bin
加入到path
路径。 - 下载 VS code,安装扩展项
Latex Workshop
。 - 打开
设置
找到Auto Save Delay
,开启自动保存并编译。 - 现在编辑
.tex
文件,可以实时编译查看了!
绘图代码
使用 tikz
包,来绘制各种复杂图形。详细信息可以查看 文档。
绘制密码学归约证明的交互过程:
\documentclass[11pt]{ctexart}
\usepackage[top=2cm, bottom=2cm, left=2cm, right=2cm]{geometry}
\usepackage{algorithm}
\usepackage{algorithmicx}
\usepackage{algpseudocode}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{graphs, positioning, quotes, shapes.geometric}
\usetikzlibrary{arrows.meta}%画箭头用的包
\usepackage{pgffor}%可以使用foreach的包
\usepackage{ifthen}%可以使用ifthenelse的包,还能使用whiledo
\usetikzlibrary{fpu}%修理不能使用ifthenelse的错误
\usetikzlibrary{math}%使用数学程序
\usetikzlibrary {arrows.meta,automata,positioning,shadows}
\usetikzlibrary{chains,scopes,positioning,backgrounds,shapes,fit,shadows,calc,arrows.meta}
\RequirePackage{amsmath,mathrsfs,amsfonts,amssymb}
\begin{document}
\title{这是标题}
\maketitle
\tableofcontents %目录
\newpage
\section{画图}
\noindent
资料:
\begin{enumerate}
\item https://www.cnblogs.com/qizhou/p/13040159.html
\item https://www.zhihu.com/question/479931043
\item https://github.com/Hansimov/pgfmanual-zh
\item https://blog.csdn.net/m0\_50984266/article/details/112254334
\end{enumerate}
\subsection{第一种绘图方式}
\begin{center}
\begin{tikzpicture}[auto,
arrow1/.style = {
draw = black, thick, -{Latex[length = 2mm, width = 1.5mm]},
}]
\draw[line width=1.5pt] (0,0)--(16,0);
\draw[-] (3,1)--(3,-8);
\draw[-] (5,1)--(5,-8);
\draw[-] (11,1)--(11,-8);
\draw[-] (13,1)--(13,-8);
\node [minimum width=3cm,minimum height=1.5cm] (Ch) at(1,0.5){$Ch$};
\node [minimum width=3cm,minimum height=1.5cm] (B) at(8,0.5){$B$};
\node [minimum width=3cm,minimum height=1.5cm] (A) at(14,0.5){$A$};
\node [minimum width=3cm,minimum height=1.5cm] (Ch1) at(1,-1){
$$\begin{math}\begin{aligned}
x \leftarrow_R U_n\\
y = f(x)
\end{aligned}\end{math}$$
};
\draw[arrow1] (3.2,-2) -- node{$y$} (4.8,-2);
\node [minimum width=3cm,minimum height=1.5cm] (B1) at(8,-3){
$$\begin{math}\begin{aligned}
i \leftarrow_R \{1,\cdots,m\}\\
x_j \leftarrow_R U_n, \forall j \neq i\\
Y = (f(x_1),\cdots,y,\cdots,f(x_m))
\end{aligned}\end{math}$$
};
\draw[arrow1] (11.2,-4.5) -- node{$Y$} (12.8,-4.5);
\node [minimum width=3cm,minimum height=1.5cm] (A1) at(15,-5){$X \leftarrow A(1^{l(n)m},Y)$};
\draw[arrow1] (12.8,-5.5) -- node{$X$} (11.2,-5.5);
\node [minimum width=3cm,minimum height=1.5cm] (B2) at(8,-6){$x' = X_i$};
\draw[arrow1] (4.8,-6.5) -- node{$x'$} (3.2,-6.5);
\node [minimum width=3cm,minimum height=1.5cm] (Ch2) at(1,-7){
$f(x') \overset{?}{=} y$
};
\end{tikzpicture}
\end{center}
\subsection{第二种绘图方式}
\begin{center}
\begin{tikzpicture}[auto,
box/.style = {draw, minimum height=3.5cm, minimum width=3cm, align=left, outer sep=0pt},
lbl/.style = {anchor=north west, outer sep=0mm},
arrow1/.style = {
draw = black, thick, -{Latex[length = 2mm, width = 1.5mm]},
}
]
\node (n1) [box,
label={[lbl] north west:Challenger ~~ $\mathcal{C}$},]
{
$\begin{aligned}\\
(pk,sk) \overset{R}{\leftarrow} G() \\
x \overset{R}{\leftarrow} X \\
y \gets F(pk,x) \\
t=\left\{
\begin{aligned}
1, \quad F(pk,I(sk,\widehat{y}))=\widehat{y}\\
0, \quad F(pk,I(sk,\widehat{y}))\neq \widehat{y}
\end{aligned}
\right.
\end{aligned}$
};
\node (n3) [box,
label={[lbl]north west:Adversary~~ $\mathcal{A}$},
right=25mm of n1 -| n1.east,]
{ $ \widehat{y} \in Y $ };
\node (n4) [below=5mm of n3]{$ \widehat{x} $};
\path[arrow1] ([yshift=5ex] n1.east) -- node{$pk,y$} ([yshift=5ex] n3.west);
\path[arrow1] ([yshift=-2ex] n3.west) -- node[above]{$\widehat{y}$} ([yshift=-2ex] n1.east);
\path[arrow1] ([yshift=-6ex] n1.east) -- node{$t$} ([yshift=-6ex] n3.west);
\path[arrow1] (n3) -- (n4);
\end{tikzpicture}
\end{center}
\end{document}