带标签的方块

带标签的方块

我是 LaTex 新手,不知道如何编写这样的代码,有人能帮我吗?非常感谢!

我是新手LaTeX,不知道如何输入这样的内容,你能帮助我吗?非常感谢。

答案1

首先要说的是:

\documentclass[border=1cm]{standalone}

\usepackage{tikz}

\begin{document}
    
    \begin{tikzpicture}
        
        %braces
        \draw [] (8.5,0) arc (-80:80:0.2cm and 0.5cm);
        \draw [rotate=180] (-0.5,-1) arc (-80:80:0.2cm and 0.5cm);

        
        %draw
        \foreach \x in {1,2.5,4,5.5}{
        \draw (\x,0) rectangle (\x+1,1);
        \node at (\x+1.25,0) {,};
        \draw (\x+1.5,0) rectangle (\x+2.5,1);
        }
    
        %nodes
        \foreach \x \y \z in {1/1/3,2.5/2.5/6,4/4/5,5.5/5.5/4}{
        \node [inner sep=0] (A) at (\x+0.5,0) {};
        \node [inner sep=0] (B) at (\x+0.5,-\y*0.2) {}; 
        \draw [->] (B) edge (A) node[below] {\tiny $\z$ choices};
            }
    
        \end{tikzpicture}
    
    \end{document}

在此处输入图片描述

答案2

使用 TikZ 矩阵:

\documentclass{article}

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

\begin{document}
\begin{tikzpicture}
\matrix[matrix of nodes, 
    nodes in empty cells,
    inner sep=0pt,
    nodes={draw, very thick, minimum size = 16pt},
    column sep=6pt,
    left delimiter={(},
    right delimiter={)}]
    (mymatr)
    {&&&&\\};
\foreach \ind in {1,...,4}
    \node[font=\bfseries] at ([xshift=2pt]mymatr-1-\ind.south east) {,};
\foreach \ind \descr in {1/3,2/6,3/5,4/4}{
        \node[below=\ind*12pt of mymatr-1-\ind] (u\ind) {\descr\ chioces};
        \draw[-Stealth] (u\ind) -- (mymatr-1-\ind);
            }
    
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容