On Wed, 06 Jun 2007 19:42:26 -0400
Aditya Mahajan
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]%
\protocolfieldheader[frame=on,width=\dimexpr\c!protocolunitsize*\c!protocolbits\relax]%
{\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)}%
\protocolfieldheader[width=\dimexpr\c!protocolunitsize*#1\relax]{\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]
\startprotocolheader[bits=16,unitsize=1cm][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
Hi Aditya, you wanted something like this \newdimen\scale \scale\1mm \def\rule#1{\hrule width #1\scale} \rule{10} but you made this \def\scale{1mm} \def\rule#1{\hrule width #1\scale} \rule{10} The length of the \hrule in the first example is 10pt (10 \times 1pt = 10pt), while in the second example it is 101pt width (10 & 1pt = 101pt). Wolfgang