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 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}

However, when I try to compile this same code with the llncs class file (http://www.springer.com/computer/lncs/lncs+authors?SGWID=0-40209-0-0-0), which forces me to remove the amsmath package references, the following error is thrown:

! Misplaced alignment tab character &. l.544 0 & 0 & 1 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 1 & 1 & 1 & 1 & 1 & 0 \ Clearly I'm making some simple error, but I'm not sure what it is. Does anyone see it?

  • Is the inverse misplaced? It should be on a square matrix. – Andrew Swann Oct 1 '13 at 9:40
  • Nope, but good eye! – caw Oct 2 '13 at 18:33
6

Without amsmath, you can set a pmatrix as an array with column specification @{}*{<num>}{c}@{}. This sets <num> columns with centered content and not spacing @{} on either side of the matrix:

enter image description here

\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 &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 \\ 0 \\ 1 \\ 0 \\ 1 \\ 1 \\ 0 \\ 1 \\ 1 \\ 0 \\ 1 \\ 1 \\ 1
  \end{array}\right)
\end{equation}
\end{document}
  • 1
    If you wish to spread out the content a little more, add \setlength{\arraycolsep}{5pt} to your document preamble. llncs sets this to 1.4\p@ (1.4pt) by default; much lower/smaller than the article default of 5\p@ (5pt). – Werner Sep 30 '13 at 19:50
1

I just wanted to prove to myself that it could be done without all those & characters and with many fewer \\ macros.

\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}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.