Re: [NTG-context] Filter module for R
On Sun, 14 Jun 2020, Fabrice L wrote: Hi, Following a question about the broken R module (R the statistical software), Aditya suggested me the filter module (thanks to him). I’m about to distribute a set of course notes to colleagues, and I need to deal with details now. I have one problem and two questions. 1) the filter collect R code between \startR / \stopR and submit this code to R. As it can be seen in the following minimal example, when a label contains an accented character (« Fréquence » in my example), the pdf graphic does not contains the « é ». Strangely, the snippet of code (which is saved locally as « test2-temp-R-0.tmp » (for test2.tex)) when submitted with the same command as the filtercommand, works correctly; that means the same file works when submitted to R outside of ConTeXt. I have no idea how to solve this. Are you running the exact same command as the `filtercommand`. If so, I don't know why running the `filtercommand` through context vs directly typing it on the terminal should behave differently. The filter module effectively just runs os.execute("filtercommand"). I don't use R so I am unable to debug further. 2) In a teaching context, we may want sometimes to show the code. The filter module actually permits to show the output of the code submitted to R (which can include or not the input commands); would it be possible to typeset the submitted code ? This is an adapted version of the code that I use for my course where I use the vim module to do the typesetting: \usemodule[filter] \usemodule[vim] \definecolor [darkblue] [r=0.1, g=0.11, b=0.84] \definecolor [darkgreen] [g=0.7] \definecolor [lightblue] [h=87cefa] \definecolor [lightgreen] [g=0.95,b=0.8,r=0.8] \defineframedtext [leftbartext] [ width=local, frame=off, framecolor=darkblue, leftframe=on, rulethickness=1ex, offset=0.25ex, loffset=3ex, background=color, backgroundcolor=lightblue, ] \definevimtyping [RCODE] [ syntax=r, directory=output, strip=yes, escape=yes, before={\blank[quarterline]\startleftbartext}, after={\stopleftbartext}, ] \define[1]\ShowOutput {\typeRCODEfile{\externalfilterinputfile} \startleftbartext[framecolor=darkgreen, backgroundcolor=lightgreen] \setupalign[flushleft, verytolerant] % range={1,-1} not currently supported % See below for details \typefile[range={1,-1}]{#1} \stopleftbartext} \defineexternalfilter [R] [ filtercommand={R CMD BATCH -q --no-timing --save --restore \externalfilterinputfile\space \externalfilteroutputfile}, output=\externalfilterbasefile.out, directory=output, readcommand=\ShowOutput, read=no, cache=yes, purge=yes, % THE COMMA WAS MISSING ] \starttext Some text... \startR[read=yes] pdf("RPlots/MyHistogram.pdf",5,5) X <- rnorm(200,mean=10,sd=2) hist(X, col = "red3" , xlab="Score QI" , main="", ylab="fréquence") \stopR \externalfigure[RPlots/MyHistogram.pdf][width=.5\textwidth] \stoptext 3) Finally, using "R CMD BATCH… » as the filtercommand add an extra line at the end of the output file which can be typeset to visualize results. Would it be possible by a magic trick to deleter the last line of the file ? It is possible to filter lines using `\typefile[range={start, stop}]{filename}`. You can use `range={1,3}` to only include lines 1 upto 3 or `range={1, +2}` to include line 1 followed by 2 lines. What you want is something like `range={1,-1}`, i.e., include from the first to last-1 line, but this is not currently supported. You could ask Hans to do so, as it is relatively simple to add. Of course, you will then need to document this on the wiki. 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 ___
[NTG-context] Filter module for R
Hi,Following a question about the broken R module (R the statistical software), Aditya suggested me the filter module (thanks to him). I’m about to distribute a set of course notes to colleagues, and I need to deal with details now. I have one problem and two questions.1) the filter collect R code between \startR / \stopR and submit this code to R. As it can be seen in the following minimal example, when a label contains an accented character (« Fréquence » in my example), the pdf graphic does not contains the « é ». Strangely, the snippet of code (which is saved locally as « test2-temp-R-0.tmp » (for test2.tex)) when submitted with the same command as the filtercommand, works correctly; that means the same file works when submitted to R outside of ConTeXt. I have no idea how to solve this. 2) In a teaching context, we may want sometimes to show the code. The filter module actually permits to show the output of the code submitted to R (which can include or not the input commands); would it be possible to typeset the submitted code ?3) Finally, using "R CMD BATCH… » as the filtercommand add an extra line at the end of the output file which can be typeset to visualize results. Would it be possible by a magic trick to deleter the last line of the file ?Here is a minimal code:% —\usemodule[filter]\defineexternalfilter [R] [ filtercommand={R CMD BATCH -q --no-timing --save --restore \externalfilterinputfile\space \externalfilteroutputfile}, output=\externalfilterbasefile.out, directory=output, readcommand=\typefile, read=no, cache=yes, purge=yes ]\starttextSome text...\startR[read=yes] pdf("RPlots/MyHistogram.pdf",5,5) X <- rnorm(200,mean=10,sd=2) hist(X, col = "red3" , xlab="Score QI" , main="", ylab="fréquence")\stopR\externalfigure[MyHistogram.pdf][width=.5\textwidth] \stoptext% —Sorry for the three questions… and thanks for any help.Fabrice. MyHistogram.pdf Description: Adobe PDF document ___ 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] \recursestring undefined when inside \dorecurse
On 6/14/2020 11:41 PM, Pablo Rodriguez wrote: Dear list, I have the following sample: \starttext \dorecurse{25}{\recurselevel\par} \doloopoverstring{a,b,c}{\recursestring} } \stoptext Both LMTX and MkIV complain about \recursestring for being undefined. I wonder whether this is inteded or it is a bug. intended, as there is no \doloopoverstring, it's \doloopoverlist {red,green,blue} { [\recursestring] } (btw, you have one } too many) - 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 ___
[NTG-context] using annotations for extended print handling
Dear list, I have an over a thousand pages document generated with ConTeXt. I need to print and chapters and part of chapters (or send to other people). /PrintPageRange is great (and you can even generate a new document containing only the pages in /PrintPageRange). But the issue here is that I would need to recompile the document again for each new required /PrintPageRange. Another approach would be to add PDF annotations (outside page boundaries) to store the desired information. So I created text annotations (using \comment) with author information composed from unit number (such as "i3", "ii9" or "iii28"), info on the unit part (such as "-explanation", "-synopsis", "-exercises", or others) and position ("-start" and "-stop"). This would make author fields such as "i3-start" (which has a corresponding "i3-stop", or "ii22-synopsis-start" (with the corresponding closing annotation). To make easier to identify these annotations, they all share the same title. As contents, all these text annotations have the page number. From the generated PDF document, I need to read all text annotations in order to extract two fields from those annotations that contain a "whatever" /Subj. These fields are /T and /Contents. I guess that the way to deal with the (over 700) annotations would be to store both fields in a Lua table. But this is only a suspicion, since I don’t know how to read the values, how to store them, or how to compare them with specific units or unit parts to get these page numbers. I mean, with a command such as \extractpages{i5,i8-exercises,i15-explanation} would get the pages for each "-start" and "-stop" that could be passed automatically to a \filterpages command. A sample that generates something similar: \setuppapersize[A8] \setupinteraction[state=start] \starttext \dorecurse{5}{\part{\romannumerals{\recurselevel}} \dorecurse{15}{\chapter{\recurselevel} \comment [title=whatever, color=yellow, %~ the following code is to have expansion in interaction author={\ctxlua{context([[\namedstructurevariable{part}{title}% \namedstructurevariable{chapter}{title}]].."-start")}}] {\pagenumber} \doloopoverlist{explanation,exercises,synopsis}{\chapter{\recurselevel} %~ I would like to use \recursestring, but it is undefined here \comment [title=whatever, color=green, author={\ctxlua{context([[\namedstructurevariable{part}{title}% \namedstructurevariable{chapter}{title}]].. [[-\recurselevel]].."-start")}}] {\pagenumber} \dorecurse{5}{\null\page} \comment [title=whatever, color=blue, author={\ctxlua{context([[\namedstructurevariable{part}{title}% \namedstructurevariable{chapter}{title}]].. [[-\recurselevel]].."-stop")}}] {\pagenumber} } \comment [title=whatever, color=red, author={\ctxlua{context([[\namedstructurevariable{part}{title}% \namedstructurevariable{chapter}{title}]].."-stop")}}] {\pagenumber} } } \stoptext Is there a way to deal with the annotations in the document generated from the code above, in the way I described before? Many thanks for your help, Pablo -- http://www.ousia.tk ___ 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] \recursestring undefined when inside \dorecurse
Dear list, I have the following sample: \starttext \dorecurse{25}{\recurselevel\par} \doloopoverstring{a,b,c}{\recursestring} } \stoptext Both LMTX and MkIV complain about \recursestring for being undefined. I wonder whether this is inteded or it is a bug. Many thanks for your help, Pablo -- http://www.ousia.tk ___ 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] Problem with Hello-World.tex
Alessandro Perucchi schrieb am 14.06.2020 um 16:30: Hello everyone, I am quite new to ConTEXt, and after installed it according to the following web page : https://wiki.contextgarden.net/Installation I’ve installed it in macOS Catalina 10.15.5. After a successful installation (I hope), I tried to run the “First Run!” part, so I’ve downloaded the file Hello-World.tex file (via wget), and I’ve run the command “context Hello-World.tex”. I’ve attached the resulting PDF, and it looks great, except for one part, which is the figure and the text flowing around it, which is not the case here. Is there something wrong in what I’ve done? No, it's a bug and there is nothing wrong with the example. 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] Wrong page numbers in frontmatter
Thanks kindly, Wolfgang. On Mon, 15 Jun 2020 at 00:49, Wolfgang Schuster < wolfgang.schuster.li...@gmail.com> wrote: > Jack Steyn schrieb am 14.06.2020 um 16:46: > > Hi, > > > > I'm not sure why the following MWE produces a document where page 2 > > has the page number i instead of ii. It seems to have something to do > > with the use of makeup. I was using it to create a vertically centered > > title page. Is there a better way of doing this which will give the > > correct page numbers? > > > > Best, > > > > Jack > > > > \definestructureconversionset[frontpart:pagenumber][][romannumerals] > > \definestructureconversionset[bodypart:pagenumber][][numbers] > > > > \definemakeup[titlepage][align=middle] > > \definemakeup[titlepage][align=middle,pagestate=start] > > 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 > > ___ > ___ 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] Wrong page numbers in frontmatter
Jack Steyn schrieb am 14.06.2020 um 16:46: Hi, I'm not sure why the following MWE produces a document where page 2 has the page number i instead of ii. It seems to have something to do with the use of makeup. I was using it to create a vertically centered title page. Is there a better way of doing this which will give the correct page numbers? Best, Jack \definestructureconversionset[frontpart:pagenumber][][romannumerals] \definestructureconversionset[bodypart:pagenumber][][numbers] \definemakeup[titlepage][align=middle] \definemakeup[titlepage][align=middle,pagestate=start] 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 ___
[NTG-context] Wrong page numbers in frontmatter
Hi, I'm not sure why the following MWE produces a document where page 2 has the page number i instead of ii. It seems to have something to do with the use of makeup. I was using it to create a vertically centered title page. Is there a better way of doing this which will give the correct page numbers? Best, Jack \definestructureconversionset[frontpart:pagenumber][][romannumerals] \definestructureconversionset[bodypart:pagenumber][][numbers] \definemakeup[titlepage][align=middle] \starttext \startfrontmatter \startmakeup[titlepage] Title \stopmakeup test \stopfrontmatter \startbodymatter \setcounter[userpage][1] test \stopbodymatter \stoptext ___ 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] Problem with Hello-World.tex
Hello everyone,I am quite new to ConTEXt, and after installed it according to the following web page : https://wiki.contextgarden.net/InstallationI’ve installed it in macOS Catalina 10.15.5.After a successful installation (I hope), I tried to run the “First Run!” part, so I’ve downloaded the file Hello-World.tex file (via wget), and I’ve run the command “context Hello-World.tex”.I’ve attached the resulting PDF, and it looks great, except for one part, which is the figure and the text flowing around it, which is not the case here.Is there something wrong in what I’ve done?I mean, I’ve done a fresh installation, download of Hello-World.tex and run the context command.Here are the version that I could find:➜ ~ context --versionmtx-context | ConTeXt Process Management 1.03mtx-context |mtx-context | main context file: /Users/lg/Context/tex/texmf-context/tex/context/base/mkiv/context.mkivmtx-context | current version: 2020.06.12 17:43mtx-context | main context file: /Users/lg/Context/tex/texmf-context/tex/context/base/mkiv/context.mkxlmtx-context | current version: 2020.06.12 17:43Thank you!Regards,Alessandro Hello-world.pdf Description: Adobe PDF document ___ 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 ___