2

I would like to fulfill a matrix with multido (because I will have tons of matrices to write). I would like to do something like this but that does not work

\documentclass[11pt]{article}
\usepackage{amsmath,multido,ifthen}
\begin{document}
$$\begin{pMatrix}\multido{\i=1+1}{13}{%
\multido{\I=1+1}{7}{%
1\ifthenelse{\I<7}{&}{\\}}}
\end{pmatrix}$$
\end{document}

If someone has a good idea...

joaopa
  • 123
  • Do you want a 6-by-12 matrix of 1’s? – egreg Nov 16 '20 at 08:46
  • It is an example. In my work, the values could change. – joaopa Nov 16 '20 at 09:28
  • So you want to be able to specify an m-by-n matrix with constant coefficient? – egreg Nov 16 '20 at 09:44
  • Not related: In LaTeX, you should use \[ and \] and not $$. See here. – F. Pantigny Nov 16 '20 at 10:21
  • Emacs provides a very powerful feature for composing any matrix: you compose the matrix in Calc syntax: [[a b c d] [ef g h]] and call the calc-embeded function. Calc instantly converts the matrix to LaTeX syntax \begin{pmatrix} a & b & c & d \ e & f & g & h \end{pmatrix}. You need to call calc-embedded to revert to LaTeX editing. Since it is easy to repeat any entry any number of times, you can compose a matrix like the one you want very quickly. – gigiair Nov 18 '20 at 13:14

1 Answers1

3

You can use \pAutoNiceMatrix of nicematrix to construct whatever matrix you want.

\documentclass{article}
\usepackage{nicematrix}
\usepackage{ifthen}

\begin{document} [\pAutoNiceMatrix{13-13}{\ifthenelse{\arabic{iRow}<\arabic{jCol}}{1}{0}}] \end{document}

iRow is the LaTeX counter for the current row and jCol for the current column. They are defined by nicematrix.

Output of the above code

F. Pantigny
  • 40,250