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 0 & 1 & 1 & 1 & 1 & 0 & 0 & 0 \\
1 & 1 & 0 & 1 & 0 & 1 & 1 & 0 & 1 & 0 & 0 & 1 & 1 & 0 & 0 & 0 \\
\end{pmatrix}
\begin{pmatrix}
x_{15} \\
x_{14} \\
x_{13} \\
x_{12} \\
x_{11} \\
x_{10} \\
x_{9} \\
x_{8} \\
x_{7} \\
x_{6} \\
x_{5} \\
x_{4} \\
x_{3} \\
x_{2} \\
x_{1} \\
x_{0} \\
\end{pmatrix}^{-1}
+
\begin{pmatrix}
0 \\
1 \\
0 \\
0 \\
0 \\ 
1 \\
0 \\
1 \\
1 \\
0 \\
1 \\
1 \\
0 \\ 
1 \\
1 \\
1 \\
\end{pmatrix}

但是,当我尝试使用llncs类文件编译相同的代码时(http://www.springer.com/computer/lncs/lncs+authors?SGWID=0-40209-0-0-0),这迫使我删除amsmath包引用,但抛出了以下错误:

! 对齐制表符放错位置 &. l.544 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 1 & 1 & 1 & 1 & 1 & 0 \ 显然我犯了一些简单的错误,但我不确定是什么。有人看到了吗?

答案1

没有amsmath,您可以将 设置pmatrixarray带有列规范的@{}*{<num>}{c}@{}。这将设置<num>包含输入内容的列,并且矩阵两侧c没有间距:@{}

在此处输入图片描述

\documentclass{llncs}% http://www.springer.com/computer/lncs/lncs+authors?SGWID=0-40209-0-0-0
\begin{document}
\begin{equation}
  S(x) = 
  \left(\begin{array}{@{}*{16}{c}@{}}
    0 & 0 & 1 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 1 & 1 & 1 & 1 & 1 & 0 \\
    1 & 1 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 1 & 1 & 0 & 1 & 0 & 1 & 0 \\
    1 & 1 & 0 & 0 & 1 & 0 & 1 & 1 & 0 & 1 & 0 & 1 & 0 & 0 & 1 & 1 \\
    1 & 1 & 1 & 0 & 0 & 0 & 1 & 0 & 0 & 1 & 1 & 0 & 0 & 0 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\\ 1 \\ 1 \\ 0 \\ 1 \\ 1 \\ 0 \\ 1 \\ 1 \\ 1
  \end{array}\right)
\end{equation}
\end{document}

答案2

&我只是想向自己证明,不用那些字符并且用更少的宏就可以做到这一点\\

\documentclass{article}%{llncs}%
\usepackage{stackengine}[2013-09-11]
\strutlongstacks{T}
\newsavebox{\matrixbox}
\newcommand\Matrixstack[1]{%
  \sbox{\matrixbox}{\Longstack{#1}}\left(%
    \abovebaseline[-.5\ht\matrixbox+.5\ht\strutbox-\dp\strutbox]
    {\usebox{\matrixbox}}\right)}
\begin{document}
\begin{equation}
  S(x) = 
  \setstackEOL{\\}\Matrixstack{%
    0  0  1  0  0  0  0  1  0  0  1  1  1  1  1  0 \\
    1  1  0  0  0  0  0  1  0  1  1  0  1  0  1  0 \\
    1  1  0  0  1  0  1  1  0  1  0  1  0  0  1  1 \\
    1  1  1  0  0  0  1  0  0  1  1  0  0  0  0  0 \\
    1  1  0  0  0  1  1  0  0  1  1  1  1  0  1  1 \\
    0  1  0  0  0  0  1  1  0  1  1  1  1  1  0  1 \\
    0  0  1  0  1  0  1  0  1  1  0  0  1  1  0  0 \\
    1  0  1  1  1  0  1  1  0  0  0  1  0  1  1  1 \\
    0  1  0  0  0  0  0  0  1  0  0  1  1  1  0  1 \\
    1  0  1  1  0  0  0  1  0  0  1  0  1  0  0  0 \\
    1  0  1  0  0  1  1  1  0  0  1  1  0  1  0  0 \\
    1  0  1  1  1  0  1  1  1  1  0  1  1  0  0  1 \\
    1  0  1  0  0  1  0  1  1  0  0  1  0  0  0  1 \\
    0  1  0  0  0  1  1  1  1  0  0  0  0  0  0  1 \\
    1  0  0  0  1  1  0  1  0  1  1  1  1  0  0  0 \\
    1  1  0  1  0  1  1  0  1  0  0  1  1  0  0  0}
  \stackMath\setstackEOL{ }\Matrixstack{%
    x_{15} x_{14} x_{13} x_{12} x_{11} x_{10} x_9 x_8
    x_7 x_6 x_5 x_4 x_3 x_2 x_1 x_0}^{-1}
  +
  \Matrixstack{0 1 0 0 0 1 0 1 1 0 1 1 0 1 1 1}
\end{equation}
\end{document}

在此处输入图片描述

相关内容