# \setcounter in latex block to typeset matrices with more than 10 columns

I typesetting a matrix with 12 columns in a latex block in org-mode and discovered I couldn't do it by default. Reading this question on the TeX stack exchange site made me think that I could just place \setcounter{MaxMatrixCols}{20} as the first command in the block. This didn't work. However, it does export correctly. Is there a way to place this option in my init.el so I don't have to remember this every time?

 #+BEGIN_LATEX
\setcounter{MaxMatrixCols}{20}
\begin{equation*}
\mathbf{X} =
\begin{pmatrix}
1 & 1 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\
1 & 1 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\
1 & 1 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\
1 & 1 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\
1 & 1 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\
1 & 1 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\
1 & 1 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\
1 & 1 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\
\end{pmatrix}
\end{equation*}
#+END_LATEX

• Can you also post the generated LaTeX code? Maybe begin_latex macro generates an environment where this command can't be used? What is the exact error you are getting? (It will appear in the *Org PDF ... output* buffer (can't remember the exact name). – wvxvw Mar 24 '15 at 15:01
• Your example works on my system with org v8.2 and v8.3beta and Texlive 2014. – rasmus Mar 24 '15 at 15:52
• BTW: You can also write the matrix as (eval it): (insert "\n#+LATEX_HEADER: \\setcounter{MaxMatrixCols}{20}\n#+ATTR_LATEX: :environment pmatrix :mode math :math-prefix \\mathbf{X}=\n | 1 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |\n | 1 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |\n | 1 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |\n | 1 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |\n | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |\n | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |\n | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |\n | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |")` – rasmus Mar 24 '15 at 16:00
• I discovered that it does work in the outputted PDF includes the matrix, the live preview feature doesn't know about it. – wdkrnls Mar 24 '15 at 16:20