如何更改包含数学内容的纯 TeX 表中的字体大小(字体产生意外结果)

如何更改包含数学内容的纯 TeX 表中的字体大小(字体产生意外结果)

我一直难以设置纯文本表格(即 haligns)中的字体大小。我想将表格设置为使用七号或(最好)八号字体,包括包含数学的表格。

我附上了两次尝试,由于不同的原因均失败了:

尝试 1(使用 fontch)

\input fontch

% Feel free to ignore next two lines, they're just there to make it prettier.
% I've confirmed that they are not the source of the problem at hand.
\def\booktabspacer{\vrule height 0.9\baselineskip depth 0.4\baselineskip width 0pt \relax }
\def\booktablowspacer{\vrule height 0pt depth 0.5\baselineskip width 0pt \relax}
\def\booktabhighspacer{\vrule height 1.0\baselineskip depth 0pt width 0pt \relax}

\input knuth
\vskip 1cm
% work in progress. font size needs to change.
\halign{\tabskip=0.5em
    \hfill\eightpoint # \hfill & \hfill \eightpoint # \hfill \cr
    \noalign{\hrule height 0.08em}
    \omit \eightpoint\booktabspacer\hfill Item One \hfill &\omit \eightpoint\hfill Item Two \hfill \cr
    \noalign{\hrule height 0.05em}
    \booktabhighspacer
    $s_0$ & $16.2$ \cr
    $s_1$ & $18.2$ \cr
    $s_2$ & $11.3$ \cr
    $s_3$ & $19.0$ \cr
    $s_4$ \booktablowspacer & $15.0$ \cr
    \noalign{\hrule height 0.08em}
}
\vskip 1cm
\input knuth
\bye

这会产生以下结果(问题很明显):

尝试

第二次尝试

% Feel free to ignore next two lines, they're just there to make it prettier.
% I've confirmed that they are not the source of the problem at hand.
\def\booktabspacer{\vrule height 0.9\baselineskip depth 0.4\baselineskip width 0pt \relax }
\def\booktablowspacer{\vrule height 0pt depth 0.5\baselineskip width 0pt \relax}
\def\booktabhighspacer{\vrule height 1.0\baselineskip depth 0pt width 0pt \relax}

\input knuth
\vskip 1cm
% work in progress. font size needs to change.
\halign{\tabskip=0.5em
    \hfill\sevenrm # \hfill & \hfill \sevenrm # \hfill \cr
    \noalign{\hrule height 0.08em}
    \omit \sevenrm\booktabspacer\hfill Item One \hfill &\omit \sevenrm\hfill Item Two \hfill \cr
    \noalign{\hrule height 0.05em}
    \booktabhighspacer
    $s_0$ & $16.2$ \cr
    $s_1$ & $18.2$ \cr
    $s_2$ & $11.3$ \cr
    $s_3$ & $19.0$ \cr
    $s_4$ \booktablowspacer & $15.0$ \cr
    \noalign{\hrule height 0.08em}
}
\vskip 1cm
\input knuth
\bye

这会产生以下内容(问题是数学字体大小保持不变):

第七次尝试

我有两个问题:

1)为什么这次 Fo​​ntch 尝试与人们的预期如此不同?

2) 我该怎么做才能得到一个具有字体大小与字体尝试中给出的一样的表格,但不会出现荒谬的间距问题?

答案1

正如 egreg 所评论的,该命令似乎应该在垂直模式下使用。此外,您似乎希望将表格居中。以下是实现此目的的一种方法:

\input fontch
\input knuth
$$
\eightpoint
\vcenter{\halign{\tabskip=1em
  $#\hfil$& $#\hfil$\cr
    \omit Item One\hfil& \omit Item Two\hfil\cr
    \noalign{\smallskip\hrule\smallskip}
    s_0& 16.2\cr
    s_1& 18.2\cr
    s_2& 11.3\cr
    s_3& 19.0\cr
    s_4& 15.0\cr}
  }
$$
\input knuth
\bye

(我实际上没有fontch安装,所以我不知道上述是否真的有效:-)

请注意,'s 后面的空格&将被丢弃,但不是之前的那些。还请注意,显示数学模式开始一个组,因此更改\eightpoint仅限于其中。

答案2

尝试 1 的问题在于命令 eightpoint 的位置。尝试以下代码

\input fontch
\def\booktabspacer{\vrule height 0.9\baselineskip depth 0.4\baselineskip width 0pt\relax}
\def\booktablowspacer{\vrule height 0pt depth 0.5\baselineskip width 0pt \relax}
\def\booktabhighspacer{\vrule height 1.0\baselineskip depth 0pt width 0pt \relax}

\input knuth
\vskip 1cm
% work in progress. font size needs to change.
%%%
\eightpoint
%%%
%% Everything is changed to eightpoint, includig all distances that are
%% needed to properly display the text. The eightpoint settings are used
%% untill a new change font commmand is executed. The eightpont commands
%% inside the \halign command are not needed.
%% If you like to center the table uncomment the following line
% $$ \vcenter{
\halign{\tabskip=0.5em
\hfill # \hfill & \hfill  # \hfill \cr
\noalign{\hrule height 0.08em}
\omit \booktabspacer\hfill Item One \hfill &\omit \hfill Item Two \hfill \cr
\noalign{\hrule height 0.05em}
\booktabhighspacer
$s_0$ & $16.2$ \cr
$s_1$ & $18.2$ \cr
$s_2$ & $11.3$ \cr
$s_3$ & $19.0$ \cr
$s_4$ \booktablowspacer & $15.0$ \cr
\noalign{\hrule height 0.08em}
}
%% The following line closes the \vcenter command.
% }$$
%% The next command is needed in order to recover the standard size. If it is
%% not executed TeX continues writing with the eight point font (try it).
%%%
\tenpoint
%%%
\vskip 1cm
\input knuth
\bye

相关内容