TransWikia.com

Using def inside mathematical environment

TeX - LaTeX Asked by Concept7 on July 31, 2020

I have the following:

documentclass{article}

usepackage{amsmath}
usepackage{witharrows}


begin{document}
    
defvar{x}
    
[
    begin{WithArrows}
        varvar&=defvar{y}varvar
        var
    end{WithArrows}
]

end{document}

I wanted to change the var value to y but it only works for the var immediatly after the def and on that line.

The result of the compilation is:

enter image description here

And I’m wondering why the var on the second line is not affected by the instruction above.

One Answer

Change def to gdef, to make the definition global. Inside the environment, each subline is its own group, so the def does not carry over outside of it.

documentclass{article}

usepackage{amsmath}
usepackage{witharrows}


begin{document}
    
defvar{x}
    
[
    begin{WithArrows}
        varvar&=gdefvar{y}varvar
        var
    end{WithArrows}
]

end{document}

enter image description here

Correct answer by Steven B. Segletes on July 31, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP