Search code examples
latexoverleafnewenvironment

Using numbers as input in \newenvironment LaTeX


I'm trying to make an environment that builds a column vector, and that takes as input the scale factor of the distancing between the rows:

\newenvironment{VEC}[1]{\begin{Bmatrix}\renewcommand{\arraystretch}{#1}}
                       {\end{Bmatrix}} 

I know that the \newenvironment command accepts as input only strings, so I tried with \value{#1} having no successfull result. Any help would be appreciated.


Solution

  • Nothing to do with newenvironment or arguments, you just need to switch the order:

    \documentclass{article}
    \usepackage{mathtools}
    
    \newenvironment{VEC}[1]{\renewcommand{\arraystretch}{#1}\begin{Bmatrix}}
                           {\end{Bmatrix}} 
    
    
    \begin{document}
    
    \[
    \begin{VEC}{3}
    4\\
    6\\
    \end{VEC}
    \]
    
    \end{document}