\ctxlua{context(os.resultof(git --no-pager log --pretty='\%h of
\%aD' -1))}
\stoptext
But what is the easiest way to typeset the context version? There must be
something easier than
\ctxlua{context(os.resultof(context --version | grep current))}, right?
\contextversion
Aditya
On 11/12/2012 10:43 AM, Alan BRASLAU wrote:
Hello,
Were do MetaPost messages go using mplib? (/dev/null?)
I see nothing on the console nor in the log file.
Alan
\starttext
\startMPpage
message a circle ;
draw fullcircle scaled 2 cm ;
\stopMPpage
\stoptext
\starttext
\ctxlua
\vss \bgroup
\localbegstru...
\grph_include_finalize ...tedexternalfigureframed
{\vfilll \box
\foundextern...
\grph_include_place ...ode \grph_include_finalize
\fi \ctxlua
{figures.pop
\fi \ctxlua
{figures.pop()...
l.2 \externalfigure[plankaart]
It seems that \externalfigure forces execution of \raggedcenter, and if
your PDF's page is large enough, that then fails.
There is, in fact, a workaroud:
\starttext
{\setupalign[nothyphenated
is better
\starttext
\dorecurse{8}{\recurselevel\crlf}
\startluacode
global_cnt=0;
\stopluacode
\bTABLE
%% ok, but why 17 ?
\dorecurse{8}{\bTR\bTD\ctxlua{global_cnt=global_cnt+1;context(global_cnt-17)}:\recurselevel\eTD\eTR}
\eTABLE
%% straight
\startluacode
context.bTABLE()
for i=1,8 do
context.bTR
Hi Philipp,
Thanks to you, Dalyoung and Hans for the nice example using luacode.
I was wonedring how would you modify your code in order to be able to change
the name of the matrix if necessary. For instance, how to modify your code in
such a way that upon saying
\ctxlua
that upon saying
\ctxlua{document.print_matrix(b,3)}
one gets a 3x3 matrix whos coefficients are b_{11},…b_{33}.
if the two of you can come up with some specs we can make a small module
if needed
Hans
to modify your code in
such a way that upon saying
\ctxlua{document.print_matrix(b,3)}
one gets a 3x3 matrix whos coefficients are b_{11},…b_{33}.
Thanks in advance: OK
Something like this?
·
document.print_matrix = function
in
such a way that upon saying
\ctxlua{document.print_matrix(b,3)}
one gets a 3x3 matrix whos coefficients are b_{11},…b_{33}.
This may be overkill but you can just wrap the matrix command in
some TeX macro:
·
% macros=mkvi
and column
context.NC(string.format(schema, i, j))
end
context.NR()
end
context.stopmatrix()
end
\stopluacode
\starttext
\startformula
\ctxlua{document.print_matrix(3)}
\stopformula
\startformula
\ctxlua{document.print_matrix(9,4)}
\stopformula
]
{\iffirstargument
{#left }%%
\fi
\ctxlua{userdata.inwithranges(#label)}%%
\ifsecondargument
{#right}%%
\fi}
Then you can write:
See \inrange{figures} [fig:a,fig:c,fig:d,fig:e,fig:g,fig:x,fig:h]
See \inrange{figures}{TT} [fig:a,fig:c,fig:d,fig:e,fig:g,fig:x,fig:h]
See
functions sometime this weekend. But they
should be doable, really. (And, of course, you may be far more
experienced in LuaTeX than I, I don't know.)
Cheers,
Sietse
% should be below startluacode block, but clearer like so
\def\inwithranges[#1]%
{\ctxlua{u.inwithranges(#1)}}
\startluacode
u
userdata = userdata or { } userdata.bibitems = { }
\stopluacode
\startxmlsetups xml:document \xmlflush{#1} \stopxmlsetups
\startxmlsetups xml:bibitem
\ctxlua{userdata.bibitems[\letterhash\xmlatt{#1}{xml:id}] = #1}
\stopxmlsetups
\def\BibAuthor#1#2{[2:\xmlfirst{\cldcontext{userdata.bibitems['#2
{xml:define}
\xmlprocessbuffer{whatever}{demo}{}
\startluacode
userdata = userdata or { }
userdata.bibitems = { }
\stopluacode
\startxmlsetups xml:document
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:bibitem
\ctxlua{userdata.bibitems[\letterhash\xmlatt{#1}{xml:id}] = #1
\ctxlua{context(tostring(some condition)}
given that the condition returns true/false
-
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477
the dimen value in Lua?
\starttext
\scratchdimen = 20pt
\the\scratchdimen
\ctxlua{tex.dimen.scratchdimen = 10pt}
\the\scratchdimen
\stoptext
Wolfgang
___
If your question is of interest to others as well, please add
kilometersolidushour
ConTeXt:
ver: 2012.08.16 22:20 MKIV fmt: 2012.8.22
phys-dim.mkiv
%\ctxlua{
%languages.labels.define(setupprefixtext,prefixes)%
%languages.labels.define(setupunittext,units)%
%languages.labels.define(setupoperatortext,operators)%
%languages.labels.define
]])}
\directlua{tex.newcount(myothercount)}
etc...
\stoptext
again fails...
Is there any source or examples to study anything about it?
AFAIK there is no tex.setdimen but what’s the problem to use Lua tables to save
the values.
\starttext
\ctxlua{mydimension = number.topoints
ConTeXt converting
functions do not work etc. ..
Thanx Jaroslav
Here is another example:
\starttext
\newdimen\mytexdimension
\mytexdimension=100pt
\ctxlua{myluadimension = number.topoints(1)}
\ctxlua{context(myluadimension)}
\the\mytexdimension
\hbox to\mytexdimension{X}
% FAILS
!
In addition, I solve the problem at LuaTEX, so ConTeXt converting
functions do not work etc. ..
Thanx Jaroslav
Here is another example:
\starttext
\newdimen\mytexdimension
\mytexdimension=100pt
\ctxlua{myluadimension = number.topoints(1)}
\ctxlua{context(myluadimension)}
\the\mytexdimension
On Wed, Aug 22 2012, Jaroslav Hajtmar wrote:
\ctxlua{myluadimension = number.topoints(1)}
\ctxlua{context(myluadimension)}
\def\myluadimension{\ctxlua{context(myluadimension)}}
...
\hbox to\myluadimension{X}
--
Peter
Hello,
sometimes in this mail discussion I'm encountering a Ctx/Lua command which has
been unknown for me or I would use other (known) commands to do the job.
So - would it be possible to explain
- what's the difference/advantage btw \directlua and \ctxlua
- what \ctxcommand{} does
- what
converting
functions do not work etc. ..
Thanx Jaroslav
Here is another example:
\starttext
\newdimen\mytexdimension
\mytexdimension=100pt
\ctxlua{myluadimension = number.topoints(1)}
\ctxlua{context(myluadimension)}
\the\mytexdimension
\hbox to\mytexdimension{X}
% FAILS
/advantage btw \directlua and \ctxlua
No difference, just another name, there are even more synonyms.
- what \ctxcommand{} does
\ctxcommand{...} == \ctxlua{commands}
- what \cldcontext{} does?
\cldcontext{...} == \ctxlua{context(...)}
There is also \cldcommand{...} which is a short form
In a recent thread, Hans used the document namespace, where I (naively)
expected userdata:
On Aug 22, 2012, at 6:32 AM, Hans Hagen wrote:
\ctxlua{document.myluadimension = 200pt}
Is there a reason not to use userdata.myluadimension? Or is
document.myluadimension safe, because myluadimension
On 22-8-2012 14:55, Rogers, Michael K wrote:
In a recent thread, Hans used the document namespace, where I (naively)
expected userdata:
On Aug 22, 2012, at 6:32 AM, Hans Hagen wrote:
\ctxlua{document.myluadimension = 200pt}
Is there a reason not to use userdata.myluadimension
it be possible to explain
- what's the difference/advantage btw \directlua and \ctxlua
No difference, just another name, there are even more synonyms.
The \ctxlua variant is somewhat more future proof. In the past
\directlua had a mandate extra argument. Also, the \ctxlua macro
can use a dedicated message
On Mon, 20 Aug 2012 20:11:32 +0200, Sietse Brouwer sbbrou...@gmail.com wrote:
Hi Peter,
I recommend using the following handy little idiom:
\ctxlua{commands.doifelse(-45 0)}{big}{small} % small
It lets you do all sorts of things that are tricky in TeX:
\ctxlua{ commands.doifelse( string.len
Am 21.08.2012 um 08:32 schrieb Procházka Lukáš l...@pontex.cz:
On Mon, 20 Aug 2012 20:11:32 +0200, Sietse Brouwer sbbrou...@gmail.com
wrote:
Hi Peter,
I recommend using the following handy little idiom:
\ctxlua{commands.doifelse(-45 0)}{big}{small} % small
It lets you do all
Aug 2012 20:11:32 +0200, Sietse Brouwer sbbrou...@gmail.com
wrote:
Hi Peter,
I recommend using the following handy little idiom:
\ctxlua{commands.doifelse(-45 0)}{big}{small} % small
It lets you do all sorts of things that are tricky in TeX:
\ctxlua{ commands.doifelse( string.len( -45 ) 5
... I also found another solution reposter before:
\ctxlua{commands.testcase(condition)}
{ If true...}
{If false}
Note that both blocks (if-true and if-false) are mandatory.
Considering Wolfgang's last answer, it would be better to write:
\ctxcommand{testcase(condition
On 21-8-2012 17:13, Procházka Lukáš wrote:
I also found another solution reposter before:
\ctxlua{commands.testcase(condition)}
{ If true...}
{If false}
yes, but testcase is an unfortunate name and sort of obsolete (so best
use doifelse
Hi Peter,
I recommend using the following handy little idiom:
\ctxlua{commands.doifelse(-45 0)}{big}{small} % small
It lets you do all sorts of things that are tricky in TeX:
\ctxlua{ commands.doifelse( string.len( -45 ) 5 ) }{long}{short}
Cheers,
Sietse
an error after grepping the log-file.
or this:
\externalfigure[rubish.pdf]
\ifcase\figurestatus\relax \ctxlua{os.exit(999)} \fi
-
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH
?
And for the general case, what about
`\ctxlua{commands.processedfile}`? That looks like it should print the
current filename, as long as any inclusions use the ConTeXt commands
and not \input.
--Sietse
On Thu, Aug 9, 2012 at 1:24 PM, Procházka Lukáš Ing. - Pontex s. r. o.
l...@pontex.cz wrote:
Great, thank you
for startproject, startenvironment, and startproduct,
I assume?
And for the general case, what about
`\ctxlua{commands.processedfile}`? That looks like it should print the
current filename, as long as any inclusions use the ConTeXt commands
and not \input.
You can use \currentcomponent
Someone\footnote{Prof.\
3 ABC}
4 \stoptext
5
Ok, the next is only for those who want to spend some time on the
internals ...
\starttext
\def\TestA#1%
{\writestatus{Test A}{#1}%
\ctxlua{str = #1 print(str) context(str) io.savedata(temp.tmp,str)}}
\def\TestB#1%
{\writestatus{Test B}{#1
}
\startxmlsetups xml:c
\ctxlua{
title = test=..lxml.att(#1,title)
context(title)}%
\stopxmlsetups
\starttext
test : \xmlprocessdata {maths}{?xml version='1.0' standalone='yes?c
title=My title/c} {}
\stoptext
\endinput
Context gives the can't concatenate with a nil value Luatex error
when
:*}
\stopxmlsetups
\xmlregistersetup{xml:test}
\startxmlsetups xml:c
\ctxlua{
title = test=..lxml.att(#1,title)
context(title)}%
\stopxmlsetups
\starttext
test : \xmlprocessdata {maths}{?xml version='1.0' standalone='yes?c
title=My title/c} {}
\stoptext
\endinput
Context gives the can't concatenate
for me:
\startluacode
function set(node)
p = lxml.att(node,p) -- or p = lxml.att(lxml.id(node),p)
end
\stopluacode
\startxmlsetups xml:section
\ctxlua{set(#1)}
\stopxmlsetups
it looks like it returns the p attribute of the node before #1
the following snipet works though (which is strange because I
\csname##1\endcsname\relax}}%
\ctxlua{figures.push {
name = \p_grph_include_name,
label = \p_grph_include_label,
@@ -312,8 +316,8 @@
resolution = \externalfigureparameter\c!resolution,
color =
\internalspotcolorparent{\externalfigureparameter\c
On 26-6-2012 06:36, Kip Warner wrote:
On Tue, 2012-06-26 at 05:27 +0200, Wolfgang Schuster wrote:
grph-epd.mkiv (untested):
\startsetups system:graphics:epdf
%\ctxlua{figures.mergegoodies(\@@efinteraction)}%
\ctxlua{figures.mergegoodies(\externalfiguresparameter\c!interaction
Am 26.06.2012 um 01:59 schrieb Kip Warner:
Hey list,
I'm using ConTeXt 2012.06.25 and I noticed a broken compilation of my
book:
grph-epd.mkiv (untested):
\startsetups system:graphics:epdf
%\ctxlua{figures.mergegoodies(\@@efinteraction)}%
\ctxlua{figures.mergegoodies
On Tue, 2012-06-26 at 05:27 +0200, Wolfgang Schuster wrote:
grph-epd.mkiv (untested):
\startsetups system:graphics:epdf
%\ctxlua{figures.mergegoodies(\@@efinteraction)}%
\ctxlua{figures.mergegoodies(\externalfiguresparameter\c!interaction)}%
\reference[\figurereference]{}% todo
of box via ConTeXt (works fine):
\setmybox
\lsize=5cm
\dorecurse{3}{%
\lsize=\dimexpr(\lsize+7mm)
\setmybox
height of box: \the\ht0\par
width of box: \the\wd0\par
\box0\par
}
\page
... and Height of box via Lua (do not working):
\setmybox
\ctxlua{
tex.dimen.lsize=5
=5cm
\dorecurse{3}{%
\lsize=\dimexpr(\lsize+7mm)
\setmybox
height of box: \the\ht0\par
width of box: \the\wd0\par
\box0\par
}
\page
... and Height of box via Lua (does it work ?):
\setmybox
\ctxlua{tex.dimen.lsize=5*72.27*65536/25.4;i=0}
\dorecurse{3}{%
\ctxlua{
--[=[ for i=1, 3 do
=\dimexpr(\lsize+7mm)
\setmybox
height of box: \the\ht0\par
width of box: \the\wd0\par
\box0\par
}
\page
... and Height of box via Lua (do not working):
\setmybox
\ctxlua{
tex.dimen.lsize=5*72.27*65536/25.4
for i=1, 3 do
tex.dimen.lsize=tex.dimen.lsize+7*72.27*65536/25.4
context
On Fri, Jun 08 2012, Hans Hagen wrote:
I've added moduledata.spreadsheets.settings.numberseparator but you have to
test it after the next upload.
Tested. Thanks!
Just a minor comment: \setupspreadsheet[numberseparator=,] would be
nicer than
\ctxlua
On 8-6-2012 12:21, Peter Münster wrote:
On Fri, Jun 08 2012, Hans Hagen wrote:
I've added moduledata.spreadsheets.settings.numberseparator but you have to
test it after the next upload.
Tested. Thanks!
Just a minor comment: \setupspreadsheet[numberseparator=,] would be
nicer than
\ctxlua
userdata.locuskey(x)
context(string.gsub(x,(%d+),function (s) return
string.format(%04d,tonumber(s)) end))
end
\stopluacode
\def\locuskey#1{\ctxlua{userdata.locuskey(#1)}}
The Mark IV/Luatex one was much nicer, less frustrating to figure out.
On May 24, 2012, at 7:06 AM, Alan Bowen wrote
(s) return
string.format(%04d,tonumber(s)) end))
end
\stopluacode
\def\locuskey#1{\ctxlua{userdata.locuskey(#1)}}
The Mark IV/Luatex one was much nicer, less frustrating to figure out.
On May 24, 2012, at 7:06 AM, Alan Bowen wrote:
For anyone interested in producing classical indices locorum
+#3}}
% Def. of \locuskey
\startluacode
userdata = userdata or { }
function userdata.locuskey(x)
context(string.gsub(x,(%d+),function (s) return
string.format(%04d,tonumber(s)) end))
end
\stopluacode
\def\locuskey#1{\ctxlua{userdata.locuskey(#1)}}
The Mark IV/Luatex one was much
\stopluacode
\starttext
img1 is \ctxlua{userdata.mytype(img1)}\par
img2 is \ctxlua{userdata.mytype(img2)}
\stoptext
Michael
This e-mail message (including any attachments) is for the sole use of
the intended recipient(s) and may contain confidential
\startluacode
userdata = userdata or { }
function userdata.locuskey(x)
context(string.gsub(x,(%d+),function (s) return
string.format(%04d,tonumber(s)) end))
end
\stopluacode
\def\locuskey#1{\ctxlua{userdata.locuskey(#1)}}
The Mark IV/Luatex one was much nicer, less frustrating to figure out.
On May 24
... Finally, I use the following to avoid ' in arguments and to keep to
os.execute():
\bgroup
\catcode`\%=11
\ctxlua{os.execute(([[echo lua -e print 'EXECUTE']]):gsub('(.-)',
[[%1]]))}
\egroup
% Or:
\startluacode
os.execute(([[echo lua -e print 'EXECUTE']]):gsub('(.-)', [[%1
Hello,
I slightly modified the example - my code now is:
\ctxlua{os.execute([[echo lua -e print 'WWW']])}
\starttext
A
\stoptext
So now I'm able to diagnose what exactly is passed to the command line.
I'm getting:
...
languageslanguage en is active
lua -e print WWW
{c
On 15-5-2012 09:05, Procházka Lukáš Ing. - Pontex s. r. o. wrote:
Hello,
I slightly modified the example - my code now is:
\ctxlua{os.execute([[echo lua -e print 'WWW']])}
\starttext
A
\stoptext
So now I'm able to diagnose what exactly is passed to the command line.
I'm getting
os.execute([[echo lua -e print 'WWW']])
lua -e print 'WWW'
=os.exec
nil
=os.spawn
nil
- There is no '/ substitution in standalone Lua (?!).
does os.exec or os.spawn work ok?
Well, the 'os.exec' works, in condition that it is called with cmd /c:
\ctxlua{os.execute([[echo lua -e print
require 'lfs'
- there is no error.
From within the Context code, I'm getting (see CmdLine.log):
lua.exe: (command line):1: '=' expected near 'lfs'
lua.exe: (command line):1: '=' expected near 'eof'...
What could be the problem?
My OS is WinXP 32b.
And how about
\ctxlua{os.execute(lua
\ctxlua{os.execute(lua -e require 'lfs')}
... Gives:
...
fontslatin modern fonts are not preloaded
languageslanguage en is active
! LuaTeX error main ctx instance:1: attempt to call global 'e' (a nil value)
stack traceback:
main ctx instance:1: in main chunk
On 14-5-2012 12:23, Procházka Lukáš Ing. - Pontex s. r. o. wrote:
\ctxlua{os.execute(lua -e require 'lfs')}
\ctxlua{os.execute([[lua -e require 'lfs']])}
-
Hans Hagen | PRAGMA ADE
\sbc{} is a command defined by me.
\define[1]\sbc{\ctxlua{context(\%.2f, #1)}}%
I'm writing a technical report and I use that command to substitute numbers to
letters in formulas.
___
If your question is of interest
On Sun, May 13, 2012 at 3:54 PM, elgo...@libero.it elgo...@libero.it wrote:
\sbc{} is a command defined by me.
\define[1]\sbc{\ctxlua{context(\%.2f, #1)}}%
I'm writing a technical report and I use that command to substitute numbers to
letters in formulas.
ok, I'm using
\def\sbc#1{#1}
\let\sbd
On Sun, 13 May 2012, elgo...@libero.it wrote:
\sbc{} is a command defined by me.
\define[1]\sbc{\ctxlua{context(\%.2f, #1)}}%
I'm writing a technical report and I use that command to substitute numbers to
letters in formulas.
Please create a complete working minimal example.
Aditya
-
% comando \sb
\def\sb#1{\ctxlua{tex.print(#1)}}% definizione comando di sostituzione dei
valori numerici a quelli letterali
% comando \sba
\def\sba#1{\ctxlua{tex.print(string.format(\%.0f, #1))}}% sostituisce numero
a valori letterali scrivendolo senza cifre decimali
% comando \sbb
\define
Am 06.05.2012 22:26, schrieb Hans Hagen:
On 3-5-2012 19:01, Peter Rolf wrote:
Hi,
the system parameter 'n' is not properly set on the third run.
% test.tex
\starttext
\ifnum\systemparameter{n}=1\relax
\ctxlua{print(*** 1st run)}\fi
\ifnum\systemparameter{n}=2\relax
\ctxlua{print
On 3-5-2012 19:01, Peter Rolf wrote:
Hi,
the system parameter 'n' is not properly set on the third run.
% test.tex
\starttext
\ifnum\systemparameter{n}=1\relax
\ctxlua{print(*** 1st run)}\fi
\ifnum\systemparameter{n}=2\relax
\ctxlua{print(*** 2nd run)}\fi
\ifnum\systemparameter{n}=3
()}%
\settrue\MPLIBtextgetdone % no \global needed
\fi
\dowithnextbox{\ctxlua{metapost.settext(\number\nextbox,#1)}}\hbox}
\def\MPLIBresettexts
{\ctxlua{metapost.resettextexts()}%$
\setfalse\MPLIBtextgetdone}
\starttext
Serif
\startMPcode
draw textext(\ss Sans) ;
\stopMPcode
Serif
Hello,
Wiki and a file processed on a local computer give different results -
- please compare http://wiki.contextgarden.net/Command/doif...;
and the example attached:
\starttext
\ctxlua{test = true}
Test is \ctxlua{commands.testcase(test)}{True}{False}.
\ctxlua{test = false
Hi,
the system parameter 'n' is not properly set on the third run.
% test.tex
\starttext
\ifnum\systemparameter{n}=1\relax
\ctxlua{print(*** 1st run)}\fi
\ifnum\systemparameter{n}=2\relax
\ctxlua{print(*** 2nd run)}\fi
\ifnum\systemparameter{n}=3\relax
\ctxlua{print(*** 3rd run)}\fi
Hello all,
Here is another question. Consider this test file:
\starttext
\setupspellchecking[state=start,method=2]
\ctxlua{languages.words.threshold=3}
\input knuth
\stoptext
Typesetting this file produces a word list 'test.words' which ends like
this:
[threshold]=1,
[total]=122,
[version
Hi again,
On 2012-04-20 16:32, Jelle Huisman wrote:
Hello all,
Here is another question. Consider this test file:
\starttext
\setupspellchecking[state=start,method=2]
\ctxlua{languages.words.threshold=3}
\input knuth
\stoptext
Typesetting this file produces a word list 'test.words
{%
\dosingleempty\dowordcount}
\def\dowordcount[#1]{%
\ctxlua{userdata.wordcount(#1)}}
\starttext
% Set up the word count
\ctxlua{languages.words.threshold=2}
\setupspellchecking [state=start, method=2]
\setupspellchecking [list=foo]
\startsection [title=Foo]
Foo Bar
\stopsection
On 04/20/2012 04:53 PM, Philipp Gesang wrote:
Hi again,
On 2012-04-20 16:32, Jelle Huisman wrote:
Hello all,
Here is another question. Consider this test file:
\starttext
\setupspellchecking[state=start,method=2]
\ctxlua{languages.words.threshold=3}
\input knuth
\stoptext
On Mon, 2012-04-09 at 00:08 -0400, Aditya Mahajan wrote:
\def\loaddatafile#1%
{\ctxlua {
job.initialize(#1.tuc,#1.tua)
}}%
\loaddatafile{full-book} %with the .tex extension
\starttext
\placelist[chapter]
\stoptext
Thanks Aditya, but I tried doing that. ConTeXt
On Sun, 8 Apr 2012, Kip Warner wrote:
On Mon, 2012-04-09 at 00:08 -0400, Aditya Mahajan wrote:
\def\loaddatafile#1%
{\ctxlua {
job.initialize(#1.tuc,#1.tua)
}}%
\loaddatafile{full-book} %with the .tex extension
Sorry, this should have read: WITHOUT the .tex extension
.
\def\loaddatafile#1%
{\ctxlua {
job.initialize(#1.tuc,#1.tua)
}}%
\loaddatafile{full-book} %with the .tex extension
\starttext
\placelist[chapter]
\stoptext
Aditya
___
If your question is of interest
to the
user.
More complicated example:
t-Hook4.mkiv
\startluacode
function foo()
local stoptext_p = context.stoptext
context.stoptext = function(...)
context(END)
stoptext_p(...)
end
end
\stopluacode
\starttext
\input knuth
\ctxlua{foo()} % This should cause
Am 07.03.2012 um 16:57 schrieb Procházka Lukáš Ing. - Pontex s. r. o.:
... Yes, that's it! Thanks a lot!
You can also write your own stop/stop-commands for the document like
\def\startmydocument
{\starttext}
\def\stopmydocument
{\ctxlua{…}%
\stoptext}
and use them instead
{\ctxlua{…}%
\stoptext}
and use them instead of \starttext and \stoptext.
Or you use the predefined document environment which has before and after keys.
\setupdocument[after={\blank\midaligned{\bf THE END}}]
\startdocument
\input knuth
\stopdocument
Wolfgang
On Sun, 2012-03-04 at 23:20 -0500, Aditya Mahajan wrote:
If you want to use the automagic way, you can define \BazaarRevision to
redefined \BazaarRevision, for example:
\def\BazaarRevision
{\ctxlua{context.setevalue(
BazaarRevision,
os.resultofbzr
On Mon, 5 Mar 2012, Kip Warner wrote:
On Sun, 2012-03-04 at 23:20 -0500, Aditya Mahajan wrote:
If you want to use the automagic way, you can define \BazaarRevision to
redefined \BazaarRevision, for example:
\def\BazaarRevision
{\ctxlua{context.setevalue(
BazaarRevision
}
{\showboxdepth}
{\tracinggroups}
{\tracingifs}
{\tracingscantokens}
{\tracingnesting}
{\tracingassigns}
{into \tracingassigns=2}
{\errorstopmode}
{\tracingonline}
{changing \tracingonline=1}
{into \tracingonline=0}
\BazaarRevision -\ctxlua {context.setevalue( BazaarRevision, os.resultofbzr revno | tr -d '\\n
),
author=Some Book (Bzr r\BazaarRevision)]
Why don't you use the first version (\initializebazaarversion and
\usebazaarversion)?
\def\initializeBazaar
{\ctxlua{context(\\global\\edef\\BazaarRevision{\%s},
os.resultofbzr revno | tr -d '\\n')}}
\initializeBazaar
On Tue, 2012-03-06 at 00:04 -0500, Aditya Mahajan wrote:
Why don't you use the first version (\initializebazaarversion and
\usebazaarversion)?
\def\initializeBazaar
{\ctxlua{context(\\global\\edef\\BazaarRevision{\%s},
os.resultofbzr revno | tr -d '\\n
{\ctxlua{context.setevalue(
usebazaarrevision,
os.resultofbzr revno | tr -d '\\n')}}
\appendtoks \initilizebazaar \to \everystarttext
and then use can use \usebazaarrevision in the main text.
If you want to use the automagic way, you can define \BazaarRevision
()
if #files 0 then
context(table.remove(files, math.random(1,#files)) or dummy)
else
context(dummy)
end
end
\stopluacode
\def\CollectGraphics[#1]{\ctxlua{document.collectgraphics(#1)}}
\def\ChooseGraphic {\ctxlua{document.choosegraphic
, )))
end
function document.choosegraphic()
if #files 0 then
context(table.remove(files, math.random(1,#files)) or dummy)
else
context(dummy)
end
end
\stopluacode
\def\CollectGraphics[#1]{\ctxlua{document.collectgraphics(#1)}}
\def\ChooseGraphic
(orig_pos)
string.lenutf8(string),
but without success.
Can you please someone help?
Thanks
Jaroslav Hajtmar
Here is my minimal example:
\def\mymacro#1{\ctxlua{for i=1, string.len('#1') do
context(string.sub('#1',i,i).., ) end}}
\starttext
%\mymacro{šěřěžřýčřčžáýčý} % Here is a problem
Thanks
Jaroslav Hajtmar
Here is my minimal example:
\def\mymacro#1{\ctxlua{for i=1, string.len('#1') do
context(string.sub('#1',i,i).., ) end}}
\starttext
%\mymacro{šěřěžřýčřčžáýčý} % Here is a problem
\mymacro{asdfghjklqwertt} % Here is all OK
\stoptext
]
\externalfigure
[\ctxlua{context(http://placekitten.com/g/\%0.0f/\%0.0f;,
\withoutpt{\the\dimexpr\kittenwidth},
\withoutpt{\the\dimexpr\kittenheight})}]
[#1, method=jpg]}
\starttext
\placefigure[left,none]{}
{\externalkitten[width=0.5
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
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
.
\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
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
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
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
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
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
:
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
601 - 700 of 1160 matches
Mail list logo