[NTG-context] xmlfiles and url address
Hi all, I wish you happy new year and start with an xml-question: Is it possible to process files from an URL address? It should be something like: \starttext ... \xmlprocessfile{main}{http://example.com/document1.xml}{} \xmlprocessfile{main}{http://example.com/document2.xml}{} ... \stoptext Thank you for your support. Kind regards, Martin ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] xmlfiles and url address
On 5-1-2012 09:19, Martin Fechner wrote: Hi all, I wish you happy new year and start with an xml-question: Is it possible to process files from an URL address? It should be something like: \starttext \xmlprocessfile{main}{http://example.com/document1.xml}{} \xmlprocessfile{main}{http://example.com/document2.xml}{} low level hackery ... \edef\MyFileName#1{\cldcontext{resolvers.findbinfile(url.hashed("#1"))}} \xmlprocessfile{main}{\MyFileName{"http://example.com/document1.xml"}}{} \xmlshow{main} - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Italicized text trailing space too small
On 05.01.2011, at 06:32, Aditya Mahajan wrote: > On Wed, 4 Jan 2012, Kip Warner wrote: > >> Text that I {\it have italicized} trails too tight with the first >> non-italicized word that is typeset next. I'm sure there is some ConTeXt >> command that adjusts this that I am unfamiliar with. > > \italiccorrection or \/ > > Usage: > > {\it text \italiccorrection} Or www.pragma-ade.com/preliminaries/hybrid-italics.pdf \definefontfeature[default][default][itlc=yes] \setupitaliccorrection[always] % none|text|always|always,global Andreas ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] howto get good references in mkiv?
Hello Members, some piece of code, with the problems. I hope somebody can use it to improve ConTeXt, Compilation with texexec is no problem, Kind Regards, Rene' % Begin code: \setupcolors[state=start] \setupinteraction[state=start,color=orange] \setupreferencing[state=start] \defineblock[question] \defineblock[answer] \defineenumeration[question][location=top,coupling=answer] \defineenumeration[answer][location=top,coupling=question] \hideblocks[question] \hideblocks[answer] \defineblock[exercise] \defineblock[solution] \defineenumeration[exercise][location=top,text=Exercise] \defineenumeration[solution][location=top,text=Solution] \hideblocks[exercise] \hideblocks[solution] \defineblock[exer] \defineblock[sol] \defineenumeration[exer][location=top,text=Exercise] \defineenumeration[sol][location=top,text=Solution] \hideblocks[exer] \hideblocks[sol] \starttext \chapter{Preface} To write Lecture Notes or Exams I want to use a mechanism such that in just one paper the questions and the answers can be written. And then to hide the answers at some way or to get a coupling between the exercises and the solutions.\crlf I wanted also a mechanism to give each exercise and each solution a number. These numbers have not to be equal. It is may be better for the students that numbers of the solutions are different from that of the exercises! Than they can play the game: "What exercise belongs to a certain solution?"\crlf The Zeroth Attempt: a try to use "coupling".\crlf The First Attempt: the use of blocks, but the coupling explicit made by myself and there is made use of \type{\defineenumeration}.\crlf The Second Attempt: this I used already succesfully by texexec. I defined by myself a new counter and used that counter in \type{\itemize} and I referenced to the \type{\item}(s).\crlf\crlf Used is the frozen texexec "version 6.2.1 - 1997-2009 - PRAGMA ADE/POD" and "version 2011.05.18 18:04", resp. "version 2012.01.02 21:59" of context. \crlf On the way I learned howto work with a standalone ConTeXt and a system-wide installed ConTeXt. \chapter{Different mechanism to number exercises and solutions} \subsection{Zeroth Attempt} % Begin: Zeroth Attempt This Zeroth Attempt is a tryout to see if the coupling mechanism works. I never used it before so I was curiuous. \crlf\crlf If all the examples are done at once:\crlf Compilation stopped at the places: First Question, Second Question, First Answer and Second Answer. Pushed Enter and compilation continued. \startitemize[n] % oke \item With texexec: no coupling. You don't see anything. % oke \item With context ( version: 2012.01.02 21:59): You see some text written in orange "somewhere", but no interactivity.\crlf Compilation stopped at the places: First Question, Second Question, First Answer and Second Answer. Pushed Enter and compilation continued. % oke \item With context ( version: 2011.05.18 18:04): \crlf You see orange triangles as references, both the Exercises and the Solutions, but there is no interaction. \stopitemize If the example is done separately: \startitemize[n] % oke \item With texexec: no coupling. You don't see anything. % oke \item With context ( version: 2012.01.02 21:59): \crlf You see some text written in orange "somewhere", but no interactivity.\crlf Compilation stopped at the places: First Question, Second Question, First Answer and Second Answer. Pushed Enter and compilation continued. % oke \item With context ( version: 2011.05.18 18:04): \crlf You see orange triangles as references, both the Exercises and the Solutions, but there is no interaction. \crlf Compilation stopped at the places: First Question, Second Question, First Answer and Second Answer. Pushed Enter and compilation continued. \stopitemize \page \beginquestion \startquestion First Question \stopquestion \startquestion Second Question \stopquestion \endquestion \useblocks[question] \page \beginanswer \startanswer First Answer \stopanswer \startanswer Answer \stopanswer \endanswer \useblocks[answer] % End: Zeroth Attempt \subsection{First Attempt} % Begin: First Attempt Nested hidden blocks give problems, such as the continuation of the enumerations and also the amount of times that something is repeated. \crlf If all the examples are done at once:\crlf Compilation stopped at the places: First Question, Second Question, First Answer and Second Answer. Pushed Enter and compilation continued. \startitemize[n] % oke \item With texexec: no problems. % oke \item With context ( version: 2012.01.02 21:59): no references at all, so "??", both the Exercises and the Solutions. % oke \item With context ( version: 2011.05.18 18:04): \crlf no references at all, so "??", both the Exercises and the Solutions. \stopitemize If the example is done separately: \startitemize[n] % oke \item With texexec: no problems. % oke \item With context ( current version: 2012.01.02 21:59): The references do what they have to do. No problems. % oke \item With context ( cur
[NTG-context] CLD: context.getvariable as Lua variable
Hello, I'm relatively quite new to TeX world. This is my first message to list. I hope you understand me, English isn't my mother language. I'm trying to use a variable set by \setvariable in Lua. I tried some combinations, based on manual but I couldn't succeed. The code below exemplifies what I wanted to do. \starttext \setvariable{namespace}{var}{Some context} \ctxlua{ local s = context.getvariable("namespace", "var") if s == "" then ... else ... end } \stoptext I know that I can use some of \if* TeX commands, but coding in Lua is better to me. -- Wagner Macedo ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] CLD: context.getvariable as Lua variable
Am 05.01.2012 um 15:49 schrieb Wagner Macedo: > Hello, > > I'm relatively quite new to TeX world. This is my first message to list. I > hope you understand me, English isn't my mother language. > > I'm trying to use a variable set by \setvariable in Lua. I tried some > combinations, based on manual but I couldn't succeed. The code below > exemplifies what I wanted to do. > > \starttext > \setvariable{namespace}{var}{Some context} > \ctxlua{ > local s = context.getvariable("namespace", "var") > > if s == "" then > ... > else > ... > end > } > \stoptext > > I know that I can use some of \if* TeX commands, but coding in Lua is better > to me. What you’re trying is not possible but there are other ways to check the content of the variable in Lua. \startluacode userdata = userdata or { } function userdata.checkvariable(variable) if variable == "" then context("EMPTY") else context("NOT EMPTY") end end \stopluacode \setvariable{wagner}{name}{Wagner Macedo} \starttext \ctxlua{userdata.checkvariable("\getvariable{wagner}{name}")} % This does only with \startlua or \ctxlua \startlua local name = "\getvariable{wagner}{name}" if name == "" then context("No Text") else name = "Name: " .. name context(name) end \stoplua \stoptext A different method is to save the \setvariables entries in a Lua table and check the entries of the table. \startluacode userdata= userdataor { } userdata.macedo = userdata.macedo or { } userdata.macedo.data = { } function userdata.macedo.savevariables(variables) userdata.macedo.data = variables end function userdata.macedo.checkvariables() local variables = userdata.macedo.data -- check for name if variables.name == "" then context("Name: No name set") context.par() else context("Name: "..variables.name) context.par() end -- check for address if variables.address == "" then context("Address: No address set") context.par() else context("Address: "..variables.address) context.par() end end \stopluacode \starttexdefinition SaveVariables \startlua userdata.macedo.savevariables{ name= "\getvariable{macedo}{name}", address = "\getvariable{macedo}{address}", } \stoplua \stoptexdefinition \setvariables[macedo][set=\SaveVariables] \starttext \setvariables[macedo][name=Wagner Macedo] \ctxlua{userdata.macedo.checkvariables()} \setvariables[macedo][address=Secret] \ctxlua{userdata.macedo.checkvariables()} \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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Italicized text trailing space too small
On Tue, Jan 4, 2011 at 8:32 PM, Aditya Mahajan wrote: > On Wed, 4 Jan 2012, Kip Warner wrote: > >> Text that I {\it have italicized} trails too tight with the first >> non-italicized word that is typeset next. I'm sure there is some ConTeXt >> command that adjusts this that I am unfamiliar with. > > > \italiccorrection or \/ Or use \em which (as I understand it) automatically adds italic correction? Although the hybrid-italics feature looks great (so many hidden nuggets out there :). c -- Chris Lott ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] CLD: context.getvariable as Lua variable
Firstly, thanks by answer. The second way is nice, but could be generic (e.g. save any variable in a namespace)? -- Wagner Macedo On 5 January 2012 13:04, Wolfgang Schuster wrote: > > Am 05.01.2012 um 15:49 schrieb Wagner Macedo: > > Hello, > > I'm relatively quite new to TeX world. This is my first message to list. I > hope you understand me, English isn't my mother language. > > I'm trying to use a variable set by \setvariable in Lua. I tried some > combinations, based on manual but I couldn't succeed. The code below > exemplifies what I wanted to do. > > \starttext > \setvariable{namespace}{var}{Some context} > \ctxlua{ > local s = context.getvariable("namespace", "var") > > if s == "" then > ... > else > ... > end > } > \stoptext > > I know that I can use some of \if* TeX commands, but coding in Lua is > better to me. > > > What you’re trying is not possible but there are other ways to check the > content of the variable in Lua. > > \startluacode > > userdata = userdata or { } > > function userdata.checkvariable(variable) > if variable == "" then > context("EMPTY") > else > context("NOT EMPTY") > end > end > > \stopluacode > > \setvariable{wagner}{name}{Wagner Macedo} > > \starttext > > \ctxlua{userdata.checkvariable("\getvariable{wagner}{name}")} > > % This does only with \startlua or \ctxlua > > \startlua > > local name = "\getvariable{wagner}{name}" > > if name == "" then > context("No Text") > else > name = "Name: " .. name > context(name) > end > > \stoplua > > \stoptext > > A different method is to save the \setvariables entries in a Lua table and > check the entries of the table. > > \startluacode > > userdata= userdataor { } > userdata.macedo = userdata.macedo or { } > > userdata.macedo.data = { } > > function userdata.macedo.savevariables(variables) > userdata.macedo.data = variables > end > > function userdata.macedo.checkvariables() > local variables = userdata.macedo.data > -- check for name > if variables.name == "" then > context("Name: No name set") > context.par() > else > context("Name: "..variables.name) > context.par() > end > -- check for address > if variables.address == "" then > context("Address: No address set") > context.par() > else > context("Address: "..variables.address) > context.par() > end > end > > \stopluacode > > \starttexdefinition SaveVariables > \startlua > userdata.macedo.savevariables{ > name= "\getvariable{macedo}{name}", > address = "\getvariable{macedo}{address}", > } > \stoplua > \stoptexdefinition > > \setvariables[macedo][set=\SaveVariables] > > \starttext > > \setvariables[macedo][name=Wagner Macedo] > > \ctxlua{userdata.macedo.checkvariables()} > > \setvariables[macedo][address=Secret] > > \ctxlua{userdata.macedo.checkvariables()} > > \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://tex.aanhet.net > archive : http://foundry.supelec.fr/projects/contextrev/ > 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] TeX inside XML
I need to do some ConTeXt work inside an XML-proces. In principle this works for most TeX-code through an appropriate xmlsetup that calls \xmlcontext. However some code has problems, and it will be no surprise that it concerns table suff. The error is: Misplaced \omit ... \@tbxmultispans #1->\omit \scratchcounter #1\relax \advance \scratchcounter … As this code runs fine in normal ConTeXt environments, the suspicion is some catcode problem. Can I set inside the \xmlsetup-code something to have \xmlcontext using the correct catcode's, iff that turns out to be the problem of course. Thanks in advance. 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] CLD: context.getvariable as Lua variable
Am 05.01.2012 um 18:22 schrieb Wagner Macedo: > Firstly, thanks by answer. > > The second way is nice, but could be generic (e.g. save any variable in a > namespace)? It would require a different method because \setvariables doesn’t provide information about the values which are set. Can you describe what do you want to achieve and I can try to provide a better solution. 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] CLD: context.getvariable as Lua variable
Don't worry. It's not needed. I just wanted to avoid mix Lua and TeX codes. I will survive using: local s = "\getvariable{namespace}{var}" Thank you by attention. -- Wagner Macedo On 5 January 2012 14:39, Wolfgang Schuster wrote: > > Am 05.01.2012 um 18:22 schrieb Wagner Macedo: > > > Firstly, thanks by answer. > > > > The second way is nice, but could be generic (e.g. save any variable in > a namespace)? > > It would require a different method because \setvariables doesn’t provide > information about the values which are set. Can you describe what do you > want to achieve and I can try to provide a better solution. > > 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://tex.aanhet.net > archive : http://foundry.supelec.fr/projects/contextrev/ > 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] \rotate broken
Hi, The latest beta seems to have broken the \rotate command. \starttext \rotate{Test} \stoptext gives the following error ! Missing { inserted. system > tex > error on line 2 in file test.tex: Missing { inserted ... 1 \starttext 2 >> \rotate{Test} 3 \stoptext 4 \hbox \grph_rotate_finish_indeed ->\hbox \bgroup \ifx \p_rotation_rotation \empty ... \syst_boxes_with_next_box ...rotate_finish_indeed \egroup \egroup l.2 \rotate{Test} Vianney ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] \rotate broken
On 5-1-2012 19:05, Vianney le Clément wrote: Hi, The latest beta seems to have broken the \rotate command. \starttext \rotate{Test} \stoptext gives the following error indeed, i already fixed it yesterday but didn't upload yet Hans - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] missing macro
The macro \expandoneargafter seems to have been disappeared. Is that true? I need it for repairing an appearent failure in the \Word macro to capitalize the first letter in some case. 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] \rotate broken
2012/1/5 Hans Hagen : > indeed, i already fixed it yesterday but didn't upload yet > > Hans Always nice to hear. I'll patiently wait for the Wise Men then :o). Thanks, Vianney ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] missing macro
Am 05.01.2012 um 19:51 schrieb Meer, H. van der: > The macro \expandoneargafter seems to have been disappeared. Is that true? > I need it for repairing an appearent failure in the \Word macro to capitalize > the first letter in some case. Do you have a example where \Word fails in MkIV. The macro was removed because in MkIV many situations can be handled in a better way. 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] Inline itemize
Hello, If I type Blabla. \startitemize[a,text] \item one \item two \stopitemize Blabla. I get a linebreak before and after the itemize. Is this the intended behaviour? How can I get a fully inline enumeration? Thanks, Vianney ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] missing macro
In the meantime I have looked further into the problem. Although in the past redefinition of \Word was the only way to repair, this time there was a destructive interference with \startframedtext. It turned out that \startframedtext[align=middle, etc.] played havic with the following input, to the effect that \Word didn't work as expected. The simple solution --after some digging into my notes inside my (very) old copy of the ConTeXt manual-- was to always put the first set of brackets (even if empty) on the start: \startframedtext[][align=..] etc. Then the problem goes away, but I keep my fingers crossed ;-) No cause for calling "bug" therefore. Hans van der Meer On 5 jan. 2012, at 20:10, Wolfgang Schuster wrote: > > Am 05.01.2012 um 19:51 schrieb Meer, H. van der: > >> The macro \expandoneargafter seems to have been disappeared. Is that true? >> I need it for repairing an appearent failure in the \Word macro to >> capitalize the first letter in some case. > > Do you have a example where \Word fails in MkIV. The macro was removed because > in MkIV many situations can be handled in a better way. > > 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://tex.aanhet.net > archive : http://foundry.supelec.fr/projects/contextrev/ > 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] How to define a command...
Hi all, I need to define numerical coefficients (essentially at random) and then use them with commands, say like \CoeffAlpha, \CoeffBeta, and so on. More precisely, how can I define the command \RandomCoeff, so that \RandomCoeff{Beta}{1}{10} yields a command named \CoeffBeta, which is a random number chosen between 1 and 10? I tried to use the following approach, but could not make it work: %%% begin random-coeff.tex \setuprandomize[2012] % set a seed \ctxlua{CoeffAlpha = math.random(1,10) ;} \def\CoeffAlpha{\ctxlua{tex.print(CoeffAlpha)}} % \define[3]\RandomCoeff{% \ctxlua{a = math.random(#2,#3)} % \csname{Coeff#1}\endcsname{\ctxlua{tex.print(a)}} %% this line does not work as expected... } \starttext \CoeffAlpha \RandomCoeff{Beta}{1}{10} \ctxlua{tex.print(a)} %\CoeffBeta \stoptext %%% end random-coeff.tex Thanks in advance for any suggestion or hint. Best regards: OK ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] How to define a command...
Reccently I did something random in ctxlua. I post it in the hope it will be useful. Hans van der Meer \startluacode -- Define our namespace as hvdm hvdm = hvdm or {} -- Return random series of numbers 1..n depending on the number of arguments function hvdm.randomseries (n, straight) local done = {} for i = 1, n do done[i] = i end if straight == "false" then return table.concat(done,",") end local result = "" for i = n, 2, -1 do local r = math.random(i) result = result .. done[r] .. "," table.remove(done,r) end result = result .. done[1] return result end \stopluacode \def\RandomSeed#1{\directlua{math.randomseed(#1)}} \def\RandomValue{\directlua{tex.print(math.random())}} \def\RandomRange#1{\directlua{tex.print(math.random(#1))}} \def\RandomSeries[#1]#2{\ctxlua{tex.print(hvdm.randomseries(#2,"#1"))}% On 5 jan. 2012, at 21:05, Otared Kavian wrote: > Hi all, > > I need to define numerical coefficients (essentially at random) and then use > them with commands, say like \CoeffAlpha, \CoeffBeta, and so on. > More precisely, how can I define the command \RandomCoeff, so that > \RandomCoeff{Beta}{1}{10} yields a command named \CoeffBeta, which is a > random number chosen between 1 and 10? > > I tried to use the following approach, but could not make it work: > > %%% begin random-coeff.tex > \setuprandomize[2012] % set a seed > > \ctxlua{CoeffAlpha = math.random(1,10) ;} > \def\CoeffAlpha{\ctxlua{tex.print(CoeffAlpha)}} > > % > \define[3]\RandomCoeff{% > \ctxlua{a = math.random(#2,#3)} > % \csname{Coeff#1}\endcsname{\ctxlua{tex.print(a)}} %% this line does not > work as expected... > } > > \starttext > \CoeffAlpha > > \RandomCoeff{Beta}{1}{10} > > \ctxlua{tex.print(a)} > > %\CoeffBeta > > \stoptext > %%% end random-coeff.tex > > Thanks in advance for any suggestion or hint. > Best regards: OK > > ___ > 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 : http://foundry.supelec.fr/projects/contextrev/ > 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] How to define a command...
On Thu, Jan 05 2012, Otared Kavian wrote: > \define[3]\RandomCoeff{% > \ctxlua{a = math.random(#2,#3)} > % \csname{Coeff#1}\endcsname{\ctxlua{tex.print(a)}} %% this line does not > work as expected... \setuprandomize[2012] \define[3]\RandomCoeff{% \expandafter\def\csname Coeff#1\endcsname{\ctxlua{tex.print(math.random(#2,#3))}}} \starttext \RandomCoeff{Alpha}{1}{10} \RandomCoeff{Beta}{2}{20} \CoeffAlpha \CoeffBeta \stoptext -- Peter ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] How to define a command...
Am 05.01.2012 um 21:17 schrieb Peter Münster: > On Thu, Jan 05 2012, Otared Kavian wrote: > >> \define[3]\RandomCoeff{% >> \ctxlua{a = math.random(#2,#3)} >> %\csname{Coeff#1}\endcsname{\ctxlua{tex.print(a)}} %% this line does not >> work as expected... > > \setuprandomize[2012] > \define[3]\RandomCoeff{% > \expandafter\def\csname > Coeff#1\endcsname{\ctxlua{tex.print(math.random(#2,#3))}}} \setvalue{Coeff#1}{…} 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] How to define a command...
Am 05.01.2012 um 21:11 schrieb Meer, H. van der: > Reccently I did something random in ctxlua. I post it in the hope it will be > useful. > > Hans van der Meer > > \startluacode > -- Define our namespace as hvdm > hvdm = hvdm or {} Don’t use a global namespace, you can use “userdata”. userdata = userdata or { } userdata.hvdm = userdata.hvdm or { } 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] How to define a command...
Thanks Hans, in another problem I was looking for commands such as \RandomRange, \RandomSeries: I am going to use your ideas! It is incredible that on this list one gets solutions even for problems one didn't dare to ask :-) Best regards: OK On 5 janv. 2012, at 21:11, Meer, H. van der wrote: > Reccently I did something random in ctxlua. I post it in the hope it will be > useful. > > Hans van der Meer > > \startluacode > -- Define our namespace as hvdm > hvdm = hvdm or {} > > -- Return random series of numbers 1..n depending on the number of > arguments > function hvdm.randomseries (n, straight) > local done = {} > for i = 1, n do > done[i] = i > end > if straight == "false" then > return table.concat(done,",") > end > local result = "" > for i = n, 2, -1 do > local r = math.random(i) > result = result .. done[r] .. "," > table.remove(done,r) > end > result = result .. done[1] > return result > end > \stopluacode > \def\RandomSeed#1{\directlua{math.randomseed(#1)}} > \def\RandomValue{\directlua{tex.print(math.random())}} > \def\RandomRange#1{\directlua{tex.print(math.random(#1))}} > \def\RandomSeries[#1]#2{\ctxlua{tex.print(hvdm.randomseries(#2,"#1"))}% > > > On 5 jan. 2012, at 21:05, Otared Kavian wrote: > >> Hi all, >> >> I need to define numerical coefficients (essentially at random) and then use >> them with commands, say like \CoeffAlpha, \CoeffBeta, and so on. >> More precisely, how can I define the command \RandomCoeff, so that >> \RandomCoeff{Beta}{1}{10} yields a command named \CoeffBeta, which is a >> random number chosen between 1 and 10? >> >> I tried to use the following approach, but could not make it work: >> >> %%% begin random-coeff.tex >> \setuprandomize[2012] % set a seed >> >> \ctxlua{CoeffAlpha = math.random(1,10) ;} >> \def\CoeffAlpha{\ctxlua{tex.print(CoeffAlpha)}} >> >> % >> \define[3]\RandomCoeff{% >> \ctxlua{a = math.random(#2,#3)} >> %\csname{Coeff#1}\endcsname{\ctxlua{tex.print(a)}} %% this line does not >> work as expected... >> } >> >> \starttext >> \CoeffAlpha >> >> \RandomCoeff{Beta}{1}{10} >> >> \ctxlua{tex.print(a)} >> >> %\CoeffBeta >> >> \stoptext >> %%% end random-coeff.tex >> >> Thanks in advance for any suggestion or hint. >> Best regards: OK >> >> ___ >> 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 : http://foundry.supelec.fr/projects/contextrev/ >> 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://tex.aanhet.net > archive : http://foundry.supelec.fr/projects/contextrev/ > 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] How to define a command...
Thanks Peter, I had tried \expandafter\xdef, \edef, \gdef, but not \expandafter\def… Thanks for your quick answer: that's exactly what I was looking for. Best regards: OK On 5 janv. 2012, at 21:17, Peter Münster wrote: > On Thu, Jan 05 2012, Otared Kavian wrote: > >> \define[3]\RandomCoeff{% >> \ctxlua{a = math.random(#2,#3)} >> %\csname{Coeff#1}\endcsname{\ctxlua{tex.print(a)}} %% this line does not >> work as expected... > > \setuprandomize[2012] > \define[3]\RandomCoeff{% > \expandafter\def\csname > Coeff#1\endcsname{\ctxlua{tex.print(math.random(#2,#3))}}} > \starttext > \RandomCoeff{Alpha}{1}{10} > \RandomCoeff{Beta}{2}{20} > \CoeffAlpha > \CoeffBeta > \stoptext > > -- > Peter > ___ > 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 : http://foundry.supelec.fr/projects/contextrev/ > 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] How to define a command...
Thanks for Wolfgang: your solution, that is \setuprandomize[2012] \define[3]\RandomCoeff{% \setvalue{Coeff#1}{\ctxlua{tex.print(math.random(#2,#3))}}} works indeed and it is somehow simpler than using \expandafter\csname, and as a matter of fact, after reading your message I searched in the ConTeXt manuals written by Hans, and found that \setvalue is defined on page 93 of module-01.pdf as \def\setvalue#1{\expandafter \def\csname#1\endcsname} so it is better to use it. Best regards: OK On 5 janv. 2012, at 21:18, Wolfgang Schuster wrote: > > Am 05.01.2012 um 21:17 schrieb Peter Münster: > >> On Thu, Jan 05 2012, Otared Kavian wrote: >> >>> \define[3]\RandomCoeff{% >>> \ctxlua{a = math.random(#2,#3)} >>> % \csname{Coeff#1}\endcsname{\ctxlua{tex.print(a)}} %% this line does not >>> work as expected... >> >> \setuprandomize[2012] >> \define[3]\RandomCoeff{% >> \expandafter\def\csname >> Coeff#1\endcsname{\ctxlua{tex.print(math.random(#2,#3))}}} > > \setvalue{Coeff#1}{…} > > 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] How to define a command...
Hi again Wolfgang and Peter, The solution you provided to my problem is great but has a small issue… Considering the definition \define[3]\RandomCoeff{% \setvalue{Coeff#1}{\ctxlua{tex.print(math.random(#2,#3))}} } after saying \RandomCoeff{Alpha}{1}{10} one gets \CoeffAlpha, but if I use several times \CoeffAlpha, it takes a new value each time, an effect which is undesirable in what I am willing to do. Is there a way to somehow « freeze » the value of \CoeffAlpha once it is defined? Best regards: OK PS: here is the complete example: \define[3]\RandomCoeff{% \setvalue{Coeff#1}{\ctxlua{tex.print(math.random(#2,#3))}} } \starttext \RandomCoeff{Alpha}{1}{10} \RandomCoeff{Beta}{10}{100} \CoeffAlpha \CoeffBeta \CoeffAlpha \CoeffBeta \stoptext On 5 janv. 2012, at 21:18, Wolfgang Schuster wrote: > > Am 05.01.2012 um 21:17 schrieb Peter Münster: > >> On Thu, Jan 05 2012, Otared Kavian wrote: >> >>> \define[3]\RandomCoeff{% >>> \ctxlua{a = math.random(#2,#3)} >>> % \csname{Coeff#1}\endcsname{\ctxlua{tex.print(a)}} %% this line does not >>> work as expected... >> >> \setuprandomize[2012] >> \define[3]\RandomCoeff{% >> \expandafter\def\csname >> Coeff#1\endcsname{\ctxlua{tex.print(math.random(#2,#3))}}} > > \setvalue{Coeff#1}{…} > > 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] How to define a command...
Sorry for the noise… I found the answer to my last question in module-01.pdf, pages 92 and 93: the right definition is \define[3]\RandomCoeff{% \setevalue{Coeff#1}{\ctxlua{tex.print(math.random(#2,#3))}} } that is one has to use \setevalue instead of \setvalue (that is \edef instead of \def). Best regards: OK On 5 janv. 2012, at 22:24, Otared Kavian wrote: > Hi again Wolfgang and Peter, > > The solution you provided to my problem is great but has a small issue… > Considering the definition > > \define[3]\RandomCoeff{% > \setvalue{Coeff#1}{\ctxlua{tex.print(math.random(#2,#3))}} > } > > after saying > \RandomCoeff{Alpha}{1}{10} > one gets \CoeffAlpha, but if I use several times \CoeffAlpha, it takes a new > value each time, an effect which is undesirable in what I am willing to do. > Is there a way to somehow « freeze » the value of \CoeffAlpha once it is > defined? > > Best regards: OK > PS: here is the complete example: > > \define[3]\RandomCoeff{% > \setvalue{Coeff#1}{\ctxlua{tex.print(math.random(#2,#3))}} > } > > \starttext > \RandomCoeff{Alpha}{1}{10} > \RandomCoeff{Beta}{10}{100} > > \CoeffAlpha > > \CoeffBeta > > \CoeffAlpha > > \CoeffBeta > > \stoptext > > On 5 janv. 2012, at 21:18, Wolfgang Schuster wrote: > >> >> Am 05.01.2012 um 21:17 schrieb Peter Münster: >> >>> On Thu, Jan 05 2012, Otared Kavian wrote: >>> \define[3]\RandomCoeff{% \ctxlua{a = math.random(#2,#3)} % \csname{Coeff#1}\endcsname{\ctxlua{tex.print(a)}} %% this line does not work as expected... >>> >>> \setuprandomize[2012] >>> \define[3]\RandomCoeff{% >>> \expandafter\def\csname >>> Coeff#1\endcsname{\ctxlua{tex.print(math.random(#2,#3))}}} >> >> \setvalue{Coeff#1}{…} >> >> 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Inline itemize
As I know, yes, this is the intended behavior. You should be thinking in a WYSIWYG way, but TeX, as most languages (except Python, that I know) works apart you write every code in one line or write pretty indented. I hope you understood. -- Wagner Macedo 2012/1/5 Vianney le Clément > If I type > >Blabla. \startitemize[a,text] \item one \item two \stopitemize Blabla. > > I get a linebreak before and after the itemize. Is this the intended > behaviour? How can I get a fully inline enumeration? > ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Inline itemize
Am 06.01.2012 um 00:06 schrieb Wagner Macedo: > As I know, yes, this is the intended behavior. You should be thinking in a > WYSIWYG way, but TeX, as most languages (except Python, that I know) works > apart you write every code in one line or write pretty indented. No, this is a bug because with the “text” keyword you can create a inline item which doesn’t start a new paragraph. 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Inline itemize
Ah... sorry. I read the manual but I didn't remember this feature. -- Wagner Macedo On 5 January 2012 20:25, Wolfgang Schuster wrote: > No, this is a bug because with the “text” keyword you can create a inline > item which doesn’t start a new paragraph. ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Italicized text trailing space too small
On Wed, 2011-01-05 at 00:32 -0500, Aditya Mahajan wrote: > On Wed, 4 Jan 2012, Kip Warner wrote: > > > Text that I {\it have italicized} trails too tight with the first > > non-italicized word that is typeset next. I'm sure there is some ConTeXt > > command that adjusts this that I am unfamiliar with. > > \italiccorrection or \/ > > Usage: > > {\it text \italiccorrection} > > Aditya > Hey Aditya. I tried both of those options, including altering \it to \em, as well as putting the following in my environment. \definefontfeature[default][default][itlc=yes] \setupitaliccorrection[always] All of the suggestions everyone kindly made appeared to have affected to alteration in the final typesetting. -- Kip Warner -- Software Engineer OpenPGP encrypted/signed mail preferred http://www.thevertigo.com signature.asc Description: This is a digitally signed message part ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] redefining paragraph breaks
On Tue, 3 Jan 2012, Chris Lott wrote: I know I could do it manually, but that makes the source ugly, so is there a way to redefine paragraph breaks so that instead of actual breaks in the output they are kept as running text separate by a paragraph symbol, e.g.: This is paragraph 1. This is paragraph 2. Becomes in the typeset document: This is paragraph 1. ¶ This is paragraph 2. ? c Can't you use plain's \everypar? ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___