ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: "Keith J. Schultz" <keithjschultz@web.de>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Help understanding framed!
Date: Mon, 20 May 2013 21:28:00 +0200	[thread overview]
Message-ID: <9A280453-F1E6-487A-A99F-082AF769B102@web.de> (raw)

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

             reply	other threads:[~2013-05-20 19:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-20 19:28 Keith J. Schultz [this message]
2013-05-20 20:01 ` Wolfgang Schuster
2013-05-20 21:53   ` Keith J. Schultz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9A280453-F1E6-487A-A99F-082AF769B102@web.de \
    --to=keithjschultz@web.de \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).