在表格中使用 resizegather:如何删除等式上方和下方的多余垂直空间?

在表格中使用 resizegather:如何删除等式上方和下方的多余垂直空间?

我需要将 CAS 生成的一些大型方程式放入表格中。 resizegather看起来它可以完成这项工作。但它会在每行的方程式上方和下方产生大量额外空间。

使用时会发生这种情况\begin{gather*} ... \end{gather*}。它确实在水平方向上缩小了方程式,以便适合,但我正在寻找一种方法来删除上下空格。

当使用时\begin{gathered} ... \end{gathered},上面和下面的空间消失了,但等式不再缩小!

这是 MWE

\documentclass[12pt]{article}
%\documentclass[12pt,parskip=full]{scrbook} %same result with this also

\usepackage{amsmath}
\usepackage{array} %for the m option
\usepackage{resizegather}

\begin{document}

No wasted extra space here in the vertical direction, 
but the math do not scale as expected

\begin{tabular}[c]{|m{2in}|l|}\hline
Solution & Verification\\  \hline
{$\begin{gathered} y=\sin x\tan x \int \cos x +3 x\sin x\tan x\end{gathered}$}&OK\\\hline
\end{tabular}

Here the math scales as expected to fit, but lots of extra 
wasted extra space in the vertical direction

\begin{tabular}[c]{|m{2in}|l|}\hline
Solution & Verification\\  \hline
\begin{gather*} y=\sin x \tan x\int \cos x + 3 x\sin x\tan x\end{gather*}&OK\\\hline
\end{tabular}

\end{document}

Mathematica 图形

列表文件

 *File List*
 scrbook.cls    2019/02/01 v3.26b KOMA-Script document class (book)
scrkbase.sty    2019/02/01 v3.26b KOMA-Script package (KOMA-Script-dependent bas
ics and keyval usage)
 scrbase.sty    2019/02/01 v3.26b KOMA-Script package (KOMA-Script-independent b
asics and keyval usage)
  keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
scrlfile.sty    2019/02/01 v3.26b KOMA-Script package (loading files)
tocbasic.sty    2019/02/01 v3.26b KOMA-Script package (handling toc-files)
scrsize12pt.clo    2019/02/01 v3.26b KOMA-Script font size class option (12pt)
typearea.sty    2019/02/01 v3.26b KOMA-Script package (type area)
 amsmath.sty    2018/12/01 v2.17b AMS math features
 amstext.sty    2000/06/29 v2.01 AMS text
  amsgen.sty    1999/11/30 v2.0 generic functions
  amsbsy.sty    1999/11/29 v1.2d Bold Symbols
  amsopn.sty    2016/03/08 v2.02 operator names
   array.sty    2018/12/30 v2.4k Tabular extension package (FMi)
resizegather.sty    2016/05/16 v1.3 Resize overly large equations (HO)
kvoptions.sty    2016/05/16 v3.12 Key value format for package options (HO)
 ltxcmds.sty    2016/05/16 v1.23 LaTeX kernel commands for general use (HO)
kvsetkeys.sty    2016/05/16 v1.17 Key value parser (HO)
infwarerr.sty    2016/05/16 v1.4 Providing info/warning/error messages (HO)
etexcmds.sty    2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO)
ifluatex.sty    2016/05/16 v1.4 Provides the ifluatex switch (HO)
graphics.sty    2017/06/25 v1.2c Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    2016/01/03 v1.10 sin cos tan (DPC)
graphics.cfg    2016/06/04 v1.11 sample graphics configuration
  luatex.def    2018/01/08 v1.0l Graphics/color driver for luatex
supp-pdf.mkii
epstopdf-base.sty    2016/05/15 v2.6 Base part for package epstopdf
  grfext.sty    2016/05/16 v1.2 Manage graphics extensions (HO)
kvdefinekeys.sty    2016/05/16 v1.4 Define keys (HO)
pdftexcmds.sty    2018/09/10 v0.29 Utility functions of pdfTeX for LuaTeX (HO)
   ifpdf.sty    2018/09/07 v3.3 Provides the ifpdf switch
 ***********

)

更新

尝试下面的答案,我没有看到方程缩小。这是新的 MWE。

\documentclass[12pt,parskip=full]{scrbook}

\usepackage{nccmath}
\usepackage{makecell} 
\setcellgapes{5pt}  
\usepackage{resizegather}      
\begin{document}

{\makegapedcells
\begin{tabular}[c]{|l|l|}\hline
Solution & Verification\\  \hline
$\medmath{\begin{gathered}y=\sin x\tan x \int \cos x +3 x\sin x\tan x \sin x\tan x \int \cos x +3 x\sin x\tan x y=\sin x\tan x \int \cos x +3 x\sin x\tan x y=\sin x\tan x \int \cos x +3 x\sin x\tan x y=\sin x\tan x \int \cos x +3 x\sin x\tan x\end{gathered}}$&OK\\ \hline
\end{tabular}
}

\end{document}

Mathematica 图形

答案1

太渴望评论了。为了模拟您的要求可以产生的结果,请参见以下示例:

\documentclass[12pt,parskip=full]{scrbook}
\usepackage{array} 
\usepackage{resizegather}

\begin{document}

{
\addtolength\abovedisplayskip{-30pt}
\addtolength\belowdisplayskip{-25pt}
\begin{tabular}[c]{|m{0.55in}|l|}\hline
Solution & Verification \\  \hline
%\vspace*{-5ex}
\begin{gather*} 
y=\sin x \tan x\int \cos x + 3 x\sin x\tan x
\end{gather*}
%\vspace*{-4ex}
        & OK            \\   \hline
\end{tabular}
}
\end{document}

预期结果很丑陋且无用:

在此处输入图片描述

答案2

请注意,该gathered环境位于一些其他数学环境内,因此对于包来说不可见resizegather,因此它无法影响“聚集”。

我建议你采用另一种方法,(在我看来)这种方法效果更好。通过使用包\medmath中的宏nccmath和使用makecell包,你可以获得以下结果:

在此处输入图片描述

\documentclass[12pt,parskip=full]{scrbook}
\usepackage{nccmath}
\usepackage{makecell} 
\setcellgapes{5pt}
\usepackage{resizegather}

\begin{document}

No wasted extra space here in the vertical direction,
but the math do not scale as expected

{\makegapedcells
\begin{tabular}{|l|l|}
    \hline
Solution    & Verification  \\  
    \hline
$\medmath{
    \begin{gathered} 
y = \sin x\tan x \int\cos x +3 x\sin x\tan x
    \end{gathered} }
$           &   OK          \\
    \hline
\end{tabular}
}

Here the math scales as expected to fit, but lots of extra
wasted extra space in the vertical direction

\begin{tabular}[c]{|m{2in}|l|}\hline
Solution & Verification \\  \hline
\begin{gather*} 
y=\sin x \tan x\int \cos x + 3 x\sin x\tan x\end{gather*}
        & OK            \\   \hline
\end{tabular}

If you are limited with horisontal space for equation you may consider to split equation into two lines and not reduce font size to much:

{\makegapedcells
\begin{tabular}{|l|l|}
    \hline
Solution    & Verification  \\
    \hline
$
    \begin{multlined}
y = \sin x\tan x    \\[-3ex]
    \int\cos x dx + 3 x\sin x\tan x
    \end{multlined}
$           &   OK          \\
    \hline
\end{tabular}

or with use of \verb+\medmath+:

{\makegapedcells
\begin{tabular}{|l|l|}
    \hline
Solution    & Verification  \\
    \hline
$\medmath{
    \begin{multlined}
y = \sin x\tan x    \\
    \int\cos x dx + 3 x\sin x\tan x
    \end{multlined} }
$           &   OK          \\
    \hline
\end{tabular}

\end{document}

相关内容