* 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
* Re: How to make \framed ignore the width of the rule
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:19 ` How to make \framed " Hans Hagen
1 sibling, 2 replies; 6+ messages in thread
From: Wolfgang Schuster @ 2007-06-07 10:16 UTC (permalink / raw)
To: ntg-context
On Wed, 06 Jun 2007 19:42:26 -0400
Aditya Mahajan <adityam@umich.edu> wrote:
> 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
___________________________________________________________________________________
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
* Re: How to make framed ignore the width of the rule
2007-06-07 10:16 ` Wolfgang Schuster
@ 2007-06-07 15:03 ` Aditya Mahajan
2007-06-07 16:54 ` How to make \framed " David Arnold
1 sibling, 0 replies; 6+ messages in thread
From: Aditya Mahajan @ 2007-06-07 15:03 UTC (permalink / raw)
To: ntg-context
Hi Wolfgang
Quoting Wolfgang Schuster <schuster.wolfgang@googlemail.com>:
> On Wed, 06 Jun 2007 19:42:26 -0400
> Aditya Mahajan <adityam@umich.edu> wrote:
>
>>
>> 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.
>>
> 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).
Ah. Thank you. Now I understand what was happening. I had tried
\dimexpr but I did \dimexpr scale * dimension \relax and got an error.
Now I realize that the correct way to use \dimexpr is dimension * scale.
Now everything looks nice. 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
* Re: How to make \framed ignore the width of the rule
2007-06-07 10:16 ` Wolfgang Schuster
2007-06-07 15:03 ` How to make framed " Aditya Mahajan
@ 2007-06-07 16:54 ` David Arnold
2007-06-07 17:07 ` How to make framed " Aditya Mahajan
1 sibling, 1 reply; 6+ messages in thread
From: David Arnold @ 2007-06-07 16:54 UTC (permalink / raw)
To: mailing list for ConTeXt users
Huh?
This:
\starttext
\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}
\stoptext
Got me this error:
! Undefined control sequence.
l.4 \newdimen\scale \scale\1
mm
What am I missing?
On Jun 7, 2007, at 3:16 AM, Wolfgang Schuster wrote:
> On Wed, 06 Jun 2007 19:42:26 -0400
> Aditya Mahajan <adityam@umich.edu> wrote:
>
>> 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
> ______________________________________________________________________
> _____________
> 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
> ______________________________________________________________________
> _____________
___________________________________________________________________________________
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
* Re: How to make framed ignore the width of the rule
2007-06-07 16:54 ` How to make \framed " David Arnold
@ 2007-06-07 17:07 ` Aditya Mahajan
0 siblings, 0 replies; 6+ messages in thread
From: Aditya Mahajan @ 2007-06-07 17:07 UTC (permalink / raw)
To: ntg-context
Quoting David Arnold <dwarnold45@suddenlink.net>:
> Huh?
>
> This:
>
> \starttext
>
> \newdimen\scale \scale\1mm
Should be
\newdimen\scale \scale1mm
> \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}
>
> \stoptext
>
> Got me this error:
>
> ! Undefined control sequence.
> l.4 \newdimen\scale \scale\1
> mm
>
> What am I missing?
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
* Re: How to make \framed ignore the width of the rule
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 17:19 ` Hans Hagen
1 sibling, 0 replies; 6+ messages in thread
From: Hans Hagen @ 2007-06-07 17:19 UTC (permalink / raw)
To: mailing list for ConTeXt users
Aditya Mahajan wrote:
> 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:
>
you have to skip back linewidth then between boxes
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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).