summaryrefslogtreecommitdiff
path: root/graphics/circuit_macros/boxdims.sty
blob: 22b76d73fd9c63fb51d836fd505a12bd508d6e7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
%
% boxdims.sty, for use with m4 preprocessors.  Last modified 30 Apr 2004.
%
% \boxdims{arg1}{arg2} expands to arg2, but writes into file \jobname.dim
% the m4 definitions for macros arg1_h, arg1_w, arg1_d, the height, width
% and depth of \hbox{arg2}.
%
% \defboxdim{arg1}{arg2} writes the definitions but expands to nothing.
%
% \boxdimfile{filename} sets the output file to filename, default \jobname.dim
%
\ProvidesPackage{boxdims}
         [2004/04/30 v2.0 Macros: boxdimfile, boxdims, defboxdim (DA)]

\newwrite\@dimensionfile
\newif\if@dimfile
\newbox\dimbox

\def\boxdimfile#1{\immediate\openout\@dimensionfile=#1\global\@dimfiletrue%
  \typeout{ boxdims.sty v2.0: Writing dimension file #1 }}%

\def\boxdims#1#2{\defboxdim{#1}{#2}#2}

\def\defboxdim#1#2{\if@dimfile\else%
    \immediate\openout\@dimensionfile=\jobname.dim\global\@dimfiletrue%
    \typeout{ boxdims.sty v2.0: Writing dimension file \jobname.dim }\fi%
  \setbox\dimbox=\hbox{#2}%
  \begingroup\@sanitize\edef\@tempa{\write\@dimensionfile{%
  \@defboxdim{#1}}}\expandafter\endgroup\@tempa}
\def\@defboxdim#1{%
define(`#1_w',\the\wd\dimbox__)%
define(`#1_h',\the\ht\dimbox__)%
define(`#1_d',\the\dp\dimbox__)dnl}