用小写字母/符号注释旋转表单元格的最右上角

用小写字母/符号注释旋转表单元格的最右上角

(第二篇帖子) 上一个答案对我拥有的表格来说很好用,除了我需要旋转的大表格(如下面的代码所示)。我尝试了所提解决方案的前两个参数(“wide-2”中的“2”和“\hspace{.3\tabcolsep”中的“.3”),但未能找到这些参数的正确设置。下面给出了带有旋转矩阵的代码。

\documentclass{book}

\usepackage{graphicx}
\usepackage{eqparbox}
\usepackage{amsmath}
\usepackage{amssymb}

\begin{document}

\newcommand{\PTSConstraint}[1]{\constraint{$g$\_$f$\_{#1}}}
\newcommand{\Pre}[1]{\ensuremath\overrightarrow{#1}}
\newcommand{\Suf}[1]{\ensuremath\overleftarrow{#1}}
\newcommand{\Neither}{\AGG{\Pre{C},\Suf{C}}}
\newcommand{\Creates}{\Fea(\Pre{D},\Suf{D},\Con)}
\newcommand{\ExtendLeft}{\Fea(\Pre{C},\Pre{D},\Suf{D},\Con)}
\newcommand{\ExtendRight}{\Fea(\Suf{C},\Pre{D},\Suf{D},\Con)}
\newcommand{\Extendboth}{\Fea(\Pre{C},\Suf{C},\Pre{D},\Suf{D},\Con)}
\newcommand{\ExtendbothHat}{\Fea(\Pre{C},\Suf{C},\Pre{D},\Suf{D},\ConHat)}
\newcommand{\Agg}{g}
\newcommand{\AGG}[1]{\phi_\Agg(#1)}
\newcommand{\Fea}{\ensuremath{\phi_f}} 
\newcommand{\Con}{\delta_f^{i+1}}
\newcommand{\ConHat}{\hat{\delta}_f^{i+1}}

\newcommand{\AnnotatedCreatesChar}{$\diamond$}
\newcommand{\AnnotatedExtendLeftChar}{$\blacktriangleright$}
\newcommand{\AnnotatedExtendRightChar}{$\blacktriangleleft$}
\newcommand{\AnnotatedExtendbothChar}{$\square$}
\newcommand{\AnnotatedExtendbothHatChar}{$\blacksquare$}

\newcommand{\AnnotatedCreates}{\eqmakebox[wide-2]{$\Creates$}\rlap{\hspace{.3\tabcolsep}\raisebox{.6\normalbaselineskip}[0pt][0pt]{\scriptsize \AnnotatedCreatesChar}}}
\newcommand{\AnnotatedExtendLeft}{\eqmakebox[wide-2]{$\ExtendLeft$}\rlap{\hspace{.3\tabcolsep}\raisebox{.6\normalbaselineskip}[0pt][0pt]{\scriptsize \AnnotatedExtendLeftChar}}}
\newcommand{\AnnotatedExtendRight}{\eqmakebox[wide-2]{$\ExtendRight$}\rlap{\hspace{.3\tabcolsep}\raisebox{.6\normalbaselineskip}[0pt][0pt]{\scriptsize \AnnotatedExtendRightChar}}}
\newcommand{\AnnotatedExtendboth}{\eqmakebox[wide-2]{$\Extendboth$}\rlap{\hspace{.3\tabcolsep}\raisebox{.6\normalbaselineskip}[0pt][0pt]{\scriptsize \AnnotatedExtendbothChar}}}
\newcommand{\AnnotatedExtendbothHat}{\eqmakebox[wide-2]{$\ExtendbothHat$}\rlap{\hspace{.3\tabcolsep}\raisebox{.6\normalbaselineskip}[0pt][0pt]{\scriptsize \AnnotatedExtendbothHatChar}}}

\begin{table}[h]
  \setlength{\tabcolsep}{3pt}
  \centering
  \renewcommand{\arraystretch}{1.6}
\scalebox{0.85}{\rotatebox{90}{
\begin{tabular}{c|c|c|c|c|c|c|c|}
\multicolumn{1}{c}{} & \multicolumn{1}{c}{$s$} & \multicolumn{1}{c}{$a$} & \multicolumn{1}{c}{$b$} & \multicolumn{1}{c}{$c$} & \multicolumn{1}{c}{$d$} & \multicolumn{1}{c}{$e$} & \multicolumn{1}{c}{$f$} \\
 \cline{2-8}
{$s$} & $\Neither$ & $\Neither$ & $\Neither$ & $\Neither$ & $\Neither$ & $\Neither$ & $\Neither$ \\
 \cline{2-8}
{$a$} & $\Neither$ & $\Neither$ & $\Neither$ & \AnnotatedExtendRight & $\Neither$ & \AnnotatedCreates & $\Neither$ \\
\cline{2-8}
{$b$} & $\Neither$ & $\Neither$ & \AnnotatedCreates & $\Neither$ & \AnnotatedCreates & $\Neither$ & \AnnotatedExtendRight \\
\cline{2-8}
{$c$} & $\Neither$ & \AnnotatedExtendLeft & $\Neither$ & \AnnotatedExtendboth & $\Neither$ & \AnnotatedExtendLeft & $\Neither$ \\
\cline{2-8}
{$d$} & $\Neither$ & $\Neither$ & \AnnotatedCreates & $\Neither$ & $\Neither$ & $\Neither$ & \AnnotatedExtendRight \\
\cline{2-8}
{$e$} & $\Neither$ & \AnnotatedCreates & $\Neither$ & \AnnotatedExtendRight & $\Neither$ & \AnnotatedCreates & $\Neither$ \\
\cline{2-8}
{$f$} & $\Neither$ & $\Neither$ & \AnnotatedExtendLeft & $\Neither$ & \AnnotatedExtendLeft & $\Neither$ & \AnnotatedExtendboth \\
\cline{2-8}
\end{tabular}
}}
\caption{Parametrised glue matrix for any zigzag constraint}
\end{table}

\end{document}

(初始帖子)给定下表,我想注释一些单元格而不改变单元格大小;注释应位于某些单元格的右上角,并且应由一个小大写字母(或一个小符号)组成。

如果我开始以标准方式书写符号,我会遇到两个问题:(1)单元格大小发生变化,(2)符号不在最右上角。

\documentclass{book}

\newcommand{\Pre}[1]{\ensuremath\overrightarrow{#1}}
\newcommand{\Suf}[1]{\ensuremath\overleftarrow{#1}}
\newcommand{\Neither}{\AGG{\Pre{C},\Suf{C}}}
\newcommand{\Creates}{\Fea(\Pre{D},\Suf{D},\Con)}
\newcommand{\Agg}{g}
\newcommand{\AGG}[1]{\phi_\Agg(#1)}
\newcommand{\Fea}{\ensuremath{\phi_f}} 
\newcommand{\Con}{\delta_f^{i+1}}

\begin{document}

\begin{table}[h]
  \setlength{\tabcolsep}{10pt}
  \centering
  \renewcommand{\arraystretch}{1.6}
\begin{tabular}{c|c|c|c|}
\multicolumn{1}{c}{} & \multicolumn{1}{c}{$s$} & \multicolumn{1}{c}{$r$} & \multicolumn{1}{c}{$t$} \\
\cline{2-4}
{$s$} & $\Neither$ & $\Neither$ & $\Neither$ \\
\cline{2-4}
{$r$} & $\Neither$ & $\Neither$ &  $\Creates$ \\
\cline{2-4}
{$t$} & $\Neither$ & $\Creates$ & $\Creates$ \\
\cline{2-4}
\end{tabular}
\caption{Parametrised glue matrix}
\end{table}

\end{document}

答案1

这里有这样一个想法:我们将最宽元素的内容存储在一个框中,然后将要上标的单元格存储在一个相同宽度的框中。这不会影响表格/列的宽度。然后,可以将上标放在零宽度框中并将其移动到位。

在此处输入图片描述

\documentclass{article}

\usepackage{eqparbox}

\newcommand{\Pre}[1]{\overrightarrow{#1}}
\newcommand{\Suf}[1]{\overleftarrow{#1}}
\newcommand{\Neither}{\AGG{\Pre{C}, \Suf{C}}}
\newcommand{\Creates}{\Fea(\Pre{D}, \Suf{D}, \Con)}
\newcommand{\Agg}{g}
\newcommand{\AGG}[1]{\phi_\Agg(#1)}
\newcommand{\Fea}{\phi_f}
\newcommand{\Con}{\delta_f^{i + 1}}

\begin{document}

\begin{table}
  \setlength{\tabcolsep}{10pt}
  \centering
  \renewcommand{\arraystretch}{1.6}
  \begin{tabular}{ c | c | c | c | }
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{$s$} & \multicolumn{1}{c}{$r$} & \multicolumn{1}{c}{$t$} \\
    \cline{2-4}
    $s$ & $\Neither$ & \eqmakebox[wide-2]{$\Neither$}\rlap{\textsuperscript{2}} & $\Neither$ \\
    \cline{2-4}
    $r$ & $\Neither$ & $\Neither$ & $\Creates$ \\
    \cline{2-4}
    $t$ & $\Neither$ & \eqmakebox[wide-2]{$\Creates$} & $\Creates$ \\
    \cline{2-4}
  \end{tabular}
  \caption{Parametrised glue matrix}
\end{table}

\end{document}

\textsuperscript{2}当然,可以进行更多的移动以完美定位它,例如

在此处输入图片描述

% ...
\eqmakebox[wide-2]{$\Neither$}%
  \rlap{\hspace{.5\tabcolsep}\raisebox{.6\normalbaselineskip}[0pt][0pt]{\scriptsize 2}}
% ...

答案2

这是一个满足单元格大小不变要求的解决方案。但是,您可能需要手动调整yshift距离。right of

编辑:如果你不想使用 TiZ 和/或不喜欢手动调整,您可以使用\newcommand{\MarkCell}[2]{\hfill#1\hspace*{3pt}\makebox[-3pt][l]{${}^{#2}$}}

\documentclass{book}

\newcommand{\Pre}[1]{\ensuremath\overrightarrow{#1}}
\newcommand{\Suf}[1]{\ensuremath\overleftarrow{#1}}
\newcommand{\Neither}{\AGG{\Pre{C},\Suf{C}}}
\newcommand{\Creates}{\Fea(\Pre{D},\Suf{D},\Con)}
\newcommand{\Agg}{g}
\newcommand{\AGG}[1]{\phi_\Agg(#1)}
\newcommand{\Fea}{\ensuremath{\phi_f}} 
\newcommand{\Con}{\delta_f^{i+1}}
\usepackage{tikz}
\usetikzlibrary{positioning}
% from https://tex.stackexchange.com/questions/339526/confusion-over-use-of-tikzmark
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
\newcommand{\MarkCell}[2]{\hfill#1\hspace*{3pt}\makebox[-3pt][l]{${}^{#2}$}}
\begin{document}

\begin{table}[h]
  \setlength{\tabcolsep}{10pt}
  \centering
  \renewcommand{\arraystretch}{1.6}
\begin{tabular}{c|c|c|c|}
\multicolumn{1}{c}{} & \multicolumn{1}{c}{$s$} & \multicolumn{1}{c}{$r$} & \multicolumn{1}{c}{$t$} \\
\cline{2-4}
{$s$} & $\Neither$ & $\Neither$\tikzmark{pfft} & $\Neither$ \\
\cline{2-4}
{$r$} & $\Neither$ & \hfill$\Neither$\hfill \hspace*{3pt}\makebox[-3pt][l]{${}^3$} &  $\Creates$ \\
\cline{2-4}
{$t$} & \MarkCell{$\Neither$}{4} & $\Creates$ & \MarkCell{$\Creates$}{5} \\
\cline{2-4}
\end{tabular}
\caption{Parametrised glue matrix}
\end{table}
\tikz[overlay,remember picture]{\node[anchor=south,right=3mm of pfft,yshift=3mm]{${\scriptstyle 2}$};} 
\end{document}

在此处输入图片描述

相关内容