Re: [NTG-context] Checking existence of a macro (control sequence) by Lua
Hello Hans, thank you for explanation and the nice how-to solution! Best regards, Lukas Because the macro actually *is* defined: as soon as tex sees \foo it reserves the name and gives it the meaning undefined, so even \undefined is defined. Anyway, that is why we have \ifdefined that does a different kind of checking. In retrospect, that is a better one, so I'll adapt that in lmtx. \starttext \let\MyMacroA\undefined \startluacode local function whatever(s) context.type("\\" .. s) context(" is " .. (tokens.defined(s,true) and "defined" or "undefined")) --% Hans' way context(" and has meaning " .. (tokens.defined(s) and "defined" or "undefined")) --% Hans' way context.par() end whatever("MyMacroA") whatever("MyMacroB") \stopluacode \stoptext \MyMacroA is defined and has meaning undefined \MyMacroB is undefined and has meaning undefined You can do this in current luatex/mkiv: if CONTEXTLMTXMODE == 0 then local d = tokens.defined local c = tokens.create function tokens.defined(s,b) if b then return d(s) else return c(s).cmd_name == "undefined_cmd" end end end Hans ___ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] Math delimiters across math alignment environments
Hi dear list! I have a question about the use of delimiters. There are commands as \left ... \right which allow delimiters of variable size, but they are usually asymmetrical. AFAIK, ConTeXt has mechanisms of the form \definemathfence[something][something][command=yes]. My question is: is it possible to make math fences work in a math alignment, e.g. \definemathfence[something][brace][command=yes] \startformula \startmathalignment[n=2,align={middle,middle}] %This won't work (I didn't expected to work, anyway) \NC \NC \something{\frac{1}{2} + \NR \NC \NC x} \NR \stopmathalignment \stopformula so that the fences are the same size? Thank you in advance. Stay safe. Jairo <3 ___ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Let chapter start on odd page and make the even page before show an image
> Am 29.05.2020 um 22:18 schrieb Aditya Mahajan : > > On Fri, 29 May 2020, Henning Hraban Ramm wrote: > >> In a similar setup I wanted to start every chapter with image and short vita >> the author and came up with the following (of course not without help from >> our wizards): >> >> >> \doifelse{\structureuservariable{image}}{}{% if image empty >> }{% >> ... >> } >> \doifnot{\structureuservariable{vita}}{}{% if vita >> ... >> }% >> }% >> }% > > You can use `\doifsomething{\structureuservariable{image}}` etc which is > slightly more readable than \doifelse{...}\empty{}{} or \doifnot{...}\empty{}. I tried several \doifs and this was the one that worked. Can’t remember the details, it’s been a while. HR ___ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Let chapter start on odd page and make the even page before show an image
On Fri, 29 May 2020, Henning Hraban Ramm wrote: In a similar setup I wanted to start every chapter with image and short vita the author and came up with the following (of course not without help from our wizards): \doifelse{\structureuservariable{image}}{}{% if image empty }{% ... } \doifnot{\structureuservariable{vita}}{}{% if vita ... }% }% }% You can use `\doifsomething{\structureuservariable{image}}` etc which is slightly more readable than \doifelse{...}\empty{}{} or \doifnot{...}\empty{}. Aditya ___ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Let chapter start on odd page and make the even page before show an image
In a similar setup I wanted to start every chapter with image and short vita the author and came up with the following (of course not without help from our wizards): \definefont[ChapterFont][Sans*default at 30pt] \startsetups normalheader % default numbers of my bodyfont are oldstyle \setupheadertexts[chapter][{\addff{normnum}\pagenumber}][{\addff{normnum}\pagenumber}][] \stopsetups \startsetups noheader \setupheadertexts[][][][] \stopsetups \startsetups bigchapter \setupalign[flushleft,hz,hanging,verytolerant,nothyphenated] \doifelse{\structureuservariable{image}}{}{% if image empty }{% \directsetup{noheader} \vbox{% {\ChapterFont\structurevariable{title}\par}% \blank[big] \externalfigure[img/\structureuservariable{image}][width=0.8\textwidth]\par } \doifnot{\structureuservariable{vita}}{}{% if vita \vfill \vbox{% {\tf\ss\structureuservariable{vita}} }% }% \page[right] \vbox{% \doifnot{\structureuservariable{subtitle}}{}{% if subtitle {\definedfont[SerifItalic*eka at 30pt]\structureuservariable{subtitle}} }% }% }% \blank[3*big] \directsetup{normalheader} \setupalign[width,hz,hanging,hyphenated]% reset alignment \stopsetups \setuphead[chapter][ page=left, number=no, command=\gobbletwoarguments, before=, after={\directsetup{bigchapter}}, style={\ChapterFont}, ] This is the result: https://www.dreiviertelhaus.de/editionka/lauf-los-buch/ (see preview images linked at the bottom) Best, Hraban ___ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Let chapter start on odd page and make the even page before show an image
Am 29.05.20 um 18:03 schrieb Aditya Mahajan: > The magic of loading and reusing them happens behind the scenes, so the > user doesn't have to worry about it. See > https://wiki.contextgarden.net/System_Macros/Key_Value_Assignments#Multi-pass_data > for more details. > > Now, suppose you wanted to use the image defined as part of > `\startchapter` as the background image of the _current_ page, then you > could access the value of the \structureuservariable. For example, > > \startchapter[title=whatever][image=filename] > > \structureuservariable{image} > > \stopchapter > > But you want to use the value of the image _before_ the start of the > chapter. So, Wolfgang is using the two-pass mechanism to store the value > of the image in the database named 'chapter` in the hash-location > `\ChapterCounter` and then retrieving it before it is defined! Thanks a lot for the clarification! juh ___ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Let chapter start on odd page and make the even page before show an image
On Fri, 29 May 2020, Jan U. Hasecke wrote: One and a half question. Why did you set \ChapterCounter explizitly and why is \ChapterCounter part of the datasetvariable? \dataset... is a high level interface for collecting two-pass data in ConTeXt. Here is a simple example: \definedataset[name] \starttext The values of the three dataset variables are: \startlines \datasetvariable{name}{hash1}{key} \datasetvariable{name}{hash2}{key} \datasetvariable{name}{hash3}{key} \stoplines Now we set the values. \setdataset[name][hash1][key=value1] \setdataset[name][hash2][key=value2] \setdataset[name][hash3][key=value3] \stoptext Note that we are using the values stored in different hash-ids before they are defined. ConTeXt stores the values in the `.tuc` file and uses them. This is what is stored in the `.tuc` file: utilitydata.job.datasets.collected={ ["name"]={ ["hash1"]={ ["key"]="value1", }, ["hash2"]={ ["key"]="value2", }, ["hash3"]={ ["key"]="value3", }, }, } The magic of loading and reusing them happens behind the scenes, so the user doesn't have to worry about it. See https://wiki.contextgarden.net/System_Macros/Key_Value_Assignments#Multi-pass_data for more details. Now, suppose you wanted to use the image defined as part of `\startchapter` as the background image of the _current_ page, then you could access the value of the \structureuservariable. For example, \startchapter[title=whatever][image=filename] \structureuservariable{image} \stopchapter But you want to use the value of the image _before_ the start of the chapter. So, Wolfgang is using the two-pass mechanism to store the value of the image in the database named 'chapter` in the hash-location `\ChapterCounter` and then retrieving it before it is defined! Aditya ___ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Let chapter start on odd page and make the even page before show an image
Hi Wolfgang, thank you very much. Amazing! Am 29.05.20 um 15:35 schrieb Wolfgang Schuster: > \definedataset [chapter] > > \startsetups [chapter:before] > > \page[yes] > > \doglobal\increment\ChapterCounter > > \doifoddpageelse > {} > {\doifsomething > {\datasetvariable{chapter}{\ChapterCounter}{image}} > {\startlayout[page] > \centerbox{\externalfigure > [\datasetvariable{chapter}{\ChapterCounter}{image}][factor=min]} > \stoplayout}} > > \stopsetups > > \setuphead > [chapter] > [page=, > beforesection=\directsetup{chapter:before}, > insidesection={\setdataset[chapter][\ChapterCounter][image=\structureuservariable{image}]}] > One and a half question. Why did you set \ChapterCounter explizitly and why is \ChapterCounter part of the datasetvariable? juh ___ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] referencing both real and user pagenumbers
Alan Bowen schrieb am 29.05.2020 um 16:53: Thank you, Wolfgang. That works nicely. One small detail left: the reference is not interactive. I have tried \setupreferencing [state=start, interaction=all] but that does not seem to be the way. minimal file: \setupinteraction[state=start] \starttext \chapter[title=My first, reference=First] \page in chapter 1 on page \getreference[realpage][First] \stoptext Create a new reference command with \definereferenceformat [getrealpage] [type=realpage] and use it (e.g. \getrealpage[First]) to show the page number. Wolfgang ___ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Let chapter start on odd page and make the even page before show an image
Jan U. Hasecke schrieb am 29.05.2020 um 15:10: Am 29.05.20 um 12:45 schrieb Wolfgang Schuster: juh schrieb am 29.05.2020 um 10:29: Dear all, with your help I can colorize the empty even page right before a chapter starts on the odd page. The mwe below shows it. Now I would like to redefine the contents of the left page on the fly in the text so that I could place images on this page. I thought that I could get a simple solution by inserting a TEXpage as even page, but this does not work for several reasons. First a TEXpage is not counted correctly like a normal page. And secondly I found now way to put it on the even page. So what I really want to achieve is a way to redefine this setups at some point in the text to insert eg. a picture on the even page before a chapter. \startsetups [chapter:before] \doifoddpageelse {} {\pushbackground[page] \setupbackgrounds[page][background=color,backgroundcolor=blue,] \page[empty,right] \popbackground} \stopsetups As you see the image is not in the right place and of course the pagenumbering is wrong. Use \startTEXpage[pagestate=start] to increase the page number with TEX pages. Thanks for this hint. I want that one of these blue pages shows an image. Is this possible? Yes but there are different ways for different requirements. - Do you you have a picture before *every* chapter? No, the additional image page shall appear only if the last chapter ends on an odd page. Then I need the image page to push the new chapter to the next odd page. - Do you use full page images? - Are the images cropped to fit the page dimension, stretched or centered with margins? For this usecase images are blown up and cropped to fit the page dimension including the bleed. \setuppagenumbering [alternative=doublesided] \setupexternalfigures [location=default] \definedataset [chapter] \startsetups [chapter:before] \page[yes] \doglobal\increment\ChapterCounter \doifoddpageelse {} {\doifsomething {\datasetvariable{chapter}{\ChapterCounter}{image}} {\startlayout[page] \centerbox{\externalfigure [\datasetvariable{chapter}{\ChapterCounter}{image}][factor=min]} \stoplayout}} \stopsetups \setuphead [chapter] [page=, beforesection=\directsetup{chapter:before}, insidesection={\setdataset[chapter][\ChapterCounter][image=\structureuservariable{image}]}] \setupexternalfigure[location=default] \starttext \startchapter [title={Tufte}] [image=cow] \dorecurse{4}{\samplefile{tufte}} \stopchapter \startchapter [title={Knuth}] [image=mill] \dorecurse{8}{\samplefile{knuth}} \stopchapter \startchapter [title={Zapf}] [image=hacker] \dorecurse{6}{\samplefile{zapf}} \stopchapter \stoptext Wolfgang ___ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Let chapter start on odd page and make the even page before show an image
Am 29.05.20 um 12:45 schrieb Wolfgang Schuster: > juh schrieb am 29.05.2020 um 10:29: >> Dear all, >> >> with your help I can colorize the empty even page right before a >> chapter starts >> on the odd page. The mwe below shows it. >> >> Now I would like to redefine the contents of the left page on the fly >> in the text >> so that I could place images on this page. >> >> I thought that I could get a simple solution by inserting a TEXpage as >> even >> page, but this does not work for several reasons. First a TEXpage is >> not counted >> correctly like a normal page. And secondly I found now way to put it >> on the >> even page. >> >> So what I really want to achieve is a way to redefine this setups at >> some point >> in the text to insert eg. a picture on the even page before a chapter. >> >> \startsetups [chapter:before] >> \doifoddpageelse >> {} >> {\pushbackground[page] >> \setupbackgrounds[page][background=color,backgroundcolor=blue,] >> \page[empty,right] >> \popbackground} >> \stopsetups >> >> As you see the image is not in the right place and of course the >> pagenumbering >> is wrong. > Use \startTEXpage[pagestate=start] to increase the page number with TEX > pages. Thanks for this hint. >> I want that one of these blue pages shows an image. Is this possible? > Yes but there are different ways for different requirements. > > - Do you you have a picture before *every* chapter? No, the additional image page shall appear only if the last chapter ends on an odd page. Then I need the image page to push the new chapter to the next odd page. > - Do you use full page images? > - Are the images cropped to fit the page dimension, stretched or > centered with margins? For this usecase images are blown up and cropped to fit the page dimension including the bleed. juh ___ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] referencing both real and user pagenumbers
Alan Bowen schrieb am 29.05.2020 um 00:13: I have a collection of papers printed previously that are to go into a single volume so that, while the papers retain their original pagination and internal cross-referencing, they are also paginated continuously. I have managed to do this using userpagenumbers for the individual papers and realpagenumbers for the volume as a whole. Re cross-referencing: \at and \in etc. return userpagenumbers (which I need). But I also need them (or something like them) to return realpagenumbers as well. Is there a way to do this? \getreference [realpage] [] Wolfgang ___ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Let chapter start on odd page and make the even page before show an image
juh schrieb am 29.05.2020 um 10:29: Dear all, with your help I can colorize the empty even page right before a chapter starts on the odd page. The mwe below shows it. Now I would like to redefine the contents of the left page on the fly in the text so that I could place images on this page. I thought that I could get a simple solution by inserting a TEXpage as even page, but this does not work for several reasons. First a TEXpage is not counted correctly like a normal page. And secondly I found now way to put it on the even page. So what I really want to achieve is a way to redefine this setups at some point in the text to insert eg. a picture on the even page before a chapter. \startsetups [chapter:before] \doifoddpageelse {} {\pushbackground[page] \setupbackgrounds[page][background=color,backgroundcolor=blue,] \page[empty,right] \popbackground} \stopsetups Here comes the not so mwe: %% start mwe \setuplayout [ location=doublesided ] \setuppagenumbering[alternative=doublesided] \definepagebreak [chapter] [footer,yes,header,footer,right] \startsetups [chapter:before] \doifoddpageelse {} {\pushbackground[page] \setupbackgrounds[page][background=color,backgroundcolor=blue,] \page[empty,right] \popbackground} \stopsetups \setuphead [chapter] [ page=yes, before=\directsetup{chapter:before}, ] \setupexternalfigure[location=default] \starttext \startchapter [title={foo}] \dorecurse{2}{\input tufte \par} \stopchapter \startchapter [title={foo2}] \dorecurse{6}{\input tufte \par} \stopchapter \startchapter [title={bar}] \input knuth \startTEXpage \externalfigure[cow.pdf][height=\paperheight,width=\paperwidth] \stopTEXpage \stopchapter \startchapter [title={baz}] \input knuth \stopchapter \stoptext %% stop mwe As you see the image is not in the right place and of course the pagenumbering is wrong. Use \startTEXpage[pagestate=start] to increase the page number with TEX pages. I want that one of these blue pages shows an image. Is this possible? Yes but there are different ways for different requirements. - Do you you have a picture before *every* chapter? - Do you use full page images? - Are the images cropped to fit the page dimension, stretched or centered with margins? - ... Wolfgang ___ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] mtxrun exit code
On Fri, 29 May 2020 11:20:22 +0200 Hans van der Meer wrote: > I am producing a series of files in a shell script with mtxrun > --autogenerate --script context input Doing exit mtxrun... shows > there is no exit number to test in the shell The exit code from mtxrun works here: printf '%s\n' '\bye' > good.tex && mtxrun --autogenerate --script context good.tex; echo $? 0 printf '%s\n' '\by' > bad.tex && mtxrun --autogenerate --script context bad.tex; echo $? 1 Marco ___ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] mtxrun exit code
I am producing a series of files in a shell script with mtxrun --autogenerate --script context input Doing exit mtxrun... shows there is no exit number to test in the shell, or to ste a shell variable to that value. I can set a global macro \ExitStatus to an exit value depending on success or failure, pass that on to mtxrun as exit statusd and test that in the script. For example: \starttext \xmlprocessbuffer{notes}{notes}{} \doif{\ExitStatus}{notok}{"let mtxrun return value 1 as error in UNIX"} \stoptext After that it would be possible in the shell script to delete the pdf produced, what is my intention in this case. Is this an option or is there presently another (standard) procedure to communicate from ConTeXt to the shell. dr. Hans van der Meer ___ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] Let chapter start on odd page and make the even page before show an image
Dear all, with your help I can colorize the empty even page right before a chapter starts on the odd page. The mwe below shows it. Now I would like to redefine the contents of the left page on the fly in the text so that I could place images on this page. I thought that I could get a simple solution by inserting a TEXpage as even page, but this does not work for several reasons. First a TEXpage is not counted correctly like a normal page. And secondly I found now way to put it on the even page. So what I really want to achieve is a way to redefine this setups at some point in the text to insert eg. a picture on the even page before a chapter. \startsetups [chapter:before] \doifoddpageelse {} {\pushbackground[page] \setupbackgrounds[page][background=color,backgroundcolor=blue,] \page[empty,right] \popbackground} \stopsetups Here comes the not so mwe: %% start mwe \setuplayout [ location=doublesided ] \setuppagenumbering[alternative=doublesided] \definepagebreak [chapter] [footer,yes,header,footer,right] \startsetups [chapter:before] \doifoddpageelse {} {\pushbackground[page] \setupbackgrounds[page][background=color,backgroundcolor=blue,] \page[empty,right] \popbackground} \stopsetups \setuphead [chapter] [ page=yes, before=\directsetup{chapter:before}, ] \setupexternalfigure[location=default] \starttext \startchapter [title={foo}] \dorecurse{2}{\input tufte \par} \stopchapter \startchapter [title={foo2}] \dorecurse{6}{\input tufte \par} \stopchapter \startchapter [title={bar}] \input knuth \startTEXpage \externalfigure[cow.pdf][height=\paperheight,width=\paperwidth] \stopTEXpage \stopchapter \startchapter [title={baz}] \input knuth \stopchapter \stoptext %% stop mwe As you see the image is not in the right place and of course the pagenumbering is wrong. I want that one of these blue pages shows an image. Is this possible? Thanks for your help. juh -- Autoren-Homepage: . http://literatur.hasecke.com Satiren & Essays: . http://www.sudelbuch.de Privater Blog: http://www.hasecke.eu Netzliteratur-Projekt: http://www.generationenprojekt.de signature.asc Description: PGP signature ___ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] About the use of command handlers
On 5/29/2020 6:29 AM, Jairo A. del Rio wrote: Hello list! I was reading the following: https://wiki.contextgarden.net/Style_Alternatives I wanted to figure out how to make a simple module. However, there's a point in the example below which I don't understand % macros=mkvi \startmodule[look] \unprotect \writestatus{loading}{ConTeXt User Module / look} \installnamespace {look} \installcommandhandler \look {look} \look \appendtoks \setuevalue{\currentlook}{\do_look{\currentlook}} \to \everydefinelook \unexpanded\def\do_look#id{% \edef\currentlook{#id}% \dosingleempty\do_do_look% } \def\do_do_look[#parms]#content{% \begingroup \iffirstargument\setupcurrentlook[#parms]\fi %This handles style and color \uselookstyleandcolor\c!style\c!color% #content% \endgroup% } \protect %% \stopmodule What have I to do if, instead of "color" or "style", I want to use another keyword, as "dummy" and get its value? Something like \definelook[lol][dummy = blabla] \lol{words} %e.g. words \emph{blabla} or something similar so "lol" is a word, a number or whatever. I've read something about command handlers, but I'm having a hard time trying to understand them. Thank you in advance! % macros=mkvi \unprotect \installnamespace {look} \installcommandhandler \look {look} \look \appendtoks \setuevalue{\currentlook}{\module_look_do{\currentlook}} \to \everydefinelook \unexpanded\def\module_look_do#id% {\edef\currentlook{#id}% \dosingleempty\module_look_do_do} \def\module_look_do_do[#parms]#content% {\dontleavehmode \begingroup \iffirstargument \setupcurrentlook[#parms]% \fi \doifsomething{\lookparameter{title}} {\begingroup \uselookstyleandcolor\c!headstyle\c!headcolor \lookparameter{title}% \lookparameter{separator}% \endgroup}% \uselookstyleandcolor\c!style\c!color #content% \endgroup} \protect \starttext \setuplook[separator={: }] \definelook[lol][color=red,headcolor=green] \lol[title=blabla]{words} \stoptext - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] LMTX: different output if dots are used in the file name
On 5/28/2020 8:31 PM, Marco Patzer wrote: On Thu, 28 May 2020 18:18:51 +0200 Hans Hagen wrote: MkIV (everything's predictable and fine): 10.10.10.tex → 10.10.10.pdf 10.10.11.tex → 10.10.11.pdf 11.10.11.tex → 11.10.11.pdf LMTX: 10.10.10.tex → 10.10 (not even a PDF suffix) 10.10.11.tex → 10.10 (file 10.10 is over-written) 11.10.11.tex → 11.10 (no suffix) MkIV is way more predictable and consistent in that regard. I'll look at it but not today ... first I need to play with some other (neat) stuff and run tests. OK, thanks. No hurry. The production projects run on some oldish 2019 MkIVs anyway. I'm trying to get my feet wet with lmtx and run it on some projects to check how usable and compatible it is. It should be compatible, although at some point there will be functionality that is only in lmtx. Okay, metapost is an exception, because there is a lot in lmtx that is not in mkiv, but that's a separate subsystem anyway. Hans - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Unicode chars and \insertpages (Win7)
On 5/28/2020 9:49 PM, Pablo Rodriguez wrote: Dear list, I have the following sample: \startext \insertpages[ξ_file.pdf] \stoptext Using latest on Linux, it works perfectly fine. On Windows (I’m still on Win7), it doesn’t work unless I replace "ξ" with an ASCII character. Could this be fixed or is it really a limiatation of Windows? It depends on the version and engine. For luatex we also depends on the interfacing that the texlive ecosystem provides. As Akira mentions, there have been some developments in that area but I didn't test that yet (no files with utf names here) but I trust his (always done) testing of context. That will trickle into future binaries (which is somewhat tricky as we have experimental as well as current). In luametatex things are different. There all windows specific operations have wide-character support, that is, the utf8 goes via utf16 and codepages and such: filenames, environment variables, command line arguments, whatever. That said: I never use non-ascii non-spacy names ... it's the most portable. Hans - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Checking existence of a macro (control sequence) by Lua
On 5/28/2020 11:24 PM, cont...@vivaldi.net wrote: Hello, one more question - why macros \Undefined and \DoNothing show "defined" although I (tried to) undefine them? \starttext \def\MyMacro{Ahoj} \def\MyMac#1#2{Something} \def\Undefined{} \let\Undefined\undefined \def\DoNothing{} \let\DoNothing\donothing \startluacode local str = { [true] = "defined", [false] = "undefined" } local function whatever(s) context.type("\\" .. s) context(" is " .. (tokens.defined(s) and "defined" or "undefined")) --% Hans' way context(" and is " .. str[token.is_defined(s)] .. ".") --% Henri's way context.par() end whatever("MyMacro") whatever("MyMacroD") whatever(" ") whatever("-") whatever("Undefined") whatever("DoNothing") \stopluacode %\Undefined % Causes "! Undefined control sequence" \stoptext Gives: " \MyMacro is defined and is defined. \MyMacroD is undefined and is undefined. \ is defined and is defined. \- is defined and is defined. \Undefined is defined and is defined. \DoNothing is defined and is defined. " Because the macro actually *is* defined: as soon as tex sees \foo it reserves the name and gives it the meaning undefined, so even \undefined is defined. Anyway, that is why we have \ifdefined that does a different kind of checking. In retrospect, that is a better one, so I'll adapt that in lmtx. \starttext \let\MyMacroA\undefined \startluacode local function whatever(s) context.type("\\" .. s) context(" is " .. (tokens.defined(s,true) and "defined" or "undefined")) --% Hans' way context(" and has meaning " .. (tokens.defined(s) and "defined" or "undefined")) --% Hans' way context.par() end whatever("MyMacroA") whatever("MyMacroB") \stopluacode \stoptext \MyMacroA is defined and has meaning undefined \MyMacroB is undefined and has meaning undefined You can do this in current luatex/mkiv: if CONTEXTLMTXMODE == 0 then local d = tokens.defined local c = tokens.create function tokens.defined(s,b) if b then return d(s) else return c(s).cmd_name == "undefined_cmd" end end end Hans - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___