Re: [NTG-context] bar graphs, m-graph, sarith

2013-07-07 Thread Alan BRASLAU
Metapost now has double precision arithmetic, so one no longer needs to
use the string arithmetic macros. However, it may be necessary to use
scantokens as in

clearxy;
z = (scantokens v1, scantokens v2);
augment.p(x,0);
augment.p(x,y);
x := x + 0.4 ;
augment.p(x,y);
augment.p(x,0);


Alan


On Sat, 6 Jul 2013 22:01:06 -0400
John Kitzmiller k...@inradius.net wrote:

 When trying to make a bar graph with m-graph.mkiv and sarith, the
 command Ssub (string subtract) seems to augment.p(v1 Sadd
 0.4,v2);Sadd instead. An mwe of a bar graph:
 
  (data1 is a separate file containing
   01 02
   02 03)
 
 \usemodule[m-graph]
 \startMPpage[instance=graph]
 input sarith;
 draw begingraph(5cm,5cm);
  gdata(data1, v,
   path p;
   augment.p(v1,0);
   augment.p(v1,v2)
   augment.p(v1 Sadd 0.4,v2);
   augment.p(v1 Sadd 0.4,0);
   gfill p--cycle withcolor .8white;
   gdraw p--cycle;
   );
 endgraph;
 \stopMPpage
 
 ...which gives bars of width 0.4 starting at abscissa 1 and 2 as
 expected. To increase the width of the bars to 0.8 and have them
 centered over 1 and 2, I expect to Ssub from the first two augments:
 
 \usemodule[m-graph]
 \startMPpage[instance=graph]
 input sarith;
 draw begingraph(5cm,5cm);
  gdata(data1, v,
   path p;
   augment.p(v1 Ssub 0.4,0);
   augment.p(v1 Ssub 0.4,v2);
   augment.p(v1 Sadd 0.4,v2);
   augment.p(v1 Sadd 0.4,0);
   gfill p--cycle withcolor .8white;
   gdraw p--cycle;
   );
 endgraph;
 \stopMPpage
 
 However, the Ssub adds instead and gives a line at 1.4 and 2.4.
 
 Compiling the above with mpost or mptopdf gives the desired
 result(s), but I am curious if this can be resolved so such bar
 graphs could be made within ConTeXT/METAFUN.
 
 Thanks! John
___
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] relative references?

2013-07-07 Thread Steffen Kram
Hi Wolfgang,

I already tried using \setuphead[…][prefix=+], this are my definitions:

\setuphead [chapter][command=\ChapterCmd, style={\ss\bfc}, page=right, 
number=yes, frame=off, placehead=yes, align=left, before={}, 
after={\blank[3*line]}, header=nomarking, prefix=+]
\setuphead [section][style={\ss\bfb}, page=no, number=yes, frame=off, 
placehead=yes, align=right, before={\testpage[6]\blank[2*line]}, 
after={\blank}, prefix=+]
\setuphead [subsection][style={\ss\bfa}, page=no, number=yes, frame=off, 
placehead=yes, align=right, before={\testpage[6]\blank[line]}, after={}, 
prefix=+]

But I can't get cross-chapter reference to work, e.g. a subsection in my second 
chapter is defined as 

\chapter[basics]{foo}
…
\section[development]{bar}


referencing this from my fourth chapter with

\in{Abschnitt}[basics:development]

just produces Abschnitt ??. Have I set up something wrong?

Thanks!
Steffen



Am 04.07.2013 um 12:07 schrieb Wolfgang Schuster schuster.wolfg...@gmail.com:

 
 Am 02.07.2013 um 17:30 schrieb Steffen Kram s...@kram.io:
 
 Hello,
 
 is it possible to reference parts of a document in a relative style?
 
 My structure is as follows:
 
 \startproduct
 …
 \startbodymatter
 \component chapterFoo/main
 \component chapterBar/main
 \stopbodymatter
 … 
 \stopproduct
 
 Each of my chapters uses \chapter, \section … \subsubsubsection markers. I 
 would like to use references for each of them.
 
 
 Is it possible to reference for example the subsection Foo AA from the 
 chapter start with an relative reference such as 
 
 \chapter[sec:foo]{Foo}
 
 \in[fooA:fooAA]
 
 \section[fooA]{Foo A}
 
 \subsection[fooAA]{Foo AA}
 
 
 but when referencing it from the second chapter use a absolute reference:
 
 \chapter[sec:bar]{Bar}
 
 \in[sec:foo:fooA:fooAA] …
 
 Is this possible? Or must I use absolute references and identifiers 
 everywhere?
 
 Take a look at page 149ff at the context manual [1] where this is described.
 
 [1] http://www.pragma-ade.nl/show-man-9.htm
 
 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] Wrong markings

2013-07-07 Thread Marco Patzer
Hi,

in the following example the markings are wrong.

\setupheadertexts
  [{\getmarking[section][both]}]
  [{\getmarking[section][first]\space\emdash\space
   \getmarking[section][last]}]

\starttext
  \def\aa#1{\section{#1}\input knuth}
  \processcommacommand [A, B, C, D, E] \aa
\stoptext

I expect the markings on the left and right to be the same and show
A–C on the first page and D–E on the second one. Looks like a bug to
me.

current version: 2013.06.10 22:51

Marco


signature.asc
Description: Digital signature
___
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] [dev-context] palatino at 10.5pt bold not found when using project structure w/ MkIV

2013-07-07 Thread Wolfgang Schuster

Am 06.07.2013 um 12:33 schrieb Sanjoy Mahajan san...@olin.edu:

 Wolfgang,
 
 Thank you for all your solutions!
 
 2. You can omit the \usetypescript line.
 
 Good to know.  Does the palatino keyword in \setupbodyfont
 automatically do that now (in Mark IV)?
 
 Should I wikify that bit of information (as MkIV-only)?  (Since I don't
 really understand how the fonts work, I am hesitant to wikify much about
 it and put up incorrect information.)

The normal way to load a new font from a external typescript is

\usetypescriptfile[name]
\usetypescript[name]
\setupbofyfont[name]

In MkII you don’t need \usetypescriptfile to load the default fonts (times,
palatino etc.) because context loads them when it generates the format
but MkIV loads them the fonts are used to save memory.

Because in many cases the name of the file is the same (with a “type-” prefix)
as the font context tries to load the file itself when you enable the font with
\setupbodyfont, even the \usetypescript call (the second argument isn’t needed
because we aren’t restricted to 256 anymore with LuaTeX) isn’t necessary
because this is also done by \setupbodyfont.

 3. Move the \setupbodyfont setting *before* \startcomponent.
 
 Right, I found that by experiment.  But how should you do that with
 projects?  The \setupbodyfont is usually part of an environment file,
 which is loaded by the project file.  Should the \project project_file
 line be placed before the \startcomponent?  Like this:
 
  \project project_file
  \startcomponent component_name
 
 If that's the recommended way, I can update
 http://wiki.contextgarden.net/Project_structure

You can do this. It’s always better to make the setup of the document before
\starttext, startcomponent etc. because some values are set/reset with 
\starttext.

 4. Add \definebodyfontenvironment[10.5pt] to your document.
 
 Thanks, that fixes everything.  On the theory of teaching a man to fish,
 how did you learn so much about making ConTeXt do just the right thing?
 
 1. Use the normal and not the developer list for such a question.
 
 I thought it was a bug (and it might be, though your
 definebodyfontenvironment solution makes me wonder if it is just my not
 knowing enough).  In general, should bug reports go to the regular list?


The only things which are posted on the developer list nowadays are bug reports
with possible fixes or extensions to the context programing language.

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] [util-jsn] incorrect handling of escapes

2013-07-07 Thread Philipp Gesang
Hi,

the JSON parser handles backslash escapes improperly. Example:

local data = [[ { escapes : (\)(\\)(\b)(\f)(\n)(\r)(\t),
  invalid : \'\v } ]]
local stuff = utilities.json.tolua (data)
inspect(stuff)

Currently it chokes on double quotes and treats the other escapes
like Lua. Fix suggestion attached.

Best regards,
Philipp

--- util-jsn.lua.orig	2013-07-08 00:09:21.834400224 +0200
+++ util-jsn.lua	2013-07-08 00:54:25.889668771 +0200
@@ -15,7 +15,7 @@
 -- Reminder for me: check usage in framework and extend when needed. Also document
 -- it in the cld lib documentation.
 
-local P, V, R, S, C, Cc, Cs, Ct, Cf, Cg = lpeg.P, lpeg.V, lpeg.R, lpeg.S, lpeg.C, lpeg.Cc, lpeg.Cs, lpeg.Ct, lpeg.Cf, lpeg.Cg
+local P, V, R, S, C, Cc, Cs, Ct, Cf, Cg, Cp = lpeg.P, lpeg.V, lpeg.R, lpeg.S, lpeg.C, lpeg.Cc, lpeg.Cs, lpeg.Ct, lpeg.Cf, lpeg.Cg, lpeg.Cp
 local lpegmatch = lpeg.match
 local format = string.format
 local utfchar = utf.char
@@ -42,7 +42,15 @@
 local whitespace = lpeg.patterns.whitespace
 local optionalws = whitespace^0
 
-local escape = C(P(\\u) / 0x * S(09,AF,af)) / function(s) return utfchar(tonumber(s)) end
+local escape_a   = C(P(\\u) / 0x * S(09,AF,af)) / function(s) return utfchar(tonumber(s)) end
+local escape_b   = P([[\]]) /  * S([[\/]]) -- represent themselves
+local escape_c   = P([[\b]]) / \010 -- backspace
+ + P([[\f]]) / \014 -- form feed
+ + P([[\n]]) / \n
+ + P([[\r]]) / \r
+ + P([[\t]]) / \t
+local invalid= P([[\]]) /  * (Cp() * P(1) / function (pos, chr) --[[ bug_user_about_invalid_escape (chr, pos) ]] return  end)
+local escape = escape_a + escape_b + escape_c + invalid
 local jstring= dquote * Cs((escape + (1-dquote))^0) * dquote
 local jtrue  = P(true)  * Cc(true)
 local jfalse = P(false) * Cc(false)


pgpKZ5aYPxA60.pgp
Description: PGP signature
___
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
___