Re: [NTG-context] letters in context mkiv
On 07/31/2017 12:48 PM, r.ermers@hccnet.nl wrote:
Dear Contex’ers,
This morning I have been experimenting with the solutions suggested by Thomas and Wolfgang.
Thomas’ solution works, it produces two distinct letters, yet the address is probably on another layer. This means that it is not shifted to the right, at least not with the command (\setupletterlayer[address]), so that it will be visible through the envelope window.
With Wolfgang’s solution the address is moved to its desired place, and the letter text is printed as well.
However, inserting a text (by means of \input) is problematic (see pdf), with or without \relax.
Hi Robert, it isn’t the use of \input. The problem is that you only get one level of expansion. If you add \input directly to letter:section:content, such as in: \startsetups[letter:section:content] \input knuth \relax \stopsetups You will have \input expanded. But in the text itself \TeX\ and large||scale won’t be expanded. I have no idea why this happens. And I don’t know how to fix it. Maybe Wolfgang knows what is happening here. If I had to guess, it might be that \directsetups only allows a level of expansion. But I may be plainly wrong. A way to avoid the issue is to add the letter content directly to the \startsetups[letter:section:context]. And rememmber that you have only one level of expansion. Just in case it might help, Pablo -- http://www.ousia.tk
Dear Pablo, Thank you for your insightful remarks. I tried your suggestions. As you predicted, the Knuth tex is processed when put here, without using the buffer mechanism. \startsetups[letter:section:content] \input knuth \relax \stopsetups Yet any codes (\TeX\) are not. Nevertheless, I consider this a step forward. In the same way, my letter texts, which contain regular codes, such as \startitemize … \stopitemize and {\bf bold} are not processed properly. The whole thing is much more complicated than I thought. Wolfgang already mentioned that the letter module is not specifically equipped for xml. Would it be wise to perhaps follow the path set out by Thomas? In that case there should be a way to shift the address. Regards, Robert
On 07/31/2017 06:58 PM, r.ermers@hccnet.nl wrote:
Dear Pablo,
Thank you for your insightful remarks. I tried your suggestions. As you predicted, the Knuth tex is processed when put here, without using the buffer mechanism.
Dear Robert, it wasn’t a prediction, I tested it myself ;-).
Yet any codes (\TeX\) are not.
Nevertheless, I consider this a step forward. In the same way, my letter texts, which contain regular codes, such as \startitemize … \stopitemize and {\bf bold} are not processed properly.
The whole thing is much more complicated than I thought. Wolfgang already mentioned that the letter module is not specifically equipped for xml.
What I would like to know is how one can get full expansion (I experienced your issue before in another scenario). Or at least, I want to know why only the first level of commands is expanded. (An \expandafter or something like that?)
Would it be wise to perhaps follow the path set out by Thomas? In that case there should be a way to shift the address.
You may use layers to locate the address where you want. Or even you may use an extra margin (it cannot be that hard). Just in case it helps, Pablo -- http://www.ousia.tk
On 31. Jul 2017, at 18:58, r.ermers@hccnet.nl wrote:
Would it be wise to perhaps follow the path set out by Thomas? In that case there should be a way to shift the address.
What efforts have you made to “shift the address”? Here is one way: \startbuffer[participants] <contacts> <contact class='participant' label='Hendriks'> <formalname>Hendriks</formalname> <informalname>Karel</informalname> <prefix>mr.</prefix> <initials>K.</initials> <city>Arnhem</city> <address> <p>Mr. K. Hendriks</p> <p>Grotestraat 5</p> <p>1234 BB Arnhem</p> </address> <kix>1234bb5</kix> </contact> <contact class='participant' label='Janssen'> <formalname>Janssen</formalname> <informalname>Piet</informalname> <initials>P.</initials> <prefix>mr.</prefix> <city>Nijmegen</city> <address> <p>Mr. P. Janssen</p> <p>Kortestraat 8</p> <p>1234 AA Nijmegen</p> </address> <kix>1234aa8</kix> </contact> </contacts> \stopbuffer \startxmlsetups xml:setups \xmlsetsetup{#1}{contacts|contact|p}{xml:*} \stopxmlsetups \xmlregistersetup{xml:setups} \startxmlsetups xml:contacts \xmlflush{#1} \stopxmlsetups \startxmlsetups xml:p \xmlflush{#1}\par \stopxmlsetups \startxmlsetups xml:contact \setlayer[address][x=20mm,y=40mm]{\framed[width=74mm,height=35mm,frame=on,offset=2mm,align=right]{\ignorespaces\xmltext{#1}{/address}}} \strut \blank [35mm] Subject: your life in \xmltext{#1}{/city} \blank [2*line] Dear \xmltext{#1}{/prefix} \xmltext{#1}{/formalname}, \blank [line] \input knuth \relax Kind regards \blank [line] X \page \stopxmlsetups \setuppagenumbering [state=stop] \definelayer[address][width=\paperwidth,height=\paperheight] \setupbackgrounds [page][background={address}] \starttext \xmlprocessbuffer{main}{participants}{} \stoptext I still don’t see you trying to learn a new language one step at a time. Thomas
Hi Thomas, Thanks for your new suggestions. As a matter of fact, I yesterday found the following suggestion (http://wiki.contextgarden.net/Layers): \definelayer[AddressBg] [location={right,top}, y=6cm, x=12cm, color=red, style=\ss\tfa]. I used this in the sample suggested by you yesterday. The address actually moves to the desired place! However, the color and style instructions (\ss\tfa) have no effect. I tried to solve that, as a first step, by putting \ss before the \xmlall instruction: \startxmlsetups xlm:contact \setlayer[AddressBg] {\framed[width=55mm,height=30mm, align=right,background=color, backgroundcolor=lightgray]{\ss\xmlall{#1}{/address}}} \strut ... \stopxmlsetups This works (see pdf), but there are probably other and better ways. Another persisting problem is that the commands are still not ‘expanded’ (see Pablo’s remarks). According to Pablo for some reason there is only one expansion level. This means that after an \input command, all other commands are not expanded (see pdf). This also applies to your suggestions (see pdf brieven2mkiv5.pdf): in the Knuth sample text the only command \TeX\, is not expanded either. Regards, Robert \startxmlsetups xml:setups \xmlsetsetup{#1}{contacts|contact|p}{xml:*} \stopxmlsetups \xmlregistersetup{xml:setups} \startxmlsetups xml:contacts \xmlflush{#1} \stopxmlsetups \startxmlsetups xml:p \xmlflush{#1}\par \stopxmlsetups \startxmlsetups xml:contact \setlayer[address][x=20mm,y=40mm]{\framed[width=74mm,height=35mm,frame=on,offset=2mm,align=right]{\ignorespaces\xmltext{#1}{/address}}} \strut \blank [35mm] Subject: your life in \xmltext{#1}{/city} \blank [2*line] Dear \xmltext{#1}{/prefix} \xmltext{#1}{/formalname}, \blank [line] % \input knuth \relax This is a {\bf bold} test. \TeX\ \startitemize \item item \item item \stopitemize \input brieftekst-test.tex \relax \par %this \par is needed, for the last word of the file merges with Kind regards. Kind regards \blank [line] X \page \stopxmlsetups \setuppagenumbering [state=stop] \definelayer[address][width=\paperwidth,height=\paperheight] \setupbackgrounds [page][background={address}] \starttext \xmlprocessbuffer{main}{participants}{} \stoptext
Op 31 jul. 2017, om 23:57 heeft Schmitz Thomas A.
het volgende geschreven: On 31. Jul 2017, at 18:58, r.ermers@hccnet.nl wrote:
Would it be wise to perhaps follow the path set out by Thomas? In that case there should be a way to shift the address.
What efforts have you made to “shift the address”? Here is one way:
\startbuffer[participants] <contacts> <contact class='participant' label='Hendriks'> <formalname>Hendriks</formalname> <informalname>Karel</informalname> <prefix>mr.</prefix> <initials>K.</initials> <city>Arnhem</city> <address> <p>Mr. K. Hendriks</p> <p>Grotestraat 5</p> <p>1234 BB Arnhem</p> </address> <kix>1234bb5</kix> </contact> <contact class='participant' label='Janssen'> <formalname>Janssen</formalname> <informalname>Piet</informalname> <initials>P.</initials> <prefix>mr.</prefix> <city>Nijmegen</city> <address> <p>Mr. P. Janssen</p> <p>Kortestraat 8</p> <p>1234 AA Nijmegen</p> </address> <kix>1234aa8</kix> </contact> </contacts> \stopbuffer
\startxmlsetups xml:setups \xmlsetsetup{#1}{contacts|contact|p}{xml:*} \stopxmlsetups
\xmlregistersetup{xml:setups}
\startxmlsetups xml:contacts \xmlflush{#1} \stopxmlsetups
\startxmlsetups xml:p \xmlflush{#1}\par \stopxmlsetups
\startxmlsetups xml:contact \setlayer[address][x=20mm,y=40mm]{\framed[width=74mm,height=35mm,frame=on,offset=2mm,align=right]{\ignorespaces\xmltext{#1}{/address}}} \strut \blank [35mm] Subject: your life in \xmltext{#1}{/city} \blank [2*line] Dear \xmltext{#1}{/prefix} \xmltext{#1}{/formalname}, \blank [line] \input knuth \relax
Kind regards \blank [line] X \page \stopxmlsetups
\setuppagenumbering [state=stop]
\definelayer[address][width=\paperwidth,height=\paperheight]
\setupbackgrounds [page][background={address}]
\starttext \xmlprocessbuffer{main}{participants}{}
\stoptext
I still don’t see you trying to learn a new language one step at a time.
Thomas ___________________________________________________________________________________ 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 ___________________________________________________________________________________
However, the color and style instructions (\ss\tfa) have no effect. I tried to solve that, as a first step, by putting \ss before the \xmlall instruction:
\startxmlsetups xlm:contact \setlayer[AddressBg] {\framed[width=55mm,height=30mm, align=right,background=color, backgroundcolor=lightgray]{\ss\xmlall{#1}{/address}}} \strut ... \stopxmlsetups
This works (see pdf), but there are probably other and better ways.
Have a look at the framed/setupframed command; they have foregroundstyle and foregroundcolor keys; that would be the most idiomatic way to set the style.
Another persisting problem is that the commands are still not ‘expanded’ (see Pablo’s remarks). According to Pablo for some reason there is only one expansion level.
This means that after an \input command, all other commands are not expanded (see pdf).
This also applies to your suggestions (see pdf brieven2mkiv5.pdf): in the Knuth sample text the only command \TeX\, is not expanded either.
You’re working within xml setups, which means that the catcodes are not the same as in TeX, which means that the backslash is just a normal character. The question is: why would you need TeX commands from an external file? Is this where your letter text comes from? You keep us guessing and are not describing what your needs are. Thomas
Your suggestion with foregroundstyle and foregroundcolor works. Thank you! \setlayer[AddressBg] {\framed[width=55mm,height=30mm, align=right,background=color, backgroundcolor=lightgray, foregroundcolor=red,foregroundstyle=\ss\tfa]{\xmlall{#1}{/address}}} My question (my ’need’) was quite simple: how I can have a workflow in which I can produce serial letters based upon contextmkiv (as I did in mkii). I encountered a number of difficulties (in steps): 1. I first noticed that I could not add a letter text, either in the file itself, or by means of \input. At that point the sample knuth file was not processed, nor were my own external letter files. I did write that I use external letter files, but perhaps failed to mention that my texts contain to my mind regular Context commands (like {\bf bold} and \startitemize … \stopitemize). I use these commands to improve the look of my letter. 2. The import problem itself was caused by a wrongful position of the \starttext … \stoptext commands. This problem was solved with help of Thomas, Wolfgang and Pablo. 3. A second problem I signalled was to have the addres moved to the desired place. I could solve this problem by reference to the contextgarden website. Thomas helped me finetune the style instruction. 4. Only when the input files were processed, it became obvious that these files (including the knuth file) in a general sense are not rendered correctly. The knuth sample document (\input knuth) contains only one single command (\TeX\), which is not expanded. For this reason, my sample letters, which contain regular codes, are not processed correctly either. Pablo Rodriguez suggested that the problem was that for some reason there is only one ‘expansion’ level. Thomas, in his last mail, now writes that according to him within the xml setups the ‘catcodes' are changed, and, as a result, the backslash is interpreted as a normal character rather than as introducing a command. While understanding what it means, I guess this might imply that it is difficult (?) or impossible (?) to correctly process files such as the knuth text and for that matter any other letter text that contains regular Context commands. Nevertheless, for the moment this problem remains unsolved. What would you advise as the next step? Should the letter be somehow set-up outside xml setups rather than inside? Should the letter texts (and a specific knuth sample text) be reformatted as xml? So in sum, I sincerely do not think I kept anyone guessing about my needs. The technical problems presented themselves one by one, step by step. Yet if I did, I apologize. Kind regards, Robert
Op 1 aug. 2017, om 10:46 heeft Schmitz Thomas A.
het volgende geschreven: However, the color and style instructions (\ss\tfa) have no effect. I tried to solve that, as a first step, by putting \ss before the \xmlall instruction:
\startxmlsetups xlm:contact \setlayer[AddressBg] {\framed[width=55mm,height=30mm, align=right,background=color, backgroundcolor=lightgray]{\ss\xmlall{#1}{/address}}} \strut ... \stopxmlsetups
This works (see pdf), but there are probably other and better ways.
Have a look at the framed/setupframed command; they have foregroundstyle and foregroundcolor keys; that would be the most idiomatic way to set the style.
Another persisting problem is that the commands are still not ‘expanded’ (see Pablo’s remarks). According to Pablo for some reason there is only one expansion level.
This means that after an \input command, all other commands are not expanded (see pdf).
This also applies to your suggestions (see pdf brieven2mkiv5.pdf): in the Knuth sample text the only command \TeX\, is not expanded either.
You’re working within xml setups, which means that the catcodes are not the same as in TeX, which means that the backslash is just a normal character. The question is: why would you need TeX commands from an external file? Is this where your letter text comes from? You keep us guessing and are not describing what your needs are.
Thomas ___________________________________________________________________________________ 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 ___________________________________________________________________________________
On 1. Aug 2017, at 12:15, r.ermers@hccnet.nl wrote:
While understanding what it means, I guess this might imply that it is difficult (?) or impossible (?) to correctly process files such as the knuth text and for that matter any other letter text that contains regular Context commands.
Nevertheless, for the moment this problem remains unsolved.
What would you advise as the next step?
Should the letter be somehow set-up outside xml setups rather than inside? Should the letter texts (and a specific knuth sample text) be reformatted as xml?
So: you want to import the letter texts from an external file. Easiest solution: instead of simply \input knuth, try this: {\pushcatcodetable \catcodetable\ctxcatcodes\input knuth \popcatcodetable} As you can see, changing the catcode regime processes the file correctly. “Expansion” means something different in TeX speak. Other possibilities: write your letter body in xml, or write the letters in buffers and use \processTEXbuffer. Thomas
Thanks Wolfgang and Thomas, The solutions of both of you function! Thank you! Robert
Op 1 aug. 2017, om 13:17 heeft Schmitz Thomas A.
het volgende geschreven: On 1. Aug 2017, at 12:15, r.ermers@hccnet.nl wrote:
While understanding what it means, I guess this might imply that it is difficult (?) or impossible (?) to correctly process files such as the knuth text and for that matter any other letter text that contains regular Context commands.
Nevertheless, for the moment this problem remains unsolved.
What would you advise as the next step?
Should the letter be somehow set-up outside xml setups rather than inside? Should the letter texts (and a specific knuth sample text) be reformatted as xml?
So: you want to import the letter texts from an external file. Easiest solution: instead of simply \input knuth, try this:
{\pushcatcodetable \catcodetable\ctxcatcodes\input knuth \popcatcodetable}
As you can see, changing the catcode regime processes the file correctly. “Expansion” means something different in TeX speak.
Other possibilities: write your letter body in xml, or write the letters in buffers and use \processTEXbuffer.
Thomas ___________________________________________________________________________________ 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 ___________________________________________________________________________________
participants (3)
-
Pablo Rodriguez
-
r.ermers@hccnet.nl
-
Schmitz Thomas A.