summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/pst-vowel/pst-vowel.sty
blob: 6699849b04dbd3ae851ba603df3464fcc5a433b6 (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
114
115
116
117
118
% pst-vowel.sty -- pstricks additions for drawing vowel diagrams.
% Copyright 2009 by Alan Munn <amunn@msu.edu>
% based on code in vowel.sty Copyright 2002 by Rei Fukui
%
% This package insert nodes for use with pstricks so that arrows can 
% be drawn to show diphthongs on vowel charts.
%
% For cardinal vowels, the change is minimal, since predefined node
% labels are used. For non-cardinal vowels, an extra node argument
% must be provided.
%
% This package may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This package has the LPPL maintenance status `maintained'.
% 
% The Current Maintainer of this package is Alan Munn.
%
% This package consists of the file pst-vowel.sty and documentation files
% pst-vowel.tex and pst-vowel.pdf
%
% Version 1.0 2009/04/24
%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{pst-vowel}[2009/04/24 pst-vowel Package version 1.0]
\RequirePackage{pst-node}
\RequirePackage{vowel}

% Put a vowel on a specified point.
% [AM] Added an extra argument to add a node label for the vowel.
% Usage is \putvowel{vowel}{x}{y}{node}
%
\renewcommand\@putvowel[4]{%
\setbox\z@\hbox{#1\global\dimen4=.5ex}%
\setbox\z@\hbox{#1}\dimen\@ne\wd\z@\incr@ne 2\vowelsep
%
\dimen\z@#2\incrz@ -.5\dimen\@ne
\expandafter\xdef\csname vwlxi\the\@vwlcnt\endcsname{\the\dimen\z@}%
\ifdim\dimen\z@<\z@ \dimen\z@-\dimen\z@
  \ifdim\dimen\z@>\@vwllftsep \@vwllftsep\dimen\z@\fi\fi
%
\dimen\z@#2\incrz@ .5\dimen\@ne
\expandafter\xdef\csname vwlxii\the\@vwlcnt\endcsname{\the\dimen\z@}%
\dimen\@ne\@vwldgmwd \incr@ne-\dimen\z@
\ifdim\dimen\@ne<\z@ \dimen\@ne-\dimen\@ne
  \ifdim\dimen\@ne>\@vwlrtsep \@vwlrtsep\dimen\@ne\fi\fi
%
\dimen\z@#3\dimen\tw@=\ht\z@\advance\dimen\tw@ -\dimen4%.5ex%
\incrz@ -\dimen\tw@ \incrz@ -\vowelsep
\expandafter\xdef\csname vwlyi\the\@vwlcnt\endcsname{\the\dimen\z@}%
\ifdim\dimen\tw@>\@vwltopsep \@vwltopsep\dimen\tw@\fi
%
\dimen\z@#3\dimen\tw@=\dp\z@\advance\dimen\tw@ \dimen4%.5ex%
\incrz@ \dimen\tw@ \incrz@ \vowelsep
\expandafter\xdef\csname vwlyii\the\@vwlcnt\endcsname{\the\dimen\z@}%
\ifdim\dimen\tw@>\@vwlbotsep \@vwlbotsep\dimen\tw@\fi
%
\expandafter\gdef\csname vwlsym\the\@vwlcnt\endcsname{\rnode{#4}{#1}}%
\expandafter\xdef\csname tmpnoerase\the\@vwlcnt\endcsname{%
  \if@tmpnoerase1\else0\fi}%
\advance\@vwlcnt \@ne
\ignorespaces}

% Macro to put a vowel next to a dot.
% [AM] Added an extra argument which specifies a node label for the dot.
% For the cardinal vowels, these labels are pre-specified v1 ... v16
% For arbitrarily placed vowels using \putvowel[l] or \putvowel[r] the node
% label has to be explicitly given as in \putvowel[l]{vowel}{x}{y}{node}.
%
\def\@putdotvowel[#1]#2#3#4#5{%
\if x#1\@putvowel{#2}{#3}{#4}{#5}\else
\@tmpnoerasetrue\@putvowel{\rnode{#5}{\vowelsymbol}}{#3}{#4}{#5}\@tmpnoerasefalse
\setbox\z@\hbox{#2}\setbox\@ne\hbox{\vowelsymbol}%
\dimen\z@=#3\dimen\@ne=#4\dimen\tw@=.5\wd\z@
\advance\dimen\tw@.5\wd\@ne \advance\dimen\tw@.5\vowelsep
%
\if l#1%
  \incrz@-\dimen\tw@
\else
  \if r#1\incrz@\dimen\tw@
  \else \errmessage{put(c)vowel: no such option [#1]}%
  \fi
\fi
%
\edef\@vwltmpi{\the\dimen\z@}%
\@putvowel{#2}\@vwltmpi{#4}{#5}\fi}

% Put a vowel on a cardinal position
% [AM] This code has been modified to add an explicit node label for each 
% dotted vowel. The labels for the cardinal vowels are v1 ... v16.
%

\def\@putcvowel[#1]#2#3{%
\ifcase#3\or
  \@putdotvowel[#1]{#2}\z@\z@{v1}\or
  \@putdotvowel[#1]{#2}\c@rdhposii\vowelvunit{v2}\or
  \@putdotvowel[#1]{#2}\c@rdhposiii{2\vowelvunit}{v3}\or
  \@putdotvowel[#1]{#2}\c@rdhposiv\@vwldgmht{v4}\or
  \@putdotvowel[#1]{#2}\@vwldgmwd\@vwldgmht{v5}\or
  \@putdotvowel[#1]{#2}\@vwldgmwd{2\vowelvunit}{v6}\or
  \@putdotvowel[#1]{#2}\@vwldgmwd\vowelvunit{v7}\or
  \@putdotvowel[#1]{#2}\@vwldgmwd\z@{v8}\or
  \@putdotvowel[#1]{#2}{2\vowelhunit}\z@{v9}\or
  \@putdotvowel[#1]{#2}\c@rdhposx\vowelvunit{v10}\or
  \@putdotvowel[#1]{#2}\c@rdhposxi{1.5\vowelvunit}{v11}\or
  \@putdotvowel[#1]{#2}\c@rdhposxii{2\vowelvunit}{v12}\or
  \@putdotvowel[#1]{#2}\c@rdhposxiii{.5\vowelvunit}{v13}\or
  \@putdotvowel[#1]{#2}\c@rdhposxiv{.5\vowelvunit}{v14}\or
  \@putdotvowel[#1]{#2}\c@rdhposxv{2.5\vowelvunit}{v15}\or
  \@putdotvowel[#1]{#2}\c@rdhposxvi{2.5\vowelvunit}{v16}\else\fi
}

\endinput