color expansion (not colo-new related)
Hi all, I tried to seperate some style specific code to external variables. Most things work so far, but the expansion of color causes me problems. I must emphasize that this is no colo-new problem, as my code fails with the old colo-ini too. I have tried several things, but still no luck. What (expansion) magic is missing in my code? Any help is welcome. Peter \setupcolors[state=start] \newconditional\CondA \newconditional\CondB \newconditional\CondC % state dependend color \def\GetFGcolor#1#2#3#4#5{% \ifconditional\CondA \ifconditional\CondC#4 \else#5\fi \else \ifconditional\CondB#1 \else \ifconditional\CondC#2 \else#3\fi \fi \fi}% \starttext %\settrue\CondA %\settrue\CondB \settrue\CondC \setvariables[FOO][foregroundcolor=\GetFGcolor{red}{green}{blue}{lightgray}{darkgray}] \color[red]{color} is working. \edef\FGcolor{\getvariable{FOO}{foregroundcolor}} %\edef\FGcolor{\GetFGcolor{red}{green}{blue}{lightgray}{darkgray}} FGcolor=\FGcolor foregroundcolor= \color[\FGcolor]{\getvariable{FOO}{foregroundcolor}}% no color here \stoptext
Peter Rolf wrote:
Hi all,
I tried to seperate some style specific code to external variables. Most things work so far, but the expansion of color causes me problems. I must emphasize that this is no colo-new problem, as my code fails with the old colo-ini too.
I have tried several things, but still no luck. What (expansion) magic is missing in my code? Any help is welcome.
\def\GetFGcolor#1#2#3#4#5{% \ifconditional\CondA \ifconditional\CondC#4% \else#5\fi \else \ifconditional\CondB#1% \else \ifconditional\CondC#2% \else#3\fi \fi \fi} you introduce spaces btw, often its easier to remap colors \def\test{\color[whatever]{some color}} \definecolor[whatever][green] test \definecolor[whatever][red] test or to use palets or ... ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Hans Hagen schrieb:
Peter Rolf wrote:
Hi all,
I tried to seperate some style specific code to external variables. Most things work so far, but the expansion of color causes me problems. I must emphasize that this is no colo-new problem, as my code fails with the old colo-ini too.
I have tried several things, but still no luck. What (expansion) magic is missing in my code? Any help is welcome.
\def\GetFGcolor#1#2#3#4#5{% \ifconditional\CondA \ifconditional\CondC#4% \else#5\fi \else \ifconditional\CondB#1% \else \ifconditional\CondC#2% \else#3\fi \fi \fi}
you introduce spaces
yes, stupid me :)
btw, often its easier to remap colors
\def\test{\color[whatever]{some color}}
\definecolor[whatever][green] test \definecolor[whatever][red] test
or to use palets or ...
I will think about it. Thanks Hans!
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl ----------------------------------------------------------------- ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
participants (2)
-
Hans Hagen
-
Peter Rolf