Document Classescommand scope

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
Berticus
Posts: 8
Joined: Wed Dec 31, 2008 11:37 pm

command scope

Post by Berticus »

How do I create a command that can only be used in a certain environment? Like how \item can only be used in either \enumerate and \itemize.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

command scope

Post by phi »

Define the command in the environment initialization code, then it's only available in the environment:

Code: Select all

\newenvironment{abcdef}{\newcommand*{\ghijkl}{...}}{}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Berticus
Posts: 8
Joined: Wed Dec 31, 2008 11:37 pm

Re: command scope

Post by Berticus »

Hmm... odd. I tried that before and it kept saying that the command was already defined. Works now though.
Post Reply