diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/bytefield/bytefield.sty | 262 |
1 files changed, 194 insertions, 68 deletions
diff --git a/Master/texmf-dist/tex/latex/bytefield/bytefield.sty b/Master/texmf-dist/tex/latex/bytefield/bytefield.sty index 40ce86b2517..98e039072c7 100644 --- a/Master/texmf-dist/tex/latex/bytefield/bytefield.sty +++ b/Master/texmf-dist/tex/latex/bytefield/bytefield.sty @@ -8,7 +8,7 @@ %% %% This is a generated file. %% -%% Copyright (C) 2010 by Scott Pakin <scott+bf@pakin.org> +%% Copyright (C) 2011 by Scott Pakin <scott+bf@pakin.org> %% %% This file may be distributed and/or modified under the conditions of %% the LaTeX Project Public License, either version 1.3a of this license @@ -22,13 +22,15 @@ %% \NeedsTeXFormat{LaTeX2e}[1999/12/01] \ProvidesPackage{bytefield} - [2010/10/31 v1.3 Network protocol diagrams] + [2011/01/25 v2.0 Network protocol diagrams] \RequirePackage{calc}[1998/07/07] +\RequirePackage{keyval} \def\bf@newdimen#1{\advance\count11 by 1 - \ch@ck1\insc@unt\dimen% Check room + \ch@ck1\insc@unt\dimen \allocationnumber=\count11 \dimendef#1=\allocationnumber - \wlog{\string#1=\string\dimen\the\allocationnumber\space (locally)}} + \wlog{\string#1=\string\dimen\the\allocationnumber\space (locally)}% +} \AtBeginDocument{% \begingroup\expandafter\expandafter\expandafter\endgroup \expandafter\ifx\csname locdimen\endcsname\relax @@ -44,42 +46,46 @@ \global\advance\bytefield@height by \bytefield@height@increment} \newcounter{bits@wide} \newsavebox{\entire@bytefield@picture} -\newenvironment{bytefield}[1]{% - \setcounter{bits@wide}{#1}% +\newenvironment{bytefield}[2][]{% + \bf@bytefieldsetup{#1}% + \setcounter{bits@wide}{#2}% \let\old@nl=\\% \let\amp=&% \catcode`\&=10 \openup -1pt \setlength{\bytefield@height}{0pt}% \setlength{\unitlength}{1pt}% - \counting@wordstrue + \global\counting@wordstrue \begin{lrbox}{\entire@bytefield@picture}% \renewcommand{\\}{% - \amp\show@wordlabelr\cr% - \ignorespaces\counting@wordstrue\make@lspace\amp}% - \vbox\bgroup\ialign\bgroup##\amp##\amp##\cr\amp% + \unskip + \amp\show@wordlabelr\cr + \ignorespaces\global\counting@wordstrue\make@lspace\amp}% + \vbox\bgroup\ialign\bgroup##\amp##\amp##\cr\amp }{% - \amp\show@wordlabelr\cr\egroup\egroup% + \amp\show@wordlabelr\cr\egroup\egroup \end{lrbox}% \usebox{\entire@bytefield@picture}} -\newlength{\bitwidth} -\AtBeginDocument{\settowidth{\bitwidth}{\tiny 99i}} -\newlength{\byteheight} -\AtBeginDocument{\setlength{\byteheight}{4ex}} +\newcommand*{\bf@bitformatting}{\tiny} +\newcommand*{\bf@boxformatting}{\centering} +\newlength{\bf@bitwidth} +\settowidth{\bf@bitwidth}{\bf@bitformatting{99i}} +\newlength{\bf@bitheight} +\setlength{\bf@bitheight}{4ex} \newlength{\units@wide} \newlength{\units@tall} \DeclareRobustCommand{\bitbox}[3][lrtb]{% - \setlength{\units@wide}{\bitwidth * #2}% + \setlength{\units@wide}{\bf@bitwidth * #2}% \parse@bitbox@arg{#1}% - \draw@bit@picture{\strip@pt\units@wide}{\strip@pt\byteheight}{#3}} + \draw@bit@picture{\strip@pt\units@wide}{\strip@pt\bf@bitheight}{#3}} \DeclareRobustCommand{\wordbox}[3][lrtb]{% - \setlength{\units@wide}{\bitwidth * \value{bits@wide}}% - \setlength{\units@tall}{\byteheight * #2}% + \setlength{\units@wide}{\bf@bitwidth * \value{bits@wide}}% + \setlength{\units@tall}{\bf@bitheight * #2}% \parse@bitbox@arg{#1}% \draw@bit@picture{\strip@pt\units@wide}{\strip@pt\units@tall}{#3}} \DeclareRobustCommand{\draw@bit@picture}[3]{% \begin{picture}(#1,#2)% - \put(0,0){\makebox(#1,#2){\parbox[c]{#1\unitlength}{% + \put(0,0){\makebox(#1,#2){\parbox{#1\unitlength}{% \bf@newdimen\height \bf@newdimen\depth \bf@newdimen\totalheight @@ -90,7 +96,7 @@ \width=#1\unitlength \def\widthunits{#1}% \def\heightunits{#2}% - \centering #3}}}% + \bf@boxformatting{#3\par}}}}% \ifbitbox@top \put(0,#2){\line(1,0){#1}} \fi @@ -106,7 +112,7 @@ \end{picture}% \ifcounting@words \inc@bytefield@height{\unitlength * \real{#2}}% - \counting@wordsfalse + \global\counting@wordsfalse \fi \ignorespaces} \newif\ifbitbox@top @@ -141,7 +147,7 @@ \fi} \newlength{\units@high} \DeclareRobustCommand{\skippedwords}[1][2ex]{% - \setlength{\units@wide}{\bitwidth * \value{bits@wide}}% + \setlength{\units@wide}{\bf@bitwidth * \value{bits@wide}}% \setlength{\units@high}{1pt * \ratio{\units@wide}{6.0pt}}% \setlength{\units@tall}{#1 + \units@high}% \edef\num@wide{\strip@pt\units@wide}% @@ -155,12 +161,12 @@ \end{picture}% \ifcounting@words \inc@bytefield@height{\unitlength * \real{\num@tall}}% - \counting@wordsfalse + \global\counting@wordsfalse \fi} \DeclareRobustCommand{\bitheader}[2][l]{% \parse@bitbox@arg{lrtb}% - \setlength{\units@wide}{\bitwidth * \value{bits@wide}}% - \setlength{\units@tall}{\heightof{\tiny 9}}% + \setlength{\units@wide}{\bf@bitwidth * \value{bits@wide}}% + \setlength{\units@tall}{\heightof{\bf@bitformatting{1234567890}}}% \setlength{\units@high}{\units@tall * -1}% \def\bit@endianness{#1}% \begin{picture}(\strip@pt\units@wide,\strip@pt\units@tall)% @@ -169,7 +175,7 @@ \end{picture}% \ifcounting@words \inc@bytefield@height{\unitlength * \real{\strip@pt\units@tall}}% - \counting@wordsfalse + \global\counting@wordsfalse \fi \ignorespaces} \def\parse@range@list#1,{% @@ -188,64 +194,76 @@ \ifnum\value{header@val}<\value{max@header@val}% \if\bit@endianness b% \setlength{\header@xpos}{% - \bitwidth * (\value{bits@wide}-\value{header@val}-1)} + \bf@bitwidth * (\value{bits@wide}-\value{header@val}-1)} \else - \setlength{\header@xpos}{\bitwidth * \value{header@val}} + \setlength{\header@xpos}{\bf@bitwidth * \value{header@val}} \fi \put(\strip@pt\header@xpos,0){% - \makebox(\strip@pt\bitwidth,\strip@pt\units@tall){% - \tiny \theheader@val}} + \makebox(\strip@pt\bf@bitwidth,\strip@pt\units@tall){% + \bf@bitformatting{\theheader@val}}} \addtocounter{header@val}{1} \repeat} -\newlength{\curlyshrinkage} -\setlength{\curlyshrinkage}{5pt} -\newlength{\curlyspace} -\AtBeginDocument{\setlength{\curlyspace}{1ex}} -\newlength{\labelspace} -\AtBeginDocument{\setlength{\labelspace}{0.5ex}} +\def\bf@leftcurlyshrinkage{5pt} +\def\bf@rightcurlyshrinkage{5pt} +\def\bf@leftcurlyspace{0pt} +\def\bf@rightcurlyspace{0pt} +\def\bf@leftlabelspace{0pt} +\def\bf@rightlabelspace{0pt} +\gdef\bf@leftcurlyspace{1ex} +\gdef\bf@rightcurlyspace{1ex} +\gdef\bf@leftlabelspace{0.5ex} +\gdef\bf@rightlabelspace{0.5ex} +\let\bf@leftcurly=\{ +\let\bf@rightcurly=\} \newbox{\curly@box} \def\store@rcurly#1#2{% \begingroup - \bf@newdimen\curly@height% - \setlength{\curly@height}{#2 - \curlyshrinkage}% - \bf@newdimen\half@curly@height% + \bf@newdimen\curly@height + \setlength{\curly@height}{#2 - \bf@rightcurlyshrinkage}% + \bf@newdimen\half@curly@height \setlength{\half@curly@height}{0.5\curly@height}% - \bf@newdimen\curly@shift% - \setlength{\curly@shift}{\half@curly@height + 0.5\curlyshrinkage}% + \bf@newdimen\curly@shift + \setlength{\curly@shift}{\bf@rightcurlyshrinkage}% + \setlength{\curly@shift}{\half@curly@height + 0.5\curly@shift}% \global\sbox{#1}{\raisebox{\curly@shift}{% $\xdef\old@axis{\the\fontdimen22\textfont2}$% $\fontdimen22\textfont2=0pt% - \left.\vrule height\half@curly@height - width 0pt - depth\half@curly@height\right\}$% + \left. + \vrule height\half@curly@height + width 0pt + depth\half@curly@height\right\bf@rightcurly$% $\fontdimen22\textfont2=\old@axis$}}% \endgroup } \def\store@lcurly#1#2{% \begingroup - \bf@newdimen\curly@height% - \setlength{\curly@height}{#2 - \curlyshrinkage}% - \bf@newdimen\half@curly@height% + \bf@newdimen\curly@height + \setlength{\curly@height}{#2 - \bf@leftcurlyshrinkage}% + \bf@newdimen\half@curly@height \setlength{\half@curly@height}{0.5\curly@height}% - \bf@newdimen\curly@shift% - \setlength{\curly@shift}{\half@curly@height + 0.5\curlyshrinkage}% + \bf@newdimen\curly@shift + \setlength{\curly@shift}{\bf@leftcurlyshrinkage}% + \setlength{\curly@shift}{\half@curly@height + 0.5\curly@shift}% \global\sbox{#1}{\raisebox{\curly@shift}{% $\xdef\old@axis{\the\fontdimen22\textfont2}$% $\fontdimen22\textfont2=0pt% - \left\{\vrule height\half@curly@height - width 0pt - depth\half@curly@height\right.$% + \left\bf@leftcurly + \vrule height\half@curly@height + width 0pt + depth\half@curly@height\right.$% $\fontdimen22\textfont2=\old@axis$}}% \endgroup } \def\show@wordlabelr{} \newlength{\wordlabelr@start} \newlength{\wordlabelr@end} -\newenvironment{wordgroupr}[1]{% +\newenvironment{rightwordgroup}[1]{% + \endgroup \global\wordlabelr@start=\bytefield@height \gdef\wordlabelr@text{#1}% - \ignorespaces% + \ignorespaces }{% + \begingroup \global\wordlabelr@end=\bytefield@height \gdef\show@wordlabelr{% \sbox{\word@label@box}{% @@ -253,27 +271,30 @@ \settowidth{\label@box@width}{\usebox{\word@label@box}}% \setlength{\label@box@height}{\wordlabelr@end-\wordlabelr@start}% \store@rcurly{\curly@box}{\label@box@height}% - \bf@newdimen\total@box@width% + \bf@newdimen\total@box@width \setlength{\total@box@width}{% - \curlyspace + + \bf@rightcurlyspace + \widthof{\usebox{\curly@box}} + - \labelspace + + \bf@rightlabelspace + \label@box@width}% \begin{picture}(\strip@pt\total@box@width,0) \put(0,0){% - \hspace*{\curlyspace}% + \hspace*{\bf@rightcurlyspace}% \usebox{\curly@box}% - \hspace*{\labelspace}% + \hspace*{\bf@rightlabelspace}% \makebox(\strip@pt\label@box@width,\strip@pt\label@box@height){% \usebox{\word@label@box}}} \end{picture}% \gdef\show@wordlabelr{}}% - \ignorespaces} + \def\@currenvir{rightwordgroup}% + \ignorespaces +} \newlength{\wordlabell@start} \newlength{\wordlabell@end} \newlength{\total@lbox@width} \gdef\make@lspace{} -\newenvironment{wordgroupl}[1]{% +\newenvironment{leftwordgroup}[1]{% + \endgroup \global\wordlabell@start=\bytefield@height \gdef\wordlabell@text{#1}% \sbox{\word@label@box}{% @@ -281,20 +302,21 @@ \settowidth{\label@box@width}{\usebox{\word@label@box}}% \store@lcurly{\curly@box}{5cm}% \setlength{\total@lbox@width}{% - \curlyspace + + \bf@leftcurlyspace + \widthof{\usebox{\curly@box}} + - \labelspace + + \bf@leftlabelspace + \label@box@width}% \global\total@lbox@width=\total@lbox@width \gdef\make@lspace{% \hspace*{\total@lbox@width}% \gdef\make@lspace{}}% - \ignorespaces% + \ignorespaces }{% + \begingroup \global\wordlabell@end=\bytefield@height \bf@newdimen\starting@point \setlength{\starting@point}{% - -\total@lbox@width - \bitwidth*\value{bits@wide}}% + -\total@lbox@width - \bf@bitwidth*\value{bits@wide}}% \sbox{\word@label@box}{% \begin{tabular}[b]{@{}l@{}}\wordlabell@text\end{tabular}}% \settowidth{\label@box@width}{\usebox{\word@label@box}}% @@ -304,14 +326,118 @@ \put(\strip@pt\starting@point,0){% \makebox(\strip@pt\label@box@width,\strip@pt\label@box@height){% \usebox{\word@label@box}}% - \hspace*{\labelspace}% + \hspace*{\bf@leftlabelspace}% \usebox{\curly@box}% - \hspace*{\curlyspace}} + \hspace*{\bf@leftcurlyspace}} \end{picture}% + \def\@currenvir{leftwordgroup}% \ignorespaces} \newlength{\label@box@width} \newlength{\label@box@height} \newsavebox{\word@label@box} +\newcommand{\bf@enter@compatibility@mode@i}{% + \PackageInfo{bytefield}{Entering version 1 compatibility mode}% + \newlength{\bitwidth}% + \newlength{\byteheight}% + \newlength{\curlyspace}% + \newlength{\labelspace}% + \newlength{\curlyshrinkage}% + \settowidth{\bitwidth}{\tiny 99i}% + \setlength{\byteheight}{4ex}% + \setlength{\curlyspace}{1ex}% + \setlength{\labelspace}{0.5ex}% + \setlength{\curlyshrinkage}{5pt}% + \let\newbytefield=\bytefield + \let\endnewbytefield=\endbytefield + \renewenvironment{bytefield}[1]{% + \begin{newbytefield}[% + bitwidth=\bitwidth, + bitheight=\byteheight, + curlyspace=\curlyspace, + labelspace=\labelspace, + curlyshrinkage=\curlyshrinkage]{##1}% + }{% + \end{newbytefield}% + } + \def\wordgroupr{\begin{rightwordgroup}} + \def\endwordgroupr{\end{rightwordgroup}} + \def\wordgroupl{\begin{leftwordgroup}} + \def\endwordgroupl{\end{leftwordgroup}} + \renewcommand{\bytefieldsetup}[1]{% + \PackageError{bytefield}{% + The \protect\bytefieldsetup\space macro is not available in\MessageBreak + version 1 compatibility mode% + }{% + Remove [compat1] from the \protect\usepackage{bytefield} line to + make \protect\bytefieldsetup\MessageBreak + available to this document.\space\space (The document may also need + to be modified to use\MessageBreak + the new bytefield interface.) + }% + }% +} +\newcommand{\wordgroupr}{% + \PackageError{bytefield}{% + Macros \protect\wordgroupr, \protect\wordgroupl, \protect\endwordgroupr, + \MessageBreak + and \protect\endwordgroupl\space no longer exist% + }{% + Starting with version 2.0, bytefield uses \protect\begin{wordgroupr}... + \MessageBreak + \protect\end{wordgroupr} and \protect\begin{wordgroupl}...% + \protect\end{wordgroupl}\MessageBreak + to specify word groups and a new \protect\bytefieldsetup\space macro to + \MessageBreak + change bytefield's various formatting parameters.% + }% +} +\let\endwordgroupr=\wordgroupr +\let\wordgroupl=\wordgroupr +\let\endwordgroupl=\wordgroupr +\define@key{bytefield}{bitwidth}{% + \def\bf@bw@arg{#1}% + \def\bf@auto{auto}% + \ifx\bf@bw@arg\bf@auto + \settowidth{\bf@bitwidth}{\bf@bitformatting{99i}}% + \else + \setlength{\bf@bitwidth}{#1}% + \fi +} +\define@key{bytefield}{bitheight}{\setlength{\bf@bitheight}{#1}} +\define@key{bytefield}{bitformatting}{\def\bf@bitformatting{#1}} +\define@key{bytefield}{boxformatting}{\def\bf@boxformatting{#1}} +\define@key{bytefield}{leftcurly}{\def\bf@leftcurly{#1}} +\define@key{bytefield}{rightcurly}{\def\bf@rightcurly{#1}} +\define@key{bytefield}{leftcurlyspace}{\def\bf@leftcurlyspace{#1}} +\define@key{bytefield}{rightcurlyspace}{\def\bf@rightcurlyspace{#1}} +\define@key{bytefield}{curlyspace}{% + \def\bf@leftcurlyspace{#1}% + \def\bf@rightcurlyspace{#1}% +} +\define@key{bytefield}{leftlabelspace}{\def\bf@leftlabelspace{#1}} +\define@key{bytefield}{rightlabelspace}{\def\bf@rightlabelspace{#1}} +\define@key{bytefield}{labelspace}{% + \def\bf@leftlabelspace{#1}% + \def\bf@rightlabelspace{#1}% +} +\define@key{bytefield}{leftcurlyshrinkage}{\def\bf@leftcurlyshrinkage{#1}} +\define@key{bytefield}{rightcurlyshrinkage}{\def\bf@rightcurlyshrinkage{#1}} +\define@key{bytefield}{curlyshrinkage}{% + \def\bf@leftcurlyshrinkage{#1}% + \def\bf@rightcurlyshrinkage{#1}% +} +\newcommand{\bf@bytefieldsetup}{\setkeys{bytefield}} +\let\bytefieldsetup=\bf@bytefieldsetup +\DeclareOption{compat1}{\bf@enter@compatibility@mode@i} +\def\bf@package@options{} +\DeclareOption*{% + \edef\next{% + \noexpand\g@addto@macro\noexpand\bf@package@options{,\CurrentOption}% + }% + \next +} +\ProcessOptions\relax +\expandafter\bf@bytefieldsetup\expandafter{\bf@package@options} \endinput %% %% End of file `bytefield.sty'. |