summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/syntrace/syntrace.dtx
blob: cb65d15a9bb44560c2e205090e0685b781b2771b (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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
% \iffalse meta-comment 
%
% Copyright (C) 2006 by Mathieu Boretti
% 
% This file may be distributed and/or modified under the 
% conditions of the LaTeX Project Public License, either 
% version 1.3 of this license or (at your option) 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 2003/12/01 or later.
%
% The current Maintainer of this work is Mathieu Boretti
%
% This work consists of the file syntrace.ins and
% syntrace.dtx and the derived file syntrace.sty
% 
% 
% \fi 
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{syntrace}[2006/08/17 v1.1 Package for dealing with trace in syntaxic tree]
%<package>\RequirePackage{ifthen}
%<package>\DeclareOption{synttree}{
%<package>\AtEndOfPackage{%
%<package>\IfFileExists{synttree.sty}{%
%<package>\RequirePackage{synttree}\syntraceaddresetmacro{synttree}%
%<package>}{%
%<package>\PackageWarning{syntrace}{Unable to locate synttree package}
%<package>}
%<package>}
%<package>}
%<package>\DeclareOption{qtree}{
%<package>\AtEndOfPackage{%
%<package>\IfFileExists{qtree.sty}{%
%<package>\RequirePackage{qtree}\syntraceaddresetmacro{Tree}%
%<package>}{%
%<package>\PackageWarning{syntrace}{Unable to locate qtree package}
%<package>}
%<package>}
%<package>}
%<package>\DeclareOption{i-start}{
%<package>\AtEndOfPackage{%
%<package>\setcounter{syntrace@startvalue}{8}
%<package>}
%<package>}
%<package>\ExecuteOptions{synttree}
%<package>\ProcessOptions
%
%<*driver>
\documentclass{ltxdoc}
\usepackage[qtree,i-start]{syntrace}
\usepackage{verbatim}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
    \DocInput{syntrace.dtx}
\end{document}
%</driver>
% \fi
% \GetFileInfo{syntrace.sty}
% \title{The \textsf{syntrace} package\thanks{This document corresponds to \textsf{syntrace}~\fileversion, dated~\filedate.}}
% \author{Mathieu Boretti \\ \texttt{mathieu.boretti@gmail.com}}
%
% \maketitle
%
% \begin{abstract}
% This file describe the \textsf{syntrace} package. This package is intended for \LaTeX\ users who must deal with
% traces in synttree. 
% \end{abstract}
%
% \section{Options}
%
% \DescribeMacro{synttree} The |synttree| option add the synttree command of the synttree package to the auto reset commands. With this option, the |\synttree| command is redefined to auto reset trace counter. A |\synttree*| command is add that work like |\synttree|, but without auto reset. This option is enabled is a default options.
%
% \DescribeMacro{qtree} The |qtree| option add the Tree command of the qtree package to the auto reset command.
%
% \DescribeMacro{i-start} The |i-start| change the first label of trace to i instance of a.
% 
% \section{Usage}
% The \textsf{syntrace} package add a way to deal with trace in tree produce using the \textsf{synttree} package.
%
% \DescribeMacro{\traceLabel} The |\traceLabel{label}| set and draw a end trace. The parameter is the label to use for 
% the reference.
%
% \DescribeMacro{\traceReference} The |\traceReference{ref}| draw a trace linked with the specified reference.
%
% \DescribeMacro{\syntraceresetmacro} The |\syntraceresetmacro{commande name without slash}| add auto-reset to this command.
%
% \section{Examples}
% \subsection{Simply example with synttree}
% \begin{verbatim}
% \synttree[A %
%           [B [C\traceLabel{l1}] [D]] %
%           [E [F] [\traceReference{l1}]]%
%          ]
% \end{verbatim}
% \synttree[A %
%           [B [C\traceLabel{l1}] [D]] %
%           [E [F] [\traceReference{l1}]]%
%          ]
% \subsection{One complex example with synttree}
% \begin{verbatim}
% \synttree*[AgrP
%            [DP\traceLabel{sujet1} [.t Le chat]]
%            [Agr'
%             [Arg [dort\traceLabel{verbe1}]]
%             [TP
%              [T'
%               [T [\traceReference{verbe1}]]
%               [VP
%                [\traceReference{sujet1}]
%                [V' [V [\traceReference{verbe1}]]]
%               ]
%              ]
%             ]
%            ]
%           ]
% \end{verbatim}
% \synttree*[AgrP
%            [DP\traceLabel{sujet1} [.t Le chat]]
%            [Agr'
%             [Arg [dort\traceLabel{verbe1}]]
%             [TP
%              [T'
%               [T [\traceReference{verbe1}]]
%               [VP
%                [\traceReference{sujet1}]
%                [V' [V [\traceReference{verbe1}]]]
%               ]
%              ]
%             ]
%            ]
%           ]
% \subsection{One example with qtree}
% \syntraceaddresetmacro{Tree}
% \begin{verbatim}
% \Tree [.S [.NP subject\traceLabel{s1} ] [.VP [.V verb ] [.NP \traceReference{s1} ]]]
% \end{verbatim}
% \Tree [.S [.NP subject\traceLabel{s1} ] [.VP [.V verb ] [.NP \traceReference{s1} ]]]
% \section{Implementation}
%
% \begin{macro}{syntrace@startvalue}
% This counter define the start value of the trace numbering
%    \begin{macrocode}
\newcounter{syntrace@startvalue}
\setcounter{syntrace@startvalue}{0}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{syntrace@labelcounter}
% This counter count the trace
%    \begin{macrocode}
\newcounter{syntrace@labelcounter}
\setcounter{syntrace@labelcounter}{\arabic{syntrace@startvalue}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\thesyntrace@labelcounter}
% This macro display the value of the trace counter
%    \begin{macrocode}
\renewcommand*{\thesyntrace@labelcounter}{%
    \alph{syntrace@labelcounter}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\syntrace@labelletter}
% This macro display the default letter for the trace
%    \begin{macrocode}
\newcommand*{\syntrace@labelletter}{%
    \ensuremath{t}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\syntrace@displaytrace}
% This macro display the value of a trace
%    \begin{macrocode}
\newcommand*{\syntrace@displaytrace}[1]{%
    \raisebox{-.5\height}{\scriptsize\mbox{#1}}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\traceLabel}
% This macro add a start trace
%    \begin{macrocode}
\newcommand*{\traceLabel}[1]{%
    \refstepcounter{syntrace@labelcounter}%
    \syntrace@displaytrace{\thesyntrace@labelcounter}%
    \label{syntrace-#1}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\traceLabel}
% This macro add a reference to a trace
%    \begin{macrocode}
\newcommand*{\traceReference}[1]{%
    \syntrace@labelletter\syntrace@displaytrace{\ref{syntrace-#1}}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\syntrace@reset}
% This macro reset the trace counter
%    \begin{macrocode}
\newcommand*{\syntrace@reset}{%
    \setcounter{syntrace@labelcounter}{\arabic{syntrace@startvalue}}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\syntraceaddresetmacro}
% This macro add autoreset to a command and add a starred version to this command that have the default functionnality
%    \begin{macrocode}
\newcommand*{\syntraceaddresetmacro}[1]{%
    \expandafter\ifx%
        \csname syntrace@old@#1\endcsname
        \relax%
        \PackageInfo{syntrace}{Adding auto-reset to #1}%
        \expandafter\let\csname syntrace@old@#1\expandafter\endcsname%
        \csname #1\endcsname%
        \expandafter\def\csname#1\endcsname{\@ifstar{%
                \csname syntrace@old@#1\endcsname%
            }{%
                \syntrace@reset%
                \csname syntrace@old@#1\endcsname%
            }%
        }%
    \else
        \PackageWarning{syntrace}{#1 allready set as auto-reset}%
    \fi
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\syntraceremoveresetmacro}
% This macro remove autoreset to a command
%    \begin{macrocode}
\newcommand*{\syntraceremoveresetmacro}[1]{%
    \expandafter\ifx%
        \csname syntrace@old@#1\endcsname
        \relax%
        \PackageWarning{syntrace}{#1 is not set as auto-reset}%
    \else
        \PackageInfo{syntrace}{Removing auto-reset from #1}%
        \expandafter\let\csname #1\expandafter\endcsname%
        \csname syntrace@old@#1\endcsname%
        \expandafter\let\csname syntrace@old@#1\expandafter\endcsname\relax%
    \fi
}
%    \end{macrocode}
% \end{macro}
% \Finale
\endinput