-
Notifications
You must be signed in to change notification settings - Fork 0
/
mathdimen.sty
61 lines (49 loc) · 1.42 KB
/
mathdimen.sty
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
\ProvidesPackage{mathdimen}[2012/03/01 v0.1]
\RequirePackage{newfile,etoolbox}
%variable definitions
\@ifpackageloaded{tex4ht}{}{
\newoutputstream{mathdim}
\openoutputfile{\jobname.mtd}{mathdim}
}
\newcount\dmath@count
\newbox\MathBox
\newcommand\save@math@dimens{%
\addtostream{mathdim}{\noexpand\mathdim{\the\dmath@count}{\the\wd\MathBox}{\the\ht\MathBox}{\the\dp\MathBox}}
}
\newcommand\step@math@count{\global\advance\dmath@count by1\relax}
% Display math definitions
\newcommand\Start@math@box{%
\setlength{\abovedisplayskip}{0pt}
\setlength{\belowdisplayskip}{0pt}
\setbox\MathBox=\vbox\bgroup
}
\newcommand\End@math@box{%
\egroup\copy\MathBox%
\setbox\MathBox=\vbox{\unvbox\MathBox\unskip\unpenalty\unkern}%
\step@math@count
%\advance\dmath@count by1\relax%
%Výška: \the\ht\MathBox, šířka \the\wd\MathBox
%\addtostream{mathdim}{\noexpand\mathdim{\the\dmath@count}{\the\wd\MathBox}{\the\ht\MathBox}{\the\dp\MathBox}}
\save@math@dimens
}
%We must redefine the math commands
\let\oldbdisplay\[
\let\oldedisplay\]
\let\oldbmath\(
\let\oldemath\)
\renewcommand\[{%\]
\Start@math@box\oldbdisplay
}
\renewcommand\]{%
\oldedisplay\End@math@box
}
\renewcommand\({%%% \) end brackets because of broken syntax highlighting in gedit
\setbox\MathBox=\hbox\bgroup\oldbmath
}
\renewcommand\){%
\oldemath\egroup%
\step@math@count
\save@math@dimens
}
\BeforeBeginEnvironment{equation}{\Start@math@box}
\AfterEndEnvironment{equation}{\End@math@box}