summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/asyfig/asyalign.sty
blob: 43c48815ee613f84a0f755b1cf665beef8f9426d (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
%% LaTeX2e file `asyalign.sty'
%% generated by the `filecontents' environment
%% from source `asyfig' on 2010/03/20.
%%
\ProvidesPackage{asyalign}

% This package provides code for placing Asymptote labels inline in \LaTeX\ documents. It is adapted from code that is usually included within Aymptote's \<filename>|_.pre| file, which provides a \LaTeX\ preamble for |asy| processing; this preamble is skipped with the \pkg{asyfig} package since all figures inherit the preamble from that of the main document.

\RequirePackage{ifpdf}

\newbox\ASYbox
\newdimen\ASYdimen

\long\def\ASYbase#1#2{%
  \leavevmode
  \setbox\ASYbox\hbox{#1}%
  \ASYdimen=\ht\ASYbox
  \setbox\ASYbox\hbox{#2}%
  \lower\ASYdimen\box\ASYbox
}

\ifpdf

  \long\def\ASYaligned(#1,#2)(#3,#4)#5#6#7{%
    \leavevmode
    \setbox\ASYbox\hbox{#7}%
    \setbox\ASYbox\hbox{%
      \ASYdimen\ht\ASYbox
      \advance\ASYdimen\dp\ASYbox
      \kern#3\wd\ASYbox
      \raise#4\ASYdimen
      \box\ASYbox
    }%
    \put(#1,#2){%
      #5\wd\ASYbox 0pt\dp\ASYbox 0pt\ht\ASYbox 0pt\box\ASYbox#6%
    }%
  }

  \long\def\ASYalignT(#1,#2)(#3,#4)#5#6{%
    \ASYaligned(#1,#2)(#3,#4){%
      \special{pdf:q #5 0 0 cm}%
    }{%
      \special{pdf:Q}%
    }{#6}%
  }

  \long\def\ASYalign(#1,#2)(#3,#4)#5{\ASYaligned(#1,#2)(#3,#4){}{}{#5}}

  \let\ASYraw\@firstofone

\else

  \long\def\ASYaligned(#1,#2)(#3,#4)#5#6#7{%
    \leavevmode
    \setbox\ASYbox\hbox{#7}%
    \setbox\ASYbox\hbox{%
      \ASYdimen\ht\ASYbox%
      \advance\ASYdimen\dp\ASYbox
      \kern#3\wd\ASYbox
      \raise#4\ASYdimen
      \box\ASYbox
    }%
    \put(#1,#2){#5\wd\ASYbox 0pt\dp\ASYbox 0pt\ht\ASYbox 0pt\box\ASYbox#6}%
  }

  \long\def\ASYalignT(#1,#2)(#3,#4)#5#6{%
    \ASYaligned(#1,#2)(#3,#4){%
      \special{%
        ps:gsave currentpoint currentpoint translate
        [#5 0 0] concat neg exch neg exch translate%
      }%
    }{%
      \special{ps:currentpoint grestore moveto}%
    }{#6}%
  }

  \long\def\ASYalign(#1,#2)(#3,#4)#5{\ASYaligned(#1,#2)(#3,#4){}{}{#5}}

  \def\ASYraw#1{%
    currentpoint currentpoint translate matrix currentmatrix
    100 12 div -100 12 div scale
    #1
    setmatrix neg exch neg exch translate%
  }

\fi