TransWikia.com

Apply command to this area only

TeX - LaTeX Asked on July 11, 2021

What is the syntax for apply command on specific area only?

What I mean is something like:

newcommand{somevariable}{3}
somevariable %3
-- some block which doesn't effect the outsize --
renewcommand{somevariable}{5}
somevariable %5
-- end of the block --
somevariable %3

I don’t want to use renewcommand agian outside the block.
Is there a way to do it? Thank you!

One Answer

Definitions with newcommand (along with most settings, such as font settings other than latex counter settings) are local so scoped by andy brace group {....} or any environment begin{..} .... end{..}

This typesets 3 5 3

documentclass{article}

begin{document}

newcommand{somevariable}{3}
somevariable %3

{
renewcommand{somevariable}{5}
somevariable %5
}

somevariable %3

end{document}

Answered by David Carlisle on July 11, 2021

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