summaryrefslogtreecommitdiff
path: root/macros/latex209/contrib/misc/sentences.tex
blob: c40b4d084d083b477ee4a14650486b1e9629c7dc (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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
% -*- Mode: TeX -*-

\ifx\thisfileis\anUndefinedMacro\input maybeload \fi

\thisfileis{<eb.tex.texlocal>sentences} % abort loading if we're already loaded

\input redefine

% A referenceable "sentences" list environment for Latex.  Remember to
% put "{}" % after the \item command if the sentence begins with "[".
% There is also a "subsentences" environment.

\makeatletter

\newif\ifinsentences
\insentencesfalse

\newcounter{sentence}
\newcounter{subsentence}[sentence]

% These next definitions define the format of the "sentence"
% and "subsentence" counters.  It is tricky to get them right.
% First of all, the parentheses in "(4)" and "(2iii)" are
% defined to be part of the printed representation of the
% "sentence" and "subsentence" counters.  This is so that
% parentheses will be included in \ref - \label constructions.
% Second, the "subsentence" counter must print out with the
% "sentence" number included as well; this is similar to
% what happens with the section and chapter counters. 
% Third, despite the second requirement, the "subsentence"
% counter must appear without the sentence number when it
% is actually used to number a subsentence.
%
% We use two auxiliary control sequences here and below in order
% to make it easier to change the subsentence numbering style.
% The two control sequences are \subsentencenumbering, which should
% be \let to something like \roman or \alph, and
% \subsentencepunctuation, which controls the format of subsentence
% numbers as they appear before the subsentences.

\def\thesentence{(\arabic{sentence})}
\def\thesubsentence{(\arabic{sentence}\subsentencenumbering{subsentence})}

% These next two definitions are defaults.

\let\subsentencenumbering\roman
\def\subsentencepunctuation#1{(#1)}

%%% Using \begin{list} and \end{list} in the argument of a
%%% \newenvironment command doesn't work properly; I have to call
%%% \list and \endlist directly.

\newenvironment{sentences}{\list{\thesentence}%
{\edef\sent@nbr{\the\c@sentence}\usecounter{sentence}%
\setcounter{sentence}{\sent@nbr}%
\ifinsentences \errmessage{Nested sentences environment.} \fi
\def\makelabel##1{##1\hfil}%
\leftmargin\leftmargini\labelwidth\leftmargin
  \advance\labelwidth-\labelsep
\insentencestrue}}{\endlist}

\newenvironment{subsentences}{\list
{\subsentencepunctuation{\subsentencenumbering{subsentence}}}%
{\edef\sent@nbr{\the\c@subsentence}\usecounter{subsentence}%
\setcounter{subsentence}{\sent@nbr}%
\leftmargin\leftmargini\labelwidth\leftmargin
  \advance\labelwidth-\labelsep
\def\makelabel##1{##1\hfil}%
\ifinsentences\relax\else
   \errmessage{\string\begin{subsentences} not in sentences environment}\fi}}%
{\endlist}

% These sentence-judgement macros are for use with the sentences
% environment; they back up over preceding space.  They're designed
% for use just after an \item.

\newcommand{\sentencejudgement}[1]{\strut\llap{#1\hskip 2pt}}
\newcommand{\bad}{\sentencejudgement{$\ast$}}
\newcommand{\quest}{\sentencejudgement{?}}
\newcommand{\qquest}{\sentencejudgement{?\kern -0.5pt?}}

% An abbreviation.

\newcommand{\sentence}[1]{\begin{sentences}\item{#1}\end{sentences}}

% Local references.
%
% \nextsentence           the next sentence
% \nextsentence[2]        the sentence after the next sentence
% \nextsentencesub{1}     the first subsentence of the next sentence
% \nextsentencesub[2]{1}  the first subsentence of the sentence after
%                         the next sentence
%

\newdef\nextsentence{\@ifnextchar[{\@argnextsentence}{\@argnextsentence[1]}%]
}

\newdef\@argnextsentence[#1]{\bgroup
  \advance\c@sentence by #1\relax 
  \thesentence
  \egroup}

\newdef\nextsentencesub{\@ifnextchar[{\@argnextsentencesub
   }{\@argnextsentencesub[1]}%]
}

\newdef\@argnextsentencesub[#1]#2{\bgroup
  \advance\c@sentence by #1\relax
  \c@subsentence=#2\relax
  \thesubsentence
  \egroup}

% Define labeled brackets.  Write ``[\ntype:NP foo bar ...'' to get an
% NP bracket. \ctype is acceptable as an abbreviation.

\newdef\ntype:#1 {{$_{\mbox{\tiny #1}}$} }
\newlet\ctype=\ntype % synonmym

% Common symbols with bars over them.

\newcommand{\Bar}[1]{\ifmmode \overline{\mbox{#1}}\else $\Bar{#1}$\fi}
\newcommand{\Sbar}{\Bar S}
\newcommand{\Nbar}{\Bar N}
\newcommand{\Abar}{\Bar A}
\newcommand{\Xbar}{\Bar X}
\newcommand{\Twobar}[1]{\Bar{\Bar{#1}}}

\newcommand{\thetabar}{\overline\theta}

% More common symbols.

\newcommand{\wh}{{\it wh}}