\halign 中的垂直线与行间距 - LaTeX 错误

\halign 中的垂直线与行间距 - LaTeX 错误
\documentclass[12pt, russian]{article}

\tracingall
\tracingassigns=5
\tracingmacros=2
\tracingcommands=2
\tracingrestores=1
\tracingstats=0
\tracingoutput=10
\tracinggroups=10
\tracingonline0

\begin{document}
$$
  \left\{
   \hbox\bgroup
    $
     \vcenter\bgroup
      \gdef\withlineskip{\hbox\bgroup$}
      \gdef\endwithlineskip{$\egroup}
      \gdef\\{%
        \cr
        \gdef\withlineskip{\hbox\bgroup \vbox\bgroup \hbox{}\hbox\bgroup$}%
        \gdef\endwithlineskip{$\egroup\egroup\egroup}%
        \gdef\\{\cr}%
      }
      \offinterlineskip
      \halign{
        \hfil\withlineskip # \endwithlineskip
        &\withlineskip {}#{} \endwithlineskip
        &\withlineskip # \endwithlineskip\hfil\ \vrule
        &\withlineskip {} \cdot # \endwithlineskip\cr
        g s_{12} + s_{21} & = & (x_{1}\psi_{1})(t) = \frac{1}{g}U_{1}(t) & (-v) \\
        -s_{11} + v s_{12} + s_{22} & = & (x_{1}\psi_{2})(t) & g \\
        g s_{22} - g s_{11} - v s_{21} & = & \frac{1}{g} (g U_{2}(t) - v U_{1}(t)) & (-1) \\
      }
     \egroup
    $
   \egroup
  \right.
$$
\end{document}

我的意图在标题中。有人能解释一下 LaTeX 给出的错误吗?从.log文件中我了解到出了问题 -\\已被捕获到\halign模板条目中。无论如何,这总是会发生吗?如何解决我保存意图原理的问题?

对于那些寻求(几乎)正确输出的人,请编译这个。

\documentclass[12pt, russian]{article}

\begin{document}
$$
  \left\{
   \hbox\bgroup
    $
    \displaystyle
     \vcenter\bgroup
      \gdef\withlineskip{$\displaystyle}
      \gdef\endwithlineskip{$}
      \gdef\\{%
        \cr%
      }
      \offinterlineskip
      \halign{%
        \hfil\withlineskip#\endwithlineskip
        &\withlineskip{}#{}\endwithlineskip
        &\withlineskip#\endwithlineskip\hfil\ \vrule
        &\withlineskip{}\cdot#\endwithlineskip\hfil\cr
        g s_{12} + s_{21} & = & (x_{1}\psi_{1})(t) = \frac{1}{g}U_{1}(t) &(-v)\\
        -s_{11} + v s_{12} + s_{22} & = & (x_{1}\psi_{2})(t) &g\\
        g s_{22} - g s_{11} - v s_{21} & = & \frac{1}{g} (g U_{2}(t) - v U_{1}(t)) &(-1)\\
      }
     \egroup
    $
   \egroup
  \right.
$$
\end{document}

你注意到第三行和第二行发生冲突了吗?这就是我要解决的问题。(好吧,我的方法中又发现了一个错误,等有人向我解释错误后,我会改正的。)

更新

这就是我最初想要的:

\documentclass[12pt, russian]{article}

\begin{document}
\begin{equation}
  \left\{
   \hbox\bgroup
    $
     \vcenter\bgroup
      % \openup1\jot
      \edef\restoreinterlineskip{%
        \baselineskip=\the\baselineskip
        \lineskip=\the\lineskip
        \lineskiplimit=\the\lineskiplimit
      }
      \gdef\withlineskip{%
        \hbox\bgroup
         \hbox\bgroup
          \hbox\bgroup
           $%
            \displaystyle
      }
      \gdef\endwithlineskip{%
           $%
          \egroup
         \egroup
        \egroup
      }
      \gdef\nextrow{%
        \cr
        \noalign{\xdef\prevrowdepth{\the\prevdepth}\vskip -\prevrowdepth}%
        \gdef\withlineskip{%
          \hbox\bgroup 
           \restoreinterlineskip
           \vbox\bgroup
           \hbox{\vrule width 0pt height 0pt depth \prevrowdepth }%
           \hbox\bgroup
            $
             \displaystyle
        }%
        \gdef\nextrow{%
          \cr
          \noalign{\xdef\prevrowdepth{\the\prevdepth}}%
        }%
      }
      \offinterlineskip
      \halign{
        \hfil\withlineskip # \endwithlineskip
        &\withlineskip {}#{} \endwithlineskip
        &\withlineskip # \endwithlineskip\hfil\ \vrule
        &\withlineskip {} \cdot # \endwithlineskip\cr
        g s_{12} + s_{21} & = & (x_{1}\psi_{1})(t) = \frac{1}{g}U_{1}(t) & (-v) \nextrow
        -s_{11} + v s_{12} + s_{22} & = & (x_{1}\psi_{2})(t) & g \nextrow
        g s_{22} - g s_{11} - v s_{21} & = & \frac{1}{g} (g U_{2}(t) - v U_{1}(t)) & (-1) \nextrow
      }
      \egroup
    $
   \egroup
  \right.
  \Longrightarrow 0 = 0
\end{equation}
\end{document}

在此处输入图片描述

无需手动选择跨行跳过!:-)

答案1

问题在于 是\gdef之后第一列的一部分\cr。它们是在\hfil\whitlineskip扩展第一列的第一个之后处理的。因此\endwithlineskip第一列与 不匹配\withlineskip

我不知道要求是什么。可能只是在行之间插入空白行。然后\noalign{\bigskip}解决\cr了它。但这是纯 TeX 方法,我不明白为什么它被 LaTeX 的命令包围。

答案2

这是您所追求的 (LaTeX 语法) 吗?

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
  \renewcommand{\arraystretch}{1.5}
  \begin{array}{rl|l}
    gs_{12} + s_{21}            & = (x_1\psi_1)(t) = \dfrac1g U_1(t) & {}\cdot(-v)\\
    -s_{11} + vs_{12} + s_{22}  & = (x_1\psi_2)(t)                  & {}\cdot g\\
    gs_{22} - gs_{11} - vs_{21} & = \dfrac1g (gU_2(t) - vU_1(t))     & {}\cdot (-1)\\
  \end{array}
\]
\end{document}

在此处输入图片描述

使用纯格式的 TeX 原语,可以生成类似这样的内容:

$$
  \left\{\,
  \vcenter{
    \let\DS\displaystyle
    \mathsurround=0pt
    \def\cr{\crcr\noalign{\nointerlineskip}}
    \def\invisiblethingamabob{%
      \vrule height\baselineskip depth.6\baselineskip width0pt}
    \halign{\invisiblethingamabob $\DS\hfil #$& $\DS{}#\hfil\ \vrule $&
    $\;\DS{}\cdot #\hfil$\crcr
    gs_{12} + s_{21}            &= (x_1\psi_1)(t) = {1\over g} U_1(t) & (-v)\cr
    - s_{11} + vs_{12} + s_{22} &= (x_1\psi_2)(t)                     & g \cr
    gs_{22} - gs_{11} - vs_{21} &= {1\over g} (gU_2(t) - vU_1(t))     & (-1)\cr
  }}
  \right.
$$

在此处输入图片描述

答案3

你为一些在 LaTeX 中相当简单的事情做了太多的工作。

\documentclass[12pt]{article}
\usepackage{array}

\begin{document}
\[
\left\{
\begin{array}{@{}r@{}>{{}}l |@{} >{{}\cdot}l@{}}
g s_{12} + s_{21}              &= (x_{1}\psi_{1})(t) = \frac{1}{g}U_{1}(t) & (-v) \\[2ex]
-s_{11} + v s_{12} + s_{22}    &= (x_{1}\psi_{2})(t)                       & g    \\[2ex]
g s_{22} - g s_{11} - v s_{21} &= \frac{1}{g} (g U_{2}(t) - v U_{1}(t))    & (-1)
\end{array}
\right.
\]
\end{document}

在此处输入图片描述

不,即使你要求,我也不会删除这个答案。

你的宏为什么不起作用?你正在尝试以最复杂的方式做事。

这是一个在 Plain TeX 中或多或少直接的实现。

\def\frac#1#2{{\begingroup#1\endgroup\over#2}}

$$
\left\{
\vcenter{
  \tabskip=0pt
  \offinterlineskip
  \halign{\strut\hfil$#$&${}#$\hfil&\hskip3pt\vrule#&${}\cdot#$\hfil\cr
  g s_{12} + s_{21}&             = (x_{1}\psi_{1})(t) = \frac{1}{g}U_{1}(t)&& (-v)\cr
  \omit&& height1.5ex&\omit\cr
  -s_{11} + v s_{12} + s_{22}&   = (x_{1}\psi_{2})(t)&&                       g\cr
  \omit&& height1.5ex&\omit\cr
  g s_{22} - g s_{11} - v s_{21}&= \frac{1}{g} (g U_{2}(t) - v U_{1}(t))&&    (-1)\cr
  }
}
\right.
$$
\bye

在此处输入图片描述

相关内容