表格环境中的旋转框间距

表格环境中的旋转框间距

有人能解释一下这个表中的间距吗?

  • 为什么有些旋转的框有 0、1、2 或 3 个字符与基线相隔?
  • 为什么有些框中有前导/尾随空格?

我不明白什么机制控制着这些东西。

\documentclass{article}

\usepackage{array}
\usepackage{rotating}

\renewcommand{\arraystretch}{0}%
\setlength{\fboxsep}{0pt}%

\newcommand{\testBox}[2]{%
  \setlength{\fboxsep}{0pt}%
  \fboxrule=.1pt%
  \fbox{%
    \rotatebox[origin=#1]{#2}%
      {#1 #2}%
  }%
}

\begin{document}

\noindent
\tt

\begin{tabular}%
{@{}|llll|llll|llll|@{}}%
  \hline%
  \rlap{\rule{211pt}{.1pt}}%
  \testBox{rt}{090}&%
  \testBox{rb}{090}&%
  \testBox{rt}{270}&%
  \testBox{rb}{270}&%
  %
  \testBox{ct}{090}&%
  \testBox{cb}{090}&%
  \testBox{ct}{270}&%
  \testBox{cb}{270}&%
  %
  \testBox{lt}{090}&%
  \testBox{lb}{090}&%
  \testBox{lt}{270}&%
  \testBox{lb}{270}\\%
  \hline%
\end{tabular}

\end{document}

表格中的旋转框

答案1

正如我所评论的,这对我来说很有意义。指定的旋转原点(例如,[原始]框的右下角)在旋转之前和之后保持在相同的垂直位置。唯一的怪癖是,如果旋转后的框最终会在基线和框之间留有间隙(例如,右上角 270),则框会延伸到基线,而不会重新定位文本。

为了说明我的意思,我稍微调整了你的 MWE 以叠加未旋转和旋转的框,其中旋转点在前后图像中重叠。

\documentclass{article}

\usepackage{array}
\usepackage{rotating}

\renewcommand{\arraystretch}{0}%
\setlength{\fboxsep}{0pt}%

\newcommand{\testBox}[3][0]{%
  \setlength{\fboxsep}{0pt}%
  \fboxrule=.1pt%
  \setbox0=\hbox{\fbox{#2 #3}}%
  \fbox{%
      {#2 #3}%
  }\kern-\wd0%
  \rlap{\makebox[\dimexpr\wd0+#1\ht0][r]{\fbox{%
    \rotatebox[origin=#2]{#3}%
      {#2 #3}%
  }}}%
  \kern\wd0%
}

\begin{document}

\noindent
\tt

  \leavevmode\rlap{\rule{211pt}{.1pt}}
  \testBox[1]{rt}{090}\quad
  \testBox{rb}{090}\quad
  \testBox{rt}{270}\quad
  \testBox[1]{rb}{270}

\renewcommand{\testBox}[3][0]{%
  \setlength{\fboxsep}{0pt}%
  \fboxrule=.1pt%
  \setbox0=\hbox{\fbox{#2 #3}}%
  \fbox{%
      {#2 #3}%
  }\kern-\wd0%
  \rlap{\makebox[\dimexpr\wd0+#1\ht0][c]{\fbox{%
    \rotatebox[origin=#2]{#3}%
      {#2 #3}%
  }}}%
  \kern\wd0%
}
  \leavevmode\rlap{\rule{211pt}{.1pt}}
  \testBox[1]{ct}{090}\quad
  \testBox[-1]{cb}{090}\quad
  \testBox[-1]{ct}{270}\quad
  \testBox[1]{cb}{270}

\renewcommand{\testBox}[3][0]{%
  \setlength{\fboxsep}{0pt}%
  \fboxrule=.1pt%
  \setbox0=\hbox{\fbox{#2 #3}}%
  \fbox{%
      {#2 #3}%
  }\kern-\dimexpr\wd0+#1\ht0\relax%
  \rlap{\makebox[\wd0][l]{\fbox{%
    \rotatebox[origin=#2]{#3}%
      {#2 #3}%
  }}}%
  \kern+\dimexpr\wd0+#1\ht0\relax%%
}
  \leavevmode\rlap{\rule{211pt}{.1pt}}
  \testBox{lt}{090}\quad
  \testBox[1]{lb}{090}\quad
  \testBox[1]{lt}{270}\quad
  \testBox{lb}{270}


\end{document}

在此处输入图片描述

为了澄清起见,我在旋转原点处手动添加了红色标记(在 LaTeX 之外)。

在此处输入图片描述

相关内容