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

5
  • Do you want a 6-by-12 matrix of 1’s? Commented Nov 16, 2020 at 8:46
  • It is an example. In my work, the values could change. Commented Nov 16, 2020 at 9:28
  • So you want to be able to specify an m-by-n matrix with constant coefficient? Commented Nov 16, 2020 at 9:44
  • Not related: In LaTeX, you should use \[ and \] and not $$. See here. Commented Nov 16, 2020 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. Commented Nov 18, 2020 at 13:14

1 Answer 1

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

1
  • The answer is fantastic....for my humble opinion ...For me it is strange that it was with 0 score. Commented Nov 16, 2020 at 21:15

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.