答案1
您可以使用包\boxed
中的命令amsmath
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
X=\boxed{X_1 X_2}\quad \boxed{X_3 X_4}\cdots\boxed{X_5 X_6}
\end{equation*}
\end{document}
在框下方添加颜色和标签
\documentclass{article}
\usepackage{amsmath,tcolorbox}
\tcbuselibrary{theorems,skins}
\usetikzlibrary{arrows.meta}
\newlength\mylabelshift
\setlength\mylabelshift{3mm} % to be adjusted if needed
\newcommand{\drawlabel}[1]{\draw[Stealth-Stealth]([yshift=-\mylabelshift]frame.south west)--node[fill=white]{\(#1\)}([yshift=-\mylabelshift]frame.south east);}
\newtcbox{\mymathbox}[1][l]{
enhanced,
nobeforeafter,
math upper,
tcbox raise base,
colback=blue!30, % to set background color
size=small,
geometry nodes,
overlay={\drawlabel{#1}},
tcbox width=minimum center,
width= 2 cm ,% to be adjusted if needed
}
\begin{document}
\begin{equation*}
X=\mymathbox{X_1 X_2}\quad \mymathbox{X_3 X_4 X_5}\cdots\mymathbox{X_5 X_6}
\end{equation*}
\vspace{1cm}
\begin{equation*}
X=\mymathbox[a]{X_1 X_2}\quad \mymathbox[b]{X_3 X_4}\cdots\mymathbox[c]{X_5 X_6}
\end{equation*}
\end{document}
答案2
取决于你想去哪里。原则上你不需要任何包裹。
\documentclass{article}
\begin{document}
\[
X=
\raisebox{-1.5ex}{$\begin{array}{c}
\hline
\multicolumn{1}{|c|}{X_1 X_2}\\
\hline
\leftarrow\ell\rightarrow\\
\end{array}$}~
\raisebox{-1.5ex}{$\begin{array}{c}
\hline
\multicolumn{1}{|c|}{X_3 X_4}\\
\hline
\leftarrow\ell\rightarrow\\
\end{array}$}\cdots
\raisebox{-1.5ex}{$\begin{array}{c}
\hline
\multicolumn{1}{|c|}{X_5 X_6}\\
\hline
\leftarrow\ell\rightarrow\\
\end{array}$}
\]
\end{document}
答案3
这是一个无包版本(amsmath
如果做数学题的话总是需要的)。
\documentclass{article}
\usepackage{amsmath}
\newcommand{\block}[2]{%
\begin{array}[t]{@{}c@{}}
\boxed{\mathstrut #1}\\
\scriptstyle\blockleftarrowfill\,#2\,\blockrightarrowfill
\end{array}%
}
\newcommand{\blockleftarrowfill}{%
\mathord\leftarrow
\mkern -7mu
\cleaders\hbox{$\scriptstyle\mkern -2mu\smash-\mkern -2mu$}\hfill
\mkern -7mu\smash-%
}
\newcommand{\blockrightarrowfill}{%
\smash-%
\mkern -7mu
\cleaders\hbox{$\scriptstyle\mkern -2mu\smash-\mkern -2mu$}\hfill
\mkern -7mu
\mathord\rightarrow
}
\begin{document}
\[
X= \block{x_1\ x_2\quad}{l}\quad
\block{x_3\ x_4\quad}{l}\quad
\cdots\quad
\block{x_5\ x_6\quad}{l}
\]
\end{document}