summaryrefslogtreecommitdiff
path: root/macros/plain/contrib/pitex/inserts.ptx
blob: 70155f5d7ebb8402d3ee29ce6aba8c53b9614187 (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
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
% This is a mess.
\newinsert\ptx@insert_footnotes
\dimen\ptx@insert_footnotes20\baselineskip
\skip\ptx@insert_footnotes12pt
\count\ptx@insert_footnotes1000

\newcount\ptx@footnote_count
\newbox\ptx@footnote_box
\newif\iffootnote

\def\footnote{%
  \global\advance\ptx@footnote_count1
  \maintextfalse \footnotetrue
  \ifnext[
    {\ptx@label_withand{\the\ptx@footnote_count}\ptx@footnote}
    {\ptx@footnote}%
  }
\long\def\ptx@footnote#1{%
  {\verysmall
  \unskip\kern.1em
  \raise.53em\hbox{\the\ptx@footnote_count}%
  \global\setbox\ptx@footnote_box\hbox{\the\ptx@footnote_count}%
  }%
  \insert\ptx@insert_footnotes\bgroup
    \verysmall
    \baselineskip12pt
    \leftskip=0pt \rightskip=\leftskip
    \floatingpenalty20000
    \noindent\vrule width0pt depth0pt height9pt
    \hbox to 0pt{\hss\the\ptx@footnote_count\hskip.5em\hfill}#1%
  \egroup
  \futurelet\temp\getpunc
  }

\def\getpunc{%
  \bgroup
  \ifx\temp\virgule
    \kern-.4\wd\ptx@footnote_box,%
    \egroup
    \expandafter\gobble
  \else
    \ifx\temp\point
      \kern-.4\wd\ptx@footnote_box.%
      \egroup
      \expandafter\expandafter\expandafter\gobble
    \else
      \egroup
    \fi
  \fi
  \maintexttrue \footnotefalse
  }  


\newinsert\ptx@insert_figures
\dimen\ptx@insert_figures\vsize
\count\ptx@insert_figures1000
\newcount\ptx@figure_count
\newcount\ptx@table_count
\newbox\ptx@figure_captionbox
\newif\iffigure

\newblock*\figure
  {\ifnextnospace*
     {\def\ptx@figure_type{table}\def\ptx@figure_word{Table}\gobbleoneand\ptx@figure_do}
     {\def\ptx@figure_type{figure}\def\ptx@figure_word{Fig.}\ptx@figure_do}}
  {\egroup
   \insert\ptx@insert_figures{%
     \penalty0
     \floatingpenalty0
     \vbox to \ptx@figure_measure{0}{\ht\ptx@box_temp+\dp\ptx@box_temp+\ht\ptx@figure_captionbox}{2\baselineskip}{%
       \box\ptx@box_temp
       \vfill
       \vskip\baselineskip
       \box\ptx@figure_captionbox
       \vskip\baselineskip}}}
\def\ptx@figure_do{%
  \maintextfalse
  \figuretrue
  \global\advance\usecs{ptx@\ptx@figure_type _count}1
  \def\ptx@label{\usevalue chapter:internalcount .\the\usecs{ptx@\ptx@figure_type _count}}%
  \ifnextnospace[
     {\ptx@figure_getcaption}
     {\ptx@figure_getcaption[]}}

\def\ptx@figure_getcaption[#1]{%
  \setbox\ptx@figure_captionbox\vbox{%
    \leftskip3em \rightskip\leftskip \parindent0pt
    \ifdefined\figurefont
      \figurefont
    \else
      \verysmall
    \fi
    \baselineskip16pt
    \leavevmode
    \llap{\bf \ptx@figure_word~\usevalueand chapter:internalcount {.}{}\the\usecs{ptx@\ptx@figure_type _count}\hskip.5em}#1}%
  \setbox\ptx@box_temp=\vbox\bgroup
    \leftskip0pt plus1fill \rightskip\leftskip \parindent0pt
  }

\newwhile\ptx@figure_measure3{#1+1}{#2}{#3}{%
  \reverse\straighteniff{ifdim}
    {\dimexpr\baselineskip*\numexpr(#1)<\dimexpr(#2)\relax}
    {\breakwhile{\dimexpr(\numexpr(#1)\baselineskip\reverse\iffemptystring{#3}{+#3})\relax}}
  }

\newblock\infigure
  {\par \setbox\ptx@box_temp=\hbox\bgroup
   \leftskip0pt plus1fill \rightskip\leftskip \parindent0pt }
  {\egroup
   \kern-\prevdepth \nointerlineskip
   \vbox to \ptx@figure_measure{0}{\ht\ptx@box_temp+\dp\ptx@box_temp}{}
     {\vfil\box\ptx@box_temp\vfil}%
  }