导入 MnSymbols 后 tabularx 中的垂直空间

导入 MnSymbols 后 tabularx 中的垂直空间

我在 Windows 7 上将软件包与 TeXMaker 一起使用memoir。我想创建一个表 (unsing tabularx),在其中解释我将在整个文档中使用的符号。符号本身是从 导入的MnSymbol。我不要自始至终使用 MnSymbol 数学字符,但只在序言中导入我需要的几个符号。

现在,由于某种原因,MnSymbol在环境中使用这些字符tabularx会在我的主文档中引入任意垂直空间,如下所示:

带有符号的未对齐最后一列的示例。

为什么?让我困惑的是,当为这个线程编写 MWE 时,错位消失了!这是 MWE 的快照。

突然间,错位消失了。

table我没有修改主文档中的环境定义memoir。我尝试MnSymbol用“普通”命令替换我创建的宏,但这并不能解决问题。

有人可以帮忙吗?

最小工作示例

\documentclass[a4paper, 11pt, onecolumn, twoside]{memoir}

\usepackage{multirow}
\usepackage{tabularx}

% Import symbols from MnSymbol:
\DeclareFontFamily{U} {MnSymbolC}{}
\DeclareFontShape{U}{MnSymbolC}{m}{n}{
  <-6> MnSymbolC5
  <6-7> MnSymbolC6
  <7-8> MnSymbolC7
  <8-9> MnSymbolC8
  <9-10> MnSymbolC9
  <10-12> MnSymbolC10
  <12-> MnSymbolC12}{}
\DeclareFontShape{U}{MnSymbolC}{b}{n}{
  <-6> MnSymbolC-Bold5
  <6-7> MnSymbolC-Bold6
  <7-8> MnSymbolC-Bold7
  <8-9> MnSymbolC-Bold8
  <9-10> MnSymbolC-Bold9
  <10-12> MnSymbolC-Bold10
  <12-> MnSymbolC-Bold12}{}

\DeclareSymbolFont{MnSyC} {U} {MnSymbolC}{m}{n}

\DeclareMathSymbol{\medstar}{\mathbin}{MnSyC}{130}
\DeclareMathSymbol{\medlozenge}{\mathbin}{MnSyC}{197}
\DeclareMathSymbol{\medtriangleup}{\mathbin}{MnSyC}{81}

\begin{document}

\begin{table}
    \centering
    \begin{tabularx}{\textwidth}{c*4{>{\centering\arraybackslash}X}} 
     Letter & Caption & Number & Symbol\\
     \multicolumn{4}{c}{\rule[-.3\baselineskip]{0pt}{\baselineskip}}\\
    A & first line & $1.00$ & $\medstar$ \\
    B & second line & $2.00$ & $\medlozenge$ \\
    C & third line & $3.00$ & $\medtriangleup$ \\
    \multicolumn{4}{c}{\hrulefill}
    \end{tabularx}
    \caption{Here's a basic table.}
\end{table}

\end{document}

答案1

您的示例没有显示错位,正如此代码所证明的那样,我将其添加\showbase到第一个单元格以标记基线:

\documentclass[a4paper, 11pt, onecolumn, twoside]{memoir}

\usepackage{tabularx}
\usepackage{xcolor}

\newcommand{\showbase}{\makebox[0pt][l]{\vrule height 0pt depth 0.1pt width \textwidth}}

% Import symbols from MnSymbol:
\DeclareFontFamily{U} {MnSymbolC}{}
\DeclareFontShape{U}{MnSymbolC}{m}{n}{
  <-6> MnSymbolC5
  <6-7> MnSymbolC6
  <7-8> MnSymbolC7
  <8-9> MnSymbolC8
  <9-10> MnSymbolC9
  <10-12> MnSymbolC10
  <12-> MnSymbolC12}{}
\DeclareFontShape{U}{MnSymbolC}{b}{n}{
  <-6> MnSymbolC-Bold5
  <6-7> MnSymbolC-Bold6
  <7-8> MnSymbolC-Bold7
  <8-9> MnSymbolC-Bold8
  <9-10> MnSymbolC-Bold9
  <10-12> MnSymbolC-Bold10
  <12-> MnSymbolC-Bold12}{}

\DeclareSymbolFont{MnSyC} {U} {MnSymbolC}{m}{n}

\DeclareMathSymbol{\medstar}{\mathbin}{MnSyC}{130}
\DeclareMathSymbol{\medlozenge}{\mathbin}{MnSyC}{197}
\DeclareMathSymbol{\medtriangleup}{\mathbin}{MnSyC}{81}

\begin{document}

\begin{table}
    \centering
    \begin{tabularx}{\textwidth}{>{\showbase}c*4{>{\centering\arraybackslash}X}} 
     Letter & Caption & Number & Symbol\\
     \multicolumn{4}{c}{\rule[-.3\baselineskip]{0pt}{\baselineskip}}\\
    A & first line & $1.00$ & $\medstar$ \\
    B & second line & $2.00$ & $\medlozenge$ \\
    C & third line & $3.00$ & $\medtriangleup$ \\
    \multicolumn{4}{c}{\hrulefill}
    \end{tabularx}
    \caption{Here's a basic table.}
\end{table}

\end{document}

在此处输入图片描述

另一方面,如果我将第一个表格行更改为

    A & first line & $1.00$ & \color{blue}$\medstar$ \\

我明白了

在此处输入图片描述

这确实表明了问题。这恰恰是由\color{blue}启动文本引起的。如果输入是正确的

\textcolor{blue}{$\medstar$}

问题就不会出现。

因此,问题与使用从 导入的符号无关MnSymbol,而只是与 的不当使用有关\color

请注意,您制定规则或在表格中留出空间的技巧是错误的。

这是一个有效的代码:

\begin{table}
\centering

\begin{tabularx}{\textwidth}{c*4{>{\centering\arraybackslash}X}}
Letter & Caption & Number & Symbol\\[1ex]
A & first line & $1.00$ & \textcolor{blue}{$\medstar$} \\
B & second line & $2.00$ & \textcolor{green}{$\medlozenge$} \\
C & third line & $3.00$ & \textcolor{red}{$\medtriangleup$} \\
\hline
\end{tabularx}

\caption{Here's a basic table.}
\end{table}

我建议booktabs无论如何都要使用。

在此处输入图片描述

答案2

您的表格“构造”相当不寻常。并且MnSymbol不是问题的根源。

不清楚您想用 实现什么\multicolumn{4}{c}{\rule[-.3\baselineskip]{0pt}{\baselineskip}}\\。相反,我将使用 包中的某些规则booktabs,例如\addlinespace增加行之间的空间、\midrul列标题和其余列之间的行以及bottomrule表格底部的行:

\documentclass[a4paper, 11pt, onecolumn, twoside]{memoir}

\usepackage{multirow}
\usepackage{booktabs} % added 'booktabs', removed 'tabularx' since it is provided by memoir

% Import symbols from MnSymbol:
\DeclareFontFamily{U} {MnSymbolC}{}
\DeclareFontShape{U}{MnSymbolC}{m}{n}{
  <-6> MnSymbolC5
  <6-7> MnSymbolC6
  <7-8> MnSymbolC7
  <8-9> MnSymbolC8
  <9-10> MnSymbolC9
  <10-12> MnSymbolC10
  <12-> MnSymbolC12}{}
\DeclareFontShape{U}{MnSymbolC}{b}{n}{
  <-6> MnSymbolC-Bold5
  <6-7> MnSymbolC-Bold6
  <7-8> MnSymbolC-Bold7
  <8-9> MnSymbolC-Bold8
  <9-10> MnSymbolC-Bold9
  <10-12> MnSymbolC-Bold10
  <12-> MnSymbolC-Bold12}{}

\DeclareSymbolFont{MnSyC} {U} {MnSymbolC}{m}{n}

\DeclareMathSymbol{\medstar}{\mathbin}{MnSyC}{130}
\DeclareMathSymbol{\medlozenge}{\mathbin}{MnSyC}{197}
\DeclareMathSymbol{\medtriangleup}{\mathbin}{MnSyC}{81}

\begin{document}

\begin{table}
    \centering
    \begin{tabularx}{\textwidth}{c*4{>{\centering\arraybackslash}X}}
     Letter & Caption & Number & Symbol\\
%     \addlinespace   % it is not clear, if you like to have more vertical space
    \midrule          % or line as I selected here
    A & first line & $1.00$ & $\medstar$ \\
    B & second line & $2.00$ & $\medlozenge$ \\
    C & third line & $3.00$ & $\medtriangleup$ \\
    \bottomrule
    \end{tabularx}
    \caption{Here's a basic table.}
\end{table}

\end{document}

在此处输入图片描述

答案3

有点羞愧的是,添加\renewcommand{\tabularxcolumn}[1]{m{#1}}序言并结合 Zarko 的回答解决了我的问题。希望这也能帮助其他人。

相关内容