Post by François PatteI use xelatex. So, as far as I understand your explanations (I am not
conversant with programmation...), using ¬, _, etc. is possible for my
purpose
Yes. ;-)
Post by François Patteand as I said my environment construction works as I wish.
Yes. But be aware that none of the tokens within the arguments of your
command \newenvironment{toto}{...}{...} may be defined \outer.
So probably making the characters _ and ¬ active before doing
\newenvironment is not enough but you probably also need to ensure that
these active characters and the one-letter control-sequences \~ and \¬
and \_ also are not already defined \outer before defining the
environment by doing the call to \newenvironment.
Post by François PatteWhat I am not sure about is about the change of catcode --- which works
--- but is it the correct way to do?
As long as at the time of defining the environment "toto"/at the time of
doing the call to \newenvironment{toto}{...}{...} the two
active-character-tokens _ and ¬ and the three one-letter
control-sequence-tokens \~ and \¬ and \_ are not already defined \outer,
your way of doing things is a correct way of doing things.
These five tokens occur within the arguments of the call to the macro
\newenvironment while \newenvironment is a macro and arguments of macros
and the like cannot contain tokens that are defined \outer.
I provided \MyActivate only so that you don't need to also change
category codes of _ and ¬ before (and after) defining the environment
"toto" because in your initial posting you indicated that you don't like
this redundancy.
The gist is that at the time of defining \MyActivate the tilde, ~, is
active. So any tilde that goes into the definition of \MyActivate is an
active character token.
So at the time of carrying out \MyActivate, after assigning --- via the
directive "\lccode`\~ = ...", which comes from the definition of
\MyActivate --- to the tilde a lowercase-code-number which equals the
number of the character in TeX's internal-character-encoding scheme
whose active pendant you wish to obtain, the directive "\lowercase{~}",
which also comes from the definition of \MyActivate, yields the active
pedant of that character.
Post by François PatteAnyway your newcommand "MyActivate" does the job; it is easier than my
construction, is it safer too?
I think the code in my first posting is a little less safe than your
construction.
I think the code in my second posting is a little safer than your
construction.
The restrictions at the time of defining the environment "toto" and at
the time of carrying out the environment "toto" are slightly different:
With your code, at the time of defining the environment "toto", the
active characters _ and ¬ and the one-letter control-sequences \¬ and \_
and \~ are not allowed to be defined \outer.
With the code of my first posting, at the time of defining the
environment "toto", the one-letter control-sequences \~ and \¬ and \_
and active ~ are not allowed to be defined \outer, but the active
characters _ and ¬ are allowed to be \outer. The active character ~ also
is not allowed to be \outer at the time of carrying out an instance of
the environment "toto"!
With the code of my second posting, at the time of defining the
environment "toto", the one-letter control-sequences \~ and \¬ and \_
are not allowed to be defined \outer, but the active characters _ and ¬
and ~ are allowed to be \outer. The active character ~ also is allowed
to be \outer at the time of carrying out an instance of the environment
"toto".
I provided \MyActivate only so that you don't need to also change
category codes of _ and ¬ before (and after) defining the environment
"toto" because in your initial posting you indicated that you don't like
this redundancy.
Post by François PatteI don't understand your example: it produce no output and stops ar every
"\showthe\catcode`\"
How to use it?
The environment "toto" is used as
\begin{toto}
...
<stuff where toto's catcode-settings and toto's definitions of active
characters are in effect>
...
\end{toto}
In my example \show and \showthe are used so that you can check/compare
the settings in effect before and after the toto-environment/to the
settings in effect inside the toto-environment:
\show writes the current meaning of the token that follows \show both to
the screen/console/window of the shell or command-prompt and to the
.log-file. The word "meaning" has a special meaning in TeX-jargon. The
"meaning" of a token is information about what that token is - whether
it is a character token. If so, what category. Whether it is a control
sequence token. If so: Is it a primitive? Is it a register? Is it a
\toksdef/\chardef/whatsoeder-def-thingie? Is it a macro? In case it is a
macro, the definition's parameter text and the definition's replacement
text are written also.
Compilation is intercepted until at the ?-prompt you press the return
key. After pressing the return key, compilation is continued. This way
you have time to look at what is written by \show to the screen/to the
console/to the window where your shell or command-prompt is displayed.
\showthe needs to be followed by a token denoting a register or a
parameter or by something else whose current value can be accessed via
\the. \showthe writes that current value in the same way in which \show
writes the current meaning.
(Whether interception of compilation and the need of pressing the
retun key for continuing occurs actually depends on the
interaction-mode, i.e., on whether TeX is run in
errorstopmode/scrollmode/nonstopmode/batchmode.
But in any case the .log-file can be inspected.)
My example in the preamble of the document defines an environment "toto"
so that (only) during carrying out an instance of that environment
category codes of _ and ¬ and ~ are changed and active _ and active ¬
are redefined.
With my example, after the preamble, within the document-environment,
the "toto"-environment is used. Outside and inside the
"toto"-environment some \showthe- and \show-commands are issued so that
on the screen/console/window of the shell or command-prompt and in the
.log-file you can see and compare what settings are in effect
before/inside/after that environment:
Within the document-environment, before calling an instance of the
environment "toto", i.e., outside any environment "toto" - via \showthe
the current category codes of _ and ¬ and ~ and via \show the current
meanings/definitions of _ and ¬ and ~ are displayed on the screen/
console/window the shell shell or command-prompt and are written to the
.log-file. So by looking at what was written you can see the settings in
effect at the time of carrying out \showthe/\show.
Then via \begin{toto} an instance of the environment "toto" is started.
(Be aware that an instance of an environment like "toto", i.e.,
\begin{toto}...\end{toto} also forms a local scope. This is because the
macro \begin beneath other things starts a local scope and the macro
\end beneath other things closes the local scope.)
Within that instance of the environment "toto"/within the local scope
formed by that instance of the environment "toto" the category-codes of
_ and ¬ and ~ are changed and active _ and active ¬ are redefined.
Inside that instance of the environment "toto"/within the local scope
formed by that instance of the environment "toto" \showthe and \show are
used again for again displaying on the screen/console/window of the
shell or command-prompt and writing to the .log-file the current
category codes of _ and ¬ and ~ and via \show again displaying on the
screen/console/window of the shell or command-prompt and writing to the
.log-file the current meanings/definitions of _ and ¬ and ~.
After \end{toto} / when the local scope formed by that instance of the
environment "toto" is closed, changes to the category codes of _ and ¬
and ~ and meanings of active _ and ¬ and ~ are not in effect any more.
Via \showthe the current category codes of _ and ¬ and ~ and via \show
the current meanings/definitions of _ and ¬ and ~ are displayed on the
screen/console/window of the shell or command-prompt and writing to the
.log-file again.
I interspersed this with \message{^^JBefore toto^^J} /
\message{^^JWithin toto^^J} / \message{^^JAfter toto^^J} so that when
looking at the output displayed on the screen/console/window of the
shell or command-prompt and/or written to the .log-file, you can see
more easily which settings for the category codes of the characters _
and ¬ and ~ and which meanings for the characters _ and ¬ and ~ were
effective before/within/after the environment "toto" and thus by looking
at the output displayed on the screen/console/window of the shell or
command-prompt and/or written to the .log-file can trace and verify that
the changes to category codes and (re)definitions of active characters
done by the environment "toto" indeed are effective only within the
environment "toto".
Sincerely
Ulrich