Re: [NTG-context] Scientific paper boiler plate

2014-09-15 Thread Joshua Krämer
On 2014-09-12, 2:40, Kip Warner wrote:

 I'd like to write a short scientific paper describing an algorithm I
 discovered in the realm of computational geometry a few years ago
 before I forget it entirely. I've been meaning to do this for some
 time, but haven't had a chance. I'd like to use ConTeXt. 
 
 Does anyone have a sample source I could take a look at as a starting
 point? I will need to typeset some figures, pseudo code, references,
 etc. and this all takes much less time when someone much more clever
 than I, like Wolfgang or Hans already has a similar environment file
 and such setup.

At the moment, I am writing my MD thesis using ConTeXt.  I have
equations, figures, tables, diagrams, references.  There is also Lua
code embedded to prepare data tables from CSV files, round values etc.
Of course, there is a lot in my files that you will not need.  The
organization of my files  (preamble files, chapter files) may not
be suitable for your project.  The format of my document (thesis)
may not be what you want (journal article?).  On these grounds, I do not
think it is a good idea to take the files from somebody else and alter
them.  I know this is common in the LaTeX community, and I have seen
many times that it leads to inconsistent settings, conflicting packages
and other problems.  Instead, I suggest you to start with an empty file
and add everything *you* need.  However, if you really want, I can try
to strip down my files and send you a basic sample.

Kind regards,
Joshua Krämer


___
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] lpdf.checkedkey has problem with false values

2014-09-15 Thread Michail Vidiassov
Dear Developers and All,

lpdf.checkedkey routine from lpdf-ini.lua has problems with accessing
false boolean values, it returns them as nil. Is it by design or
neglect?
(I vaguely remember stumbling on this problems before, so  there is a
chance that I have already got the answer, but have forgotten it.)
The minimal demo:
\starttext
\startluacode
local function writebool(bv,text)
 if bv == true then
  io.write(text,  true \n)
 elseif bv == nil then
  io.write(text,  nil  \n)
 else
  io.write(text,  false\n)
 end
end
local a = {}
a[x] = true
a[y] = false
a[z] = nil
writebool(lpdf.checkedkey(a,x,boolean),lpdf.checkedkey(a,\x\,\boolean\))
writebool(lpdf.checkedkey(a,y,boolean),lpdf.checkedkey(a,\y\,\boolean\))
writebool(lpdf.checkedkey(a,z,boolean),lpdf.checkedkey(a,\z\,\boolean\))
writebool(a.x,a.x)
writebool(a.y,a.y)
writebool(a.z,a.z)
\stopluacode
TEST
\stoptext


It results in the following relevant output

lpdf.checkedkey(a,x,boolean) true
lpdf.checkedkey(a,y,boolean) nil
lpdf.checkedkey(a,z,boolean) nil
a.x true
a.y false
a.z nil

Note that false value was read by checkedkey as nil.

Sincerely, MIchail
___
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] lpdf.checkedkey has problem with false values

2014-09-15 Thread Peter Rolf
Am 15.09.2014 um 16:14 schrieb Michail Vidiassov:
 Dear Developers and All,
 
 lpdf.checkedkey routine from lpdf-ini.lua has problems with accessing
 false boolean values, it returns them as nil. Is it by design or
 neglect?

More a lua design decision. 'nil' is equal to 'false' here, 'true' is
equal to all that is not 'nil'.

http://www.lua.org/pil/3.3.html

 (I vaguely remember stumbling on this problems before, so  there is a
 chance that I have already got the answer, but have forgotten it.)
 The minimal demo:
 \starttext
 \startluacode
 local function writebool(bv,text)
  if bv == true then

if bv then

   io.write(text,  true \n)
  elseif bv == nil then

else
(if not bv then)


HTH,   Peter


   io.write(text,  nil  \n)
  else
   io.write(text,  false\n)
  end
 end
 local a = {}
 a[x] = true
 a[y] = false
 a[z] = nil
 writebool(lpdf.checkedkey(a,x,boolean),lpdf.checkedkey(a,\x\,\boolean\))
 writebool(lpdf.checkedkey(a,y,boolean),lpdf.checkedkey(a,\y\,\boolean\))
 writebool(lpdf.checkedkey(a,z,boolean),lpdf.checkedkey(a,\z\,\boolean\))
 writebool(a.x,a.x)
 writebool(a.y,a.y)
 writebool(a.z,a.z)
 \stopluacode
 TEST
 \stoptext
 
 
 It results in the following relevant output
 
 lpdf.checkedkey(a,x,boolean) true
 lpdf.checkedkey(a,y,boolean) nil
 lpdf.checkedkey(a,z,boolean) nil
 a.x true
 a.y false
 a.z nil
 
 Note that false value was read by checkedkey as nil.
 
 Sincerely, MIchail
 ___
 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] lpdf.checkedkey has problem with false values

2014-09-15 Thread Michail Vidiassov
Dear Peter,

 More a lua design decision. 'nil' is equal to 'false' here

I know no CS theory behind lua design, but try this:
\starttext
\startluacode
if nil == false then
  io.write(nil == false\n)
end
if nil ~= false then
  io.write(nil ~= false\n)
end
\stopluacode
TEST
\stoptext

and get

nil ~= false

As checkedkey is for reading parameter tables, based on user input,
there may be real difference between a property not set (i.e. nil) and
one set to be false. What if the default setting is true, for example?

Michail
___
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] lpdf.checkedkey has problem with false values

2014-09-15 Thread Aditya Mahajan

On Mon, 15 Sep 2014, Michail Vidiassov wrote:


Dear Peter,


More a lua design decision. 'nil' is equal to 'false' here


I know no CS theory behind lua design, but try this:
\starttext
\startluacode
if nil == false then
 io.write(nil == false\n)
end
if nil ~= false then
 io.write(nil ~= false\n)
end
\stopluacode
TEST
\stoptext

and get

nil ~= false


I think that what Peter meant was:

if nil then
 
end

if not nil then
  ...
end

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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


[NTG-context] problem with buffer

2014-09-15 Thread Kenny
I'm writing a module to typeset problems/tests. Depending on a flag, 
solutions are either displayed or not. If the solutions are not displayed, 
I want to give a certain amount of empty vertical space for the student's 
work. This is where my difficulty begins.

The typesetting works with the solutions displayed (\def\examshowsolutions}
{yes}) but not with the empty vertical space (\def\examshowsolutions{no}). 
I get an Emergency stop that I cannot figure out. Here's the code for a 
minimal example of my difficulty..

\def\setupsolutions{
  \doifelse{\examshowsolutions}{yes}
   {\defineenumeration[SOLUTION] % display the solutions
  [text=\Word{solution},number=no,
   after={\vskip1ex}]}
   {\definebuffer[SOLUTION] % hide solutions,
\setupbuffer[SOLUTION][local=yes]}
 }

\def\startsolution{\dosingleempty\dostartsolution}

\def\dostartsolution[#1]{
 \getparameters[solution][height=1em,] % set defaults (needed in case 
parameters missing)
 \iffirstargument
  \writestatus{DEBUG}{--First argument: |#1|}
  \getparameters[solution][#1,]
 \fi
 \writestatus{DEBUG}{--\solutionheight--}
 \startSOLUTION
 \writestatus{DEBUG}{--dostartsolution...finished}
 }
\def\stopsolution{
 \stopSOLUTION
 \writestatus{DEBUG}{--dostopsolution...1}
 \doif{\examshowsolutions}{no}{\godown[\solutionheight]}
 \writestatus{DEBUG}{--dostopsolution...finished}
 }
 
\starttext

\def\examshowsolutions{no} % control whether solutions are displayed
\setupsolutions
 
\startsolution % test without vertical height specified
 Here is a solution.
\stopsolution

\startsolution[height=5em] % test with vertical height specified
 Here is another solution.
\stopsolution

\stoptext

The error occurs with the \startSOLUTION command.

Here's the log file:
(/home/kenny/texlive/2013/texmf-dist/tex/context/base/cont-yes.mkiv

ConTeXt  ver: 2013.05.28 00:36 MKIV current  fmt: 2013.8.6  int: 
english/english

system   'cont-new.mkiv' loaded
(/home/kenny/texlive/2013/texmf-dist/tex/context/base/cont-new.mkiv)
system   files  jobname 'check', input './check', result 'check'
fontslatin modern fonts are not preloaded
languageslanguage 'en' is active
(/home/kenny/courses/Fall2014/phys1310/exam/check.tex{/home/kenny/texlive/2
013/texmf-dist/fonts/map/pdftex/context/mkiv-base.map}
fontspreloading latin modern fonts (second stage)
fontstypescripts  unknown library 'loc'
{/home/kenny/texlive/2013/texmf-dist/fonts/map/dvips/lm/lm-math.map}
{/home/kenny/texlive/2013/texmf-dist/fonts/map/dvips/lm/lm-rm.map}
fonts'fallback modern rm 12pt' is loaded
DEBUG--1em--
))
! Emergency stop.

system   tex  error on line 0 in file : Emergency stop ...

empty file

* cont-yes.mkiv
  
*** (job aborted, no legal \end found)

!  == Fatal error occurred, no output PDF file produced!

___
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] lpdf.checkedkey has problem with false values

2014-09-15 Thread Michail Vidiassov
Dear Aditya, Peter and All,

 I think that what Peter meant was:

the real issue is not teaching me lua and improving the style of my example,
but my complaint (correct or not) about inability of lpdf.checkedkey
to correctly fetch false boolean values: they are fetched as nil, just
as if they were absent or of incorrect type.

Please, someone with time and, preferably, authority - take a look at
lpdf.checkedkey code (5 minutes maximum).
Talking in general about lua, not knowing what lpdf.checkedkey is,
does and is supposed to do, does not look like efficient use of time.

Michail
___
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] lpdf.checkedkey has problem with false values

2014-09-15 Thread Hans Hagen

On 9/15/2014 6:12 PM, Michail Vidiassov wrote:

Dear Aditya, Peter and All,


I think that what Peter meant was:


the real issue is not teaching me lua and improving the style of my example,
but my complaint (correct or not) about inability of lpdf.checkedkey


it looks like your question was not clear then


to correctly fetch false boolean values: they are fetched as nil, just
as if they were absent or of incorrect type.


well, they're just not treated special


Please, someone with time and, preferably, authority - take a look at
lpdf.checkedkey code (5 minutes maximum).
Talking in general about lua, not knowing what lpdf.checkedkey is,
does and is supposed to do, does not look like efficient use of time.


you can try this (untested)

function lpdf.checkedkey(t,key,variant)
local pn = t and t[key]
if pn then
local tn = type(pn)
if tn == variant then
if variant == string then
return pn ~=  and pn or nil
elseif variant == table then
return next(pn) and pn or nil
else
return pn
end
elseif tn == string then
if variant == number then
return tonumber(pn)
elseif variant == boolean then
return toboolean(pn)
end
end
end
end

-
  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] Scientific paper boiler plate

2014-09-15 Thread Kip Warner
On Mon, 2014-09-15 at 15:18 +0200, Joshua Krämer wrote:
 At the moment, I am writing my MD thesis using ConTeXt.  I have
 equations, figures, tables, diagrams, references.  There is also Lua
 code embedded to prepare data tables from CSV files, round values etc.
 Of course, there is a lot in my files that you will not need.  The
 organization of my files  (preamble files, chapter files) may not
 be suitable for your project.  The format of my document (thesis)
 may not be what you want (journal article?).  On these grounds, I do not
 think it is a good idea to take the files from somebody else and alter
 them.  I know this is common in the LaTeX community, and I have seen
 many times that it leads to inconsistent settings, conflicting packages
 and other problems.  Instead, I suggest you to start with an empty file
 and add everything *you* need.  However, if you really want, I can try
 to strip down my files and send you a basic sample.
 
 Kind regards,
 Joshua Krämer

Hey Joshua,

I'm looking more for a journal article format, so even if you managed to
strip down your work into a boiler plate, it might, as you say, still be
not useful for this type of situation.

Thanks a lot anyways for the offer.

Respectfully,

-- 
Kip Warner -- Senior 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] lpdf.checkedkey has problem with false values

2014-09-15 Thread Michail Vidiassov
Dear Hans,

 well, they're just not treated special

IMHO, they have to be treated special.

 you can try this (untested)

I have tested it. It adds nice enhancement, but does not fix the bug
In the following case
local a = {}
a[e] = blabla
a[t] = true
a[f] = false
a[x] = true
a[y] = false
a[z] = nil

your new lpdf.checkedkey correctly fetches t and f, where the old
one failed.
And your new lpdf.checkedkey fails for e - if I attempt to fetch it
as boolean I get false instead of nil.
(That is caused by toboolean returning false for unconvertible data -
unlike tonumber).

But I did not complain about reading strings!

My problem was with y.
Both your new and old lpdf.checkedkey fetch it as nil instead of false.
My (somewhat ugly) idea of the fix is the following

local function lpdf.checkedkey(t,key,variant)
local pn = t and t[key]
if pn then
local tn = type(pn)
if tn == variant then
if variant == string then
return pn ~=  and pn or nil
elseif variant == table then
return next(pn) and pn or nil
else
return pn
end
elseif tn == string then
if variant == number then
return tonumber(pn)
elseif variant == boolean then
 if pn == true then
   return true
elseif pn == false then
   return false
end
  end
end
elseif t and t[key] ~= nil and variant == boolean and
type(t[key]) == boolean then
return t[key]
end
end

Michail
___
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] bug in hyphenation?

2014-09-15 Thread Pablo Rodriguez
Dear list,

I have a simplified verson of the sample I submitted to the list almost
a week ago:

\setuppapersize[A8]
\starttext
\startlinenumbering
\hsize\zeropoint
sentence
sentence
sentence
\stoplinenumbering

\hsize\zeropoint
sentence
sentence
sentence
\stoptext

I’m afraid that line numbering is preventing right hyphenations.

Could anyone be so kind to confirm whether this is a bug or I am missing
something?

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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] lpdf.checkedkey has problem with false values

2014-09-15 Thread Hans Hagen

On 9/15/2014 8:25 PM, Michail Vidiassov wrote:

Dear Hans,


well, they're just not treated special


IMHO, they have to be treated special.


you can try this (untested)


I have tested it. It adds nice enhancement, but does not fix the bug
In the following case
local a = {}
a[e] = blabla
a[t] = true
a[f] = false
a[x] = true
a[y] = false
a[z] = nil

your new lpdf.checkedkey correctly fetches t and f, where the old
one failed.
And your new lpdf.checkedkey fails for e - if I attempt to fetch it
as boolean I get false instead of nil.
(That is caused by toboolean returning false for unconvertible data -
unlike tonumber).

But I did not complain about reading strings!

My problem was with y.
Both your new and old lpdf.checkedkey fetch it as nil instead of false.
My (somewhat ugly) idea of the fix is the following

local function lpdf.checkedkey(t,key,variant)
 local pn = t and t[key]
 if pn then
 local tn = type(pn)
 if tn == variant then
 if variant == string then
 return pn ~=  and pn or nil
 elseif variant == table then
 return next(pn) and pn or nil
 else
 return pn
 end
 elseif tn == string then
 if variant == number then
 return tonumber(pn)
 elseif variant == boolean then
  if pn == true then
return true
 elseif pn == false then
return false
 end
   end
 end
 elseif t and t[key] ~= nil and variant == boolean and
type(t[key]) == boolean then
 return t[key]
 end
end


more like

function lpdf.checkedkey(t,key,variant)
local pn = t and t[key]
if pn ~= nil then
local tn = type(pn)
if tn == variant then
if variant == string then
return pn ~=  and pn or nil
elseif variant == table then
return next(pn) and pn or nil
else
return pn
end
elseif tn == string then
if variant == number then
return tonumber(pn) -- or nil
elseif variant == boolean then
return string.is_boolean(pn,nil,true)
end
end
end
end



-
  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] lpdf.checkedkey has problem with false values

2014-09-15 Thread Michail Vidiassov
Dear Hans,

 more like

 function lpdf.checkedkey(t,key,variant)

thank you. That works. Please, commit.

Michail

PS.
lpdf.checkedkey issue was raised while I reviewed 3D PDF support.
But there are greater problems:

It seems that u3d inclusion stopped to work in the current (2014.09.06
20:59) ConTeXt.
Texlive 2014 works.

As far as I can track, the problem is caused by the change in
function register(askedname,specification) from grph-inc.lua:
if format %a supported by output file format (and u3d falls under
this category)
specification.found is set to false in the current ConTeXt.
If I set it to true in this case (as in TeXLive 2014 version of
ConTeXt) things start to work again.
May be by doing so I am reversing some unfinished change, but it works for me.

The relevant patch:
@@ -725,7 +725,7 @@
 report_inclusion(format %a natively supported by
backend,format)
 end
 else
-specification.found = false
+specification.found = true -- was false
 if trace_figures then
 report_inclusion(format %a supported by output
file format,format)
 end
___
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
___