Search found 4 matches

by jlettvin
Wed Oct 17, 2018 8:24 pm
Forum: Math & Science
Topic: How do I use a loop to generate a set of related control sequences
Replies: 5
Views: 3843

How do I use a loop to generate a set of related control sequences

So, to be brutally clear,
are you saying that my code is a competent solution in this context?
If so, thank you for your explanations.
Otherwise, I need an alternative that would meet with approval.
by jlettvin
Tue Oct 16, 2018 6:16 pm
Forum: Math & Science
Topic: How do I use a loop to generate a set of related control sequences
Replies: 5
Views: 3843

How do I use a loop to generate a set of related control sequences

Hi Stefan,

I have so many questions, it is hard to limit myself to the few that are most challenging.
In this case, I replaced xdef with gdef (which I had tried earlier) and this code failed.
I went back to xdef and it worked again. If you have a better alternative to xdef I will try it.
But, for ...
by jlettvin
Mon Oct 15, 2018 8:34 pm
Forum: Math & Science
Topic: How do I use a loop to generate a set of related control sequences
Replies: 5
Views: 3843

How do I use a loop to generate a set of related control sequences

The answer was to use xdef. :roll:

% xdef defines the new control sequence in the global dictionary.
\foreach \Z/\atom/\name/\charge/\ions in \Element{
\expandafter\xdef\csname
ion\trimspaces\atom\endcsname{${\trimspaces\atom}^{\trimspaces\charge}$}
\immediate\write16{def{ion\trimspaces\atom ...
by jlettvin
Mon Oct 15, 2018 12:11 am
Forum: Math & Science
Topic: How do I use a loop to generate a set of related control sequences
Replies: 5
Views: 3843

How do I use a loop to generate a set of related control sequences

This loop works beautifully for extracting data from the \Element text block.
However, the function definitions made within the loop disappear when the loop finishes.
Is there a way to make the newly defined control sequences permanent globally?

\def\Element{
1 / H / Hydrogen / + / 1+,
11 / Na ...