带表格的下标

带表格的下标

我有一个以卡片为条目的魔方,我正在尝试考虑所有 3 阶魔方(共有 8 个)。我的目标是用下标 M_1、...、M_8 表示每个方块。现在我有一些可以产生所需外观的代码,但我很确定这是一种非常无效的方式来实现我想要实现的目标(下标 M_i 的位置):

\begin{center}
\bgroup
\def\arraystretch{1.5}
\begin{tabular}{|c|c|c|}
\hline
\fourh & \nineh & \twoh\\
\hline
\treh & \fiveh & \sevh\\
\hline
\eigh & \Ah & \sixh\\
\hline
\end{tabular}
\kern-1em\,
\begin{tabular}{c}
{}\\
{}\\
{}\\
$M_1$\\
\end{tabular}
\egroup
\end{center}

编译后,生成以下图像:

在此处输入图片描述

这很棒,但正如我上面的代码所揭示的,这可能不是将下标 M 放在我想要的位置的最佳方法。有没有更好的方法?

答案1

您可以添加第四列

\documentclass{article}
\usepackage{array,graphicx}
\newcommand{\mypicture}{\includegraphics[width=1cm]{example-image}}
\begin{document}
  \begin{center}
\def\arraystretch{1.5}
\begin{tabular}{|c|c|c|l}
\cline{1-3}
\mypicture & \mypicture & \mypicture \\
\cline{1-3}
\mypicture & \mypicture & \mypicture \\
\cline{1-3}
\mypicture & \mypicture & \mypicture &\multicolumn{1}{@{}l@{}}{\smash{\raisebox{-2ex}{$M_1$}}}\\
\cline{1-3}
\end{tabular}
\end{center}
\end{document}

在此处输入图片描述

现在是时候解决过度杀伤问题了:

\documentclass{article}
\usepackage{array}
\usepackage{tikz}
\newcommand{\mypicture}{\includegraphics[width=1cm]{example-image}}
\begin{document}
\begin{tikzpicture}
\def\arraystretch{1.5}
\node[inner sep=0pt] (a) {\begin{tabular}{|c|c|c|}
\hline
\mypicture & \mypicture & \mypicture \\
\hline
\mypicture & \mypicture & \mypicture \\
\hline
\mypicture & \mypicture & \mypicture \\
\cline{1-3}
\end{tabular}
};
\node[anchor=west,inner xsep=1pt] at (a.south east) {$M_1$};
\end{tikzpicture}
\end{document}

\documentclass{article}
\usepackage{array}
\usepackage{tikz}
\usetikzlibrary{matrix}
\newcommand{\mypicture}{\includegraphics[width=1cm]{example-image}}
\begin{document}
\begin{tikzpicture}
\matrix [matrix of nodes,nodes={anchor=center}](m)
    {
     \mypicture & \mypicture & \mypicture \\
     \mypicture & \mypicture & \mypicture \\
     \mypicture & \mypicture & \mypicture \\
      };
\node[anchor=west,inner sep=0pt] at (m-3-3.south east) {$M_1$};
\foreach \x[count=\y] in {1,2,3}{
\draw (m-3-1.south west) |- (m-1-3.north east);
\draw (m-\x-1.south west) -- (m-\x-3.south east);
\draw (m-1-\y.north east) -- (m-3-\y.south east);
}
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

我没有你的卡片定义,因此当然要删除我对它们的定义。[b]在这种情况下,选项可能就是所需的一切。(并且可以通过 轻松获得额外的 $M_1$ 垂直移动\raisebox{dist}{text})。

\documentclass{article}


\begin{document}

\def\fourh{fourh}
\def\nineh{nineh}
\def\twoh{twoh}
\def\treh{treh}
\def\fiveh{fiveh}
\def\sevh{sevh}
\def\eigh{eigh}
\def\Ah{Ah}
\def\sixh{sixh}

\begin{center}
%\bgroup
\def\arraystretch{1.5}
\begin{tabular}[b]{|c|c|c|}
\hline
\fourh & \nineh & \twoh\\
\hline
\treh & \fiveh & \sevh\\
\hline
\eigh & \Ah & \sixh\\
\hline
\end{tabular}
$\mkern4mu M_1$
%\kern-1em\,
%\begin{tabular}{c}
%{}\\
%{}\\
%{}\\
%$M_1$\\
%\end{tabular}
%\egroup
\end{center}
\end{document}

在此处输入图片描述

相关内容