ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* How to make \framed ignore the width of the rule
@ 2007-06-06 23:42 Aditya Mahajan
  2007-06-07 10:16 ` Wolfgang Schuster
  2007-06-07 17:19 ` How to make \framed " Hans Hagen
  0 siblings, 2 replies; 6+ messages in thread
From: Aditya Mahajan @ 2007-06-06 23:42 UTC (permalink / raw)
  To: Context Mailing List List

Hi,

How can I make \framed ignore the width of the rule? I am trying to 
typeset internet protocol headers, but I cannot fully get what I want. 
Here is my attempt:

\unprotect

\makecounter{v!protocolheaderlength}

\defineframed[protocolfieldheader]
             [location=lohi,height=3\lineheight,offset=none,strut=yes]


\def\startprotocolheader
  {\dodoubleempty\dostartprotocolheader}

\def\dostartprotocolheader[#1][#2]%
  {\getparameters[c!protocol][#1]%
   \let\field\protocolheaderfield
   \resetcounter{v!protocolheaderlength}%
   \vbox\bgroup
%    \ruledvbox\bgroup
   \removeunwantedspaces
   \dontleavehmode
   \protocolfieldheader[frame=on,width=\c!protocolbits\c!protocolunitsize]%
   {\let\\\crlf\bold #2}\crlf}

\def\stopprotocoloheader
  {\egroup}

\def\protocolheaderfield#1#2%
  {\doif{\countervalue{v!protocolheaderlength}}{\c!protocolbits}
   {\resetcounter{v!protocolheaderlength}\crlf}%
   \removeunwantedspaces
   \dontleavehmode
   \protocolfieldheader[width=#1\c!protocolunitsize]{\let\\\crlf #2\\(#1)}%
    \incrementcounter{v!protocolheaderlength}{#1}}


\protect

% \showstruts
% \showboxes

\starttext


% Why should unitsize=1mm. Are things being scaled by another factor?
\startprotocolheader[bits=16,unitsize=1mm][General MAC Headers]
  \field    {1}   {HT}
  \field    {1}   {EC}
  \field    {6}   {Type}
  \field    {1}   {ESF}
  \field    {1}   {CI}
  \field    {2}   {EKS}
  \field    {1}   {Rsv}
  \field    {3}   {LEN MSB}
  \field    {8}   {LEN LSB}
  \field    {8}   {CID MSB}
  \field    {8}   {CID LSB}
  \field    {8}   {HCS}
\stopprotocoloheader


\stoptext


Notice that all the lines are not of the same size. It seems that the 
rules of framed are causing the frame to be of a larger width.

Also am I missing a scaling factor in width= expressions above. 
Everything looks fine with unitsize=1mm, but the final figure is 
clearly larger than 16mm. I am confused as to what is happening.

Is there any better way to do this?

Thanks,
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

end of thread, other threads:[~2007-06-07 17:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-06 23:42 How to make \framed ignore the width of the rule Aditya Mahajan
2007-06-07 10:16 ` Wolfgang Schuster
2007-06-07 15:03   ` How to make framed " Aditya Mahajan
2007-06-07 16:54   ` How to make \framed " David Arnold
2007-06-07 17:07     ` How to make framed " Aditya Mahajan
2007-06-07 17:19 ` How to make \framed " Hans Hagen

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).