ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Help understanding framed!
@ 2013-05-20 19:28 Keith J. Schultz
  2013-05-20 20:01 ` Wolfgang Schuster
  0 siblings, 1 reply; 3+ messages in thread
From: Keith J. Schultz @ 2013-05-20 19:28 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: text/plain, Size: 2131 bytes --]

Hi Everybody,

I am trying to develop a module for writing Nassi-Schneidermann-Diagrams.

I thought I would use framed and metafun. But, I have run into, for me at least,
strange behaviour. I have given MWE and attach the result and a second file which is required.

What I do not understand is why the first line after \MyBoxit is "indented" (see source and result below).

The second is why when I nest \MyBoxit do I get extra vertical space?

Yes, I have found a work around, as I was preparing this mail. Notice, the use of location!
What I would want is to leave "location=top" in the setup. 

Thanx for any help.

regards
	Keith.

MWE:
\useMPlibrary [txt]

\input {Nassi.tex}

\defineframed[MyBoxit][framed]
\setupframed[MyBoxit]
[%background=Statement,%
 frame=none,%
 width=10cm,%
 align=right,%
 location=top,%
 framecolor=yellow,%
 rulethickness=2pt,%
 %backgroundcolor=white,%
 strut=no,%
 heigth=fit,%
 offset=0pt,
 frameoffset=0pt,
 depth=0pt,
 top=,
 backgroundoffset=0pt%
]
      
\defineoverlay[MyBoxit][MyBoxit]

\starttext

Here is the First Problem\par
\MyBoxit[width=10cm]
{
\Statement{First Statement}
\Statement{Second Statement}
}

\crlf
With a \% after the opening brace no problem! \par
\MyBoxit[width=10cm]
{%
\Statement{First Statement}
\Statement{Second Statement}
}
\crlf

Second problem:\par
How do I avoid added space!\par

\MyBoxit[width=10cm]
{%
\IfStatement{$\frac{(x < y)}{z} \gt gh$ OR $x \neq z$ AND \| \\ $z ≥ 2$ AND $z  2$}
\MyBoxit[width=10cm]{%
\MyBoxit[width=5cm]{%
\Statement{First Left}
\Statement{Second Left}
}%
\MyBoxit[width=5cm]{%
\Statement{On the right want to be moved up} 
}
}
\Statement{Third}
}
\crlf
Should look like this\par
\MyBoxit[width=10cm]
{%
\IfStatement{$\frac{(x < y)}{z} \gt gh$ OR $x \neq z$ AND \| \\ $z ≥ 2$ AND $z  2$}
\MyBoxit[width=10cm, location=]{%
\MyBoxit[width=5cm, location=top]{%
\Statement{First Left}
\Statement{Second Left}
}%
\MyBoxit[width=5cm, location=top]{%
\Statement{On the right want to be moved up} 
}
}
\Statement{Third}
}

\stoptext


[-- Attachment #2: NassiTest.pdf --]
[-- Type: application/pdf, Size: 15660 bytes --]

[-- Attachment #3: Nassi.tex --]
[-- Type: application/octet-stream, Size: 1311 bytes --]

% Parts of this code taken from Hans Hagen Metafun
% Other parts inspired by Hagens book


\startuniqueMPgraphic{NassiBox}
     path p ; p := unitsquare
       xscaled \overlaywidth yscaled \overlayheight;
     pickup pencircle scaled \overlaylinewidth ;
     fill p withcolor \MPcolor{\overlaycolor} ;
     draw p withcolor \MPcolor{\overlaylinecolor} ;
\stopuniqueMPgraphic


\defineoverlay[Statement][\uniqueMPgraphic{NassiBox}]


\def\Statement#1%
{\framed%
     [background=Statement,%
      frame=off,%
      width=\overlaywidth,%
      align=right,%
      framecolor=black,%
      rulethickness=2pt,%
      backgroundcolor=white]%
     {#1}%
}

\defineoverlay[IfStatement][\useMPgraphic{IfStatement}]


\def\IfStatement#1%
{\framed%
     [background=IfStatement,%
      frame=off,%
      width=\overlaywidth,%
      align=right%
      framecolor=black,%
      rulethickness=2pt,%
      backgroundcolor=white]%
     {\cbox{ #1 \\ ?}}%
}

\startuseMPgraphic{IfStatement}
	path ifp; path jp, p; p:=   ( 0, 1) -- (0.5, 0) -- (1 , 1) -- (1, 0) -- (0, 0) -- (0,1) -- (1,1) -- cycle;
	ifp := p xscaled \overlaywidth yscaled \overlayheight;
     pickup pencircle scaled \overlaylinewidth ;
     fill ifp withcolor \MPcolor{\overlaycolor} ;
     draw ifp withcolor \MPcolor{\overlaylinecolor} ;
\stopuseMPgraphic

[-- Attachment #4: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Help understanding framed!
  2013-05-20 19:28 Help understanding framed! Keith J. Schultz
@ 2013-05-20 20:01 ` Wolfgang Schuster
  2013-05-20 21:53   ` Keith J. Schultz
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Schuster @ 2013-05-20 20:01 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 20.05.2013 um 21:28 schrieb Keith J. Schultz <keithjschultz@web.de>:

> Hi Everybody,
> 
> I am trying to develop a module for writing Nassi-Schneidermann-Diagrams.
> 
> I thought I would use framed and metafun. But, I have run into, for me at least,
> strange behaviour. I have given MWE and attach the result and a second file which is required.
> 
> What I do not understand is why the first line after \MyBoxit is "indented" (see source and result below).
> 
> The second is why when I nest \MyBoxit do I get extra vertical space?
> 
> Yes, I have found a work around, as I was preparing this mail. Notice, the use of location!
> What I would want is to leave "location=top" in the setup. 

I suggest to read chapter 8 in Einführung in TeX [1], a german book about plain TeX
because basic knowledge about boxes can help a lot in your case.

[1] http://www.ruhr-uni-bochum.de/www-rz/schwanbs/TeX/

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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Help understanding framed!
  2013-05-20 20:01 ` Wolfgang Schuster
@ 2013-05-20 21:53   ` Keith J. Schultz
  0 siblings, 0 replies; 3+ messages in thread
From: Keith J. Schultz @ 2013-05-20 21:53 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Wolfgang,

Thanx for the pointer I have downloaded.

As I do not no how framed is actually implemented, I am not sure it will help much.

One of the reason I used LaTeX, then XeLaTeX, then LuaLaTeX, and now ConTeXt is
because I do not grock TeX. 

I realized by "misusing" the framed environment and metafun I could achieve what I need
without a lot of calculations. I already have a similar module for LuaLaTeX using TikZ, but
I can get more milage levagering framed.  

Right, now I working out the visual representation and will develop and interface so that 
that the user does not need to worry about finer parts of the context syntax.

regards
	Keith.


Am 20.05.2013 um 22:01 schrieb Wolfgang Schuster <schuster.wolfgang@gmail.com>:

> 
> Am 20.05.2013 um 21:28 schrieb Keith J. Schultz <keithjschultz@web.de>:
> 
>> Hi Everybody,
>> 
>> I am trying to develop a module for writing Nassi-Schneidermann-Diagrams.
>> 
>> I thought I would use framed and metafun. But, I have run into, for me at least,
>> strange behaviour. I have given MWE and attach the result and a second file which is required.
>> 
>> What I do not understand is why the first line after \MyBoxit is "indented" (see source and result below).
>> 
>> The second is why when I nest \MyBoxit do I get extra vertical space?
>> 
>> Yes, I have found a work around, as I was preparing this mail. Notice, the use of location!
>> What I would want is to leave "location=top" in the setup. 
> 
> I suggest to read chapter 8 in Einführung in TeX [1], a german book about plain TeX
> because basic knowledge about boxes can help a lot in your case.
> 
> [1] http://www.ruhr-uni-bochum.de/www-rz/schwanbs/TeX/
> 

___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-05-20 21:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-20 19:28 Help understanding framed! Keith J. Schultz
2013-05-20 20:01 ` Wolfgang Schuster
2013-05-20 21:53   ` Keith J. Schultz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).