无法绘制带有居中字母的框

无法绘制带有居中字母的框

基本上我想在乳胶中执行以下操作:(颜色不重要)

在此处输入图片描述

但我做起来很困难,因为我对盒子毫无经验。我知道数组,但我真的不知道如何执行这个。谢谢。

答案1

这是使用 tikz 矩阵的版本:

在此处输入图片描述

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\newlength{\myboxlength}
\begin{document}

\setlength{\myboxlength}{1cm}
\begin{tikzpicture}
 \matrix(table)[
  matrix of nodes,
  row sep = 0.2\myboxlength,
  column sep = 0.2\myboxlength,
  nodes={ fill=none, draw=black},
  column 1/.style={minimum width=5\myboxlength},
  column 2/.style={minimum width=1\myboxlength},
  row 1/.style={minimum height=3\myboxlength},
  row 2/.style={minimum height=1\myboxlength},
  ] 
  {A & B  \\
   C & 0  \\
  };
\end{tikzpicture}
\bigskip

\setlength{\myboxlength}{5mm}
\begin{tikzpicture}
 \matrix(table)[
  matrix of nodes,
  row sep = 0.2\myboxlength,
  column sep = 0.2\myboxlength,
  nodes={ fill=none, draw=black},
  column 1/.style={minimum width=5\myboxlength},
  column 2/.style={minimum width=1\myboxlength},
  row 1/.style={minimum height=3\myboxlength},
  row 2/.style={minimum height=1\myboxlength},
  ] 
  {A & B  \\
   C & 0  \\
  };
\end{tikzpicture}
\end{document}

答案2

\def\mybox#1#2#3{\vrule height#2\vbox to#2{\dimen0=#1\advance\dimen0by-.8pt
 \hrule width\dimen0\vfil\hbox to\dimen0{\strut\hfil#3\hfil}\vfil\hrule width\dimen0}\vrule height#2\relax}
\def\mykern{\kern1pt}
\vbox{\hbox{\mybox{5pc}{3pc}{A}\mykern\mybox{1pc}{3pc}{b}}
      \mykern
      \hbox{\mybox{5pc}{1pc}{c}\mykern\mybox{1pc}{1pc}{0}}}

在此处输入图片描述

相关内容