数电1对应latex代码

一、进制

3.BCD码

javascript 复制代码
\documentclass{article}
\usepackage{ctex}  
\usepackage{geometry} % 设置页边距
\geometry{a4paper, margin=1cm}

\usepackage{xcolor}      % 颜色支持
\usepackage{booktabs}    % 高质量表格横线 (toprule, midrule, bottomrule)
\usepackage{makecell}    % 表头单元格内换行

\begin{document}

\begin{table}[htbp]
    \centering
    \caption{几种常见的BCD代码}
    \label{tab:bcd_codes}
    \begin{tabular}{c|ccccc}
        \toprule
        \textbf{十进制数} & \multicolumn{5}{c}{\textbf{几种常见的BCD代码}} \\
        \midrule
         & \textbf{8421码} & \textbf{余3码} & \textbf{2421(A)码} & \textbf{5211码} & \textbf{余3循环码} \\
        \midrule
        0 & 0000 & 0011 & 0000 & 0000 & 0010 \\
        1 & 0001 & 0100 & 0001 & 0001 & 0110 \\
        2 & 0010 & 0101 & 0010 & 0100 & 0111 \\
        3 & 0011 & 0110 & 0011 & 0101 & 0101 \\
        4 & 0100 & 0111 & 0100 & 0111 & 0100 \\
        5 & 0101 & 1000 & 1011 & 1000 & 1100 \\
        6 & 0110 & 1001 & 1100 & 1001 & 1101 \\
        7 & 0111 & 1010 & 1101 & 1100 & 1111 \\
        8 & 1000 & 1011 & 1110 & 1101 & 1110 \\
        9 & 1001 & 1100 & 1111 & 1111 & 1010 \\
        \midrule
        \textbf{权} & \textbf{8421} &  & \textbf{2421} & \textbf{5211} &  \\
        \bottomrule
    \end{tabular}
\end{table}

\end{document}

二、逻辑关系及运算

javascript 复制代码
\documentclass{standalone}
\usepackage{ctex}           % 支持中文
\usepackage{tikz}
\usetikzlibrary{circuits.logic.US, positioning}

\begin{document}
\begin{tikzpicture}[
    circuit logic US,
    scale=1.5,  % 增大缩放比例
    every node/.style={font=\small},
    gate/.style={draw, minimum size=9mm}
]

% ========== 顶部中文标题 ==========
\node[above] at (2, 4) {\large 基本逻辑门:与、或、非};

% ========== 1. 与门(AND)- 第一行 ==========
\node[and gate, inputs={nn}] (and) at (2, 3) {};
\draw (and.input 1) -- ++(-0.5, 0) node[left] {A};
\draw (and.input 2) -- ++(-0.5, 0) node[left] {B};
\draw (and.output) -- ++(0.5, 0) node[right] {Y};
\node[above=0.2cm of and, red] {$\mathbf{Y = A \cdot B}$};
\node[below=0.2cm of and] {\textbf{与门(AND Gate)}};

% ========== 2. 或门(OR)- 第二行 ==========
\node[or gate, inputs={nn}] (or) at (2, 1) {};
\draw (or.input 1) -- ++(-0.5, 0) node[left] {A};
\draw (or.input 2) -- ++(-0.5, 0) node[left] {B};
\draw (or.output) -- ++(0.5, 0) node[right] {Y};
\node[above=0.2cm of or, blue] {$\mathbf{Y = A + B}$};
\node[below=0.2cm of or] {\textbf{或门(OR Gate)}};

% ========== 3. 非门(NOT)- 第三行 ==========
\node[not gate] (not) at (2, -1) {};
\draw (not.input) -- ++(-0.5, 0) node[left] {A};
\draw (not.output) -- ++(0.5, 0) node[right] {Y};
\node[above=0.2cm of not, violet] {$\mathbf{Y = \overline{A}}$};
\node[below=0.2cm of not] {\textbf{非门(NOT Gate)}};

% 增加行之间的分隔线(可选)
\draw[gray, thin] (0, 2) -- (4, 2);
\draw[gray, thin] (0, 0) -- (4, 0);

\end{tikzpicture}
\end{document}

与非

javascript 复制代码
\documentclass[border=20pt]{standalone}
\usepackage[UTF8]{ctex}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usepackage{amsmath}

\begin{document}
\begin{tikzpicture}[
    line width=1.5pt,
    arrow/.style={-{Stealth[length=4mm]}, line width=1.2pt}
]

% 标题
\node[font=\huge\bfseries, blue!80!black] at (0, 5) {与非门 (NAND Gate)};

% 与非门符号
\draw[blue!80!black, fill=yellow!10, line width=2pt, rounded corners=5pt] 
    (-1, 0) rectangle (1, 1.5);
\node[blue!80!black, scale=2] at (0, 0.75) {$\&$};
\draw[blue!80!black, fill=white, line width=2pt] (1, 0.75) circle (0.1);

% 输入输出
\draw[blue!80!black, line width=2pt] (-2, 0.3) -- (-1, 0.3) node[midway, above] {A};
\draw[blue!80!black, line width=2pt] (-2, 1.2) -- (-1, 1.2) node[midway, above] {B};
\draw[blue!80!black, line width=2pt] (1.1, 0.75) -- (2.5, 0.75) node[midway, above] {$Y_1$};
\draw[blue!80!black, arrow] (-2, 0.3) -- (-1, 0.3);
\draw[blue!80!black, arrow] (-2, 1.2) -- (-1, 1.2);
\draw[blue!80!black, arrow] (1.1, 0.75) -- (2.5, 0.75);

% 公式
\node[red!80!black, font=\Large] at (0, -1) 
    {$Y_1 = \overline{A \cdot B}$};

\end{tikzpicture}
\end{document}

或非

javascript 复制代码
\documentclass[border=20pt]{standalone}
\usepackage[UTF8]{ctex}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usepackage{amsmath}

\begin{document}
\begin{tikzpicture}[
    line width=1.5pt,
    arrow/.style={-{Stealth[length=4mm]}, line width=1.2pt}
]

% 标题
\node[font=\huge\bfseries, blue!80!black] at (0, 5) {或非门 (NOR Gate)};

% 或非门符号
\draw[blue!80!black, fill=green!10, line width=2pt, rounded corners=5pt] 
    (-1, 0) rectangle (1, 1.5);
\node[blue!80!black, scale=2] at (0, 0.75) {$\geq 1$};
\draw[blue!80!black, fill=white, line width=2pt] (1, 0.75) circle (0.1);

% 输入输出
\draw[blue!80!black, line width=2pt] (-2, 0.3) -- (-1, 0.3) node[midway, above] {A};
\draw[blue!80!black, line width=2pt] (-2, 1.2) -- (-1, 1.2) node[midway, above] {B};
\draw[blue!80!black, line width=2pt] (1.1, 0.75) -- (2.5, 0.75) node[midway, above] {$Y_2$};
\draw[blue!80!black, arrow] (-2, 0.3) -- (-1, 0.3);
\draw[blue!80!black, arrow] (-2, 1.2) -- (-1, 1.2);
\draw[blue!80!black, arrow] (1.1, 0.75) -- (2.5, 0.75);

% 公式
\node[red!80!black, font=\Large] at (0, -1) 
    {$Y_2 = \overline{A + B}$};

\end{tikzpicture}
\end{document}

与或非

javascript 复制代码
\documentclass[border=20pt]{standalone}
\usepackage[UTF8]{ctex}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usepackage{amsmath}

\begin{document}
\begin{tikzpicture}[
    line width=1.5pt,
    arrow/.style={-{Stealth[length=4mm]}, line width=1.2pt}
]

% 标题
\node[font=\huge\bfseries, blue!80!black] at (0, 5) {复合门 (Compound Gate)};

% 复合门符号
\draw[blue!80!black, fill=blue!10, line width=2pt, rounded corners=5pt] 
    (-1, 0.2) rectangle (1, 1.5);
\node[blue!80!black, scale=1.8] at (0, 0.85) {$\&$};
\draw[blue!80!black, fill=green!10, line width=2pt, rounded corners=5pt] 
    (-1, -1.3) rectangle (1, 0.2);
\node[blue!80!black, scale=1.8] at (0, -0.55) {$\geq 1$};
\draw[blue!80!black, fill=white, line width=2pt] (1, -0.55) circle (0.1);

% 输入输出
\draw[blue!80!black, line width=2pt] (-2.5, 0.6) -- (-1, 0.6) node[midway, above] {A};
\draw[blue!80!black, line width=2pt] (-2.5, 1.1) -- (-1, 1.1) node[midway, above] {B};
\draw[blue!80!black, line width=2pt] (-2.5, -0.9) -- (-1, -0.9) node[midway, above] {C};
\draw[blue!80!black, line width=2pt] (-2.5, -0.2) -- (-1, -0.2) node[midway, above] {D};
\draw[blue!80!black, line width=2pt] (1.1, -0.55) -- (3, -0.55) node[midway, above] {$Y_3$};
\draw[blue!80!black, arrow] (-2.5, 0.6) -- (-1, 0.6);
\draw[blue!80!black, arrow] (-2.5, 1.1) -- (-1, 1.1);
\draw[blue!80!black, arrow] (-2.5, -0.9) -- (-1, -0.9);
\draw[blue!80!black, arrow] (-2.5, -0.2) -- (-1, -0.2);
\draw[blue!80!black, arrow] (1.1, -0.55) -- (3, -0.55);

% 公式
\node[red!80!black, font=\Large] at (0, -2) 
    {$Y_3 = \overline{(A \cdot B) + (C \cdot D)}$};

\end{tikzpicture}
\end{document}
相关推荐
搞科研的小刘选手5 分钟前
【香港大学主办&IEEE出版】第六届计算机视觉、应用与算法国际学术会议(CVAA 2026)
算法·计算机视觉·应用·学术会议
Java小白笔记13 分钟前
Codex config.toml配置实战指南
人工智能·算法·chatgpt·ai编程·集成学习
王老师青少年编程19 分钟前
2026年6月GESP真题及题解(C++七级):消消乐
数据结构·c++·算法·真题·gesp·2026年6月
z小猫不吃鱼31 分钟前
模型剪枝经典论文精读:Pruning Filters for Efficient ConvNets
算法·机器学习·剪枝
Fox爱分享2 小时前
字节二面:1000瓶酒,有一瓶是毒药,多少只老鼠可以查出来?
算法·面试·程序员
+wacyltd大模型备案算法备案2 小时前
大模型评估测试题库怎么建?风险分类、测试样本的完整方法
人工智能·算法·安全·分类·大模型·大模型备案·大模型上线登记
Fox爱分享3 小时前
字节二面智力题:100只老虎和1只羊关在一起,这只羊会不会被吃?
算法·面试·程序员
xin(n_n)b3 小时前
经典题目(3):把数字翻译成字符串;兑换零钱
算法
惊鸿一博3 小时前
特征匹配+Glue Factory 框架评估特征提取与匹配算法时常用的度量标准
算法·特征匹配
柒和远方3 小时前
LeetCode 4. 寻找两个正序数组的中位数 —— 二分划分的艺术
javascript·python·算法