\makebox 在 \NewDocumentEnvironment 中时会导致“Underfull \hbox”警告

\makebox 在 \NewDocumentEnvironment 中时会导致“Underfull \hbox”警告

梅威瑟:

%! TEX program = lualatex

\documentclass[fleqn, oneside, titlepage = false, fontsize = 12pt]{scrbook}

\usepackage{xparse}

\usepackage{fontspec}

\setmainfont{cmun}[
    Extension=.otf,
    UprightFont=*rm,
    ItalicFont=*ti,
    BoldFont=*bx,
    BoldItalicFont=*bi,
]

\usepackage{IEEEtrantools}

\NewDocumentEnvironment{sustav3x3xyz}{b}
{%
\noindent\makebox[\textwidth][c]{\begin{minipage}{6cm}
    \begin{IEEEeqnarray}{rlCrlCrlCl}
        #1
    \addtocounter{equation}{1}
    \end{IEEEeqnarray}
\end{minipage}}
}{}

% https://tex.stackexchange.com/questions/149370/ieeeeqnarray-tag-like-command
\makeatletter
\newcommand\ztag[1]{%
\def\@currentlabel{#1}%
\gdef\tmp{%
\addtocounter{equation}{-1}%
\def\theequation{#1}}%
\aftergroup\aftergroup\aftergroup\aftergroup\aftergroup\aftergroup
\aftergroup\aftergroup\aftergroup\aftergroup\aftergroup\aftergroup
\aftergroup\aftergroup\aftergroup\aftergroup\aftergroup\aftergroup
\aftergroup\aftergroup\aftergroup\aftergroup\aftergroup\aftergroup
\aftergroup\aftergroup\aftergroup\aftergroup\aftergroup\aftergroup
\aftergroup
\tmp}

\begin{document}

        \noindent\makebox[\textwidth][c]{%
        \begin{minipage}{6cm}
        \begin{IEEEeqnarray}{rlCrlCrlCl}
            2&x &+& 2&y &-& 2&z & = & 1 \ztag{1}
            \\*
            3&x &+& 5&y &-& 2&z & = & 2 \ztag{2}
            \\*
            3&x &+& 5&y &-& &z & = & 3 \ztag{3}
            \addtocounter{equation}{1}
        \end{IEEEeqnarray}\end{minipage}}

        \begin{sustav3x3xyz}
            2&x &+& 2&y &-& 2&z & = & 1 \ztag{1}
            \\*
            3&x &+& 5&y &-& 2&z & = & 2 \ztag{2}
            \\*
            3&x &+& 5&y &-& &z & = & 3 \ztag{3}
        \end{sustav3x3xyz}

\end{document}

结果: 方程组


警告

warning| Underfull \hbox (badness 10000) in paragraph ...

警告指的是第二个方程组。如果我删除该系统,警告就会消失。此外,如果我\makebox从第二个系统中删除,警告也会消失。我使用\makebox使两个系统水平居中。这两个系统的代码几乎相同,只是第二个系统依赖于\NewDocumentEnvironment

答案1

在环境中将 \parfillskip 设置为 0,或者(可能更好)使用 \centering 代替此 \makebox

\NewDocumentEnvironment{sustav3x3xyz}{b}
{%\parfillskip=0pt % with the makebox
\centering
%\noindent\makebox[\textwidth][c]{%
 \begin{minipage}{6cm}
    \begin{IEEEeqnarray}{rlCrlCrlCl}
        #1
    \addtocounter{equation}{1}
    \end{IEEEeqnarray}
\end{minipage}%
%}
\par% for the centering
}{}

顺便说一句:ztag 定义导致重复的目的地,因此链接无法正常工作:

warning  (pdf backend): ignoring duplicate destination with the name 'equation.1
.1.0'

相关内容