Bonjour,
I would like to define a newcommand with 2 different definitions,
depending if it is used inside or outside a specific environment.
Is it possible to define a test which returns 0 if the command is used outside the environment and 1 if it is inside the environment?
Am Sun, 12 Jan 2025 12:23:52 +0100 schrieb François Patte:
Bonjour,
I would like to define a newcommand with 2 different definitions,
depending if it is used inside or outside a specific environment.
Is it possible to define a test which returns 0 if the command is used
outside the environment and 1 if it is inside the environment?
sure. lots of commands change their behaviour depending on where
they are. E.g. all language commands change inside a otherlanguage environment.
How to do it depends on the details, and also what you mean by
"inside", but e.g.
\documentclass{article}
\usepackage{etoolbox}
\newbool{myspecialenv}
\newcommand\testcommand{\ifbool{myspecialenv}{1}{0}} \AddToHook{env/minipage/begin}{\booltrue{myspecialenv}}
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 489 |
Nodes: | 16 (2 / 14) |
Uptime: | 47:00:22 |
Calls: | 9,670 |
Calls today: | 1 |
Files: | 13,719 |
Messages: | 6,170,124 |