I've been trying to create a function to write a bmatrix in which I pass as argument 1: initial vector position; 2: final vector position.

\foreach \i in {#1,...,#2}{

This is a simplification. Since there is a third argument where I have some values stored, and therefore I would access such data by using the variable \i. But for the purpose of the question with 1\2 should be enough.

The problem as far as I read is about "\\" and because \foreach is not expandable... I am not an expert in LaTex so I apreciate if someone can break it down simply. I read that it might work with the package "xparse".

Finally, this is my first post so any editions of the thread are welcome!

  • Welcome to the site. I think this is a duplicate of tex.stackexchange.com/q/227084/3235. – percusse Oct 2 '17 at 13:43
  • 1
    percusse thanks for your answer! That was useful! The only problem was that for printing a vector I had to use a dummy index 1: \foreach \j in {1} { \foreach \i in {#1,...,#2}{....}} – Rafael PB Oct 2 '17 at 15:48
  • @RafaelPB that comment will not help others who come to read your question. If you solved the problem provide an answer with a compilable mwe, and accept it. – user4686 Oct 2 '17 at 21:50
  • @jfbu Well like I said I managed to solve it by using a dummy index adapting the code from the link above. But indeed that's not the answer nor solution I wanted to achieve, therefore I cannot attach a code that is for a matrix of number of rows = 1 and n columns (which indeed is a vector). If I make any progress for a vector I will kindly post it, that's why I said it was it was useful but not my solution. Anyway if you know how to solve it, you can add an answer with a compilable mwe too! – Rafael PB Oct 4 '17 at 10:57

Your Answer

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

Browse other questions tagged or ask your own question.