Debian Codegraph @

texmf-dist/source/latex/syntrace/syntrace.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 2006 by Mathieu Boretti
4 %
5 % This file may be distributed and/or modified under the
6 % conditions of the LaTeX Project Public License, either
7 % version 1.3 of this license or (at your option) any later
8 % version. The latest version of this license is in:
9 %
10 % http://www.latex-project.org/lppl.txt
11 %
12 % and version 1.3 or later is part of all distributions of
13 % LaTeX version 2003/12/01 or later.
14 %
15 % The current Maintainer of this work is Mathieu Boretti
16 %
17 % This work consists of the file syntrace.ins and
18 % syntrace.dtx and the derived file syntrace.sty
19 %
20 %
21 % \fi
22 % \iffalse
23 %<package>\NeedsTeXFormat{LaTeX2e}
24 %<package>\ProvidesPackage{syntrace}[2006/08/17 v1.1 Package for dealing with trace in syntaxic tree]
25 %<package>\RequirePackage{ifthen}
26 %<package>\DeclareOption{synttree}{
27 %<package>\AtEndOfPackage{%
28 %<package>\IfFileExists{synttree.sty}{%
29 %<package>\RequirePackage{synttree}\syntraceaddresetmacro{synttree}%
30 %<package>}{%
31 %<package>\PackageWarning{syntrace}{Unable to locate synttree package}
32 %<package>}
33 %<package>}
34 %<package>}
35 %<package>\DeclareOption{qtree}{
36 %<package>\AtEndOfPackage{%
37 %<package>\IfFileExists{qtree.sty}{%
38 %<package>\RequirePackage{qtree}\syntraceaddresetmacro{Tree}%
39 %<package>}{%
40 %<package>\PackageWarning{syntrace}{Unable to locate qtree package}
41 %<package>}
42 %<package>}
43 %<package>}
44 %<package>\DeclareOption{i-start}{
45 %<package>\AtEndOfPackage{%
46 %<package>\setcounter{syntrace@startvalue}{8}
47 %<package>}
48 %<package>}
49 %<package>\ExecuteOptions{synttree}
50 %<package>\ProcessOptions
51 %
52 %<*driver>
53 \documentclass{ltxdoc}
54 \usepackage[qtree,i-start]{syntrace}
55 \usepackage{verbatim}
56 \EnableCrossrefs
57 \CodelineIndex
58 \RecordChanges
59 \begin{document}
60 \DocInput{syntrace.dtx}
61 \end{document}
62 %</driver>
63 % \fi
64 % \GetFileInfo{syntrace.sty}
65 % \title{The \textsf{syntrace} package\thanks{This document corresponds to \textsf{syntrace}~\fileversion, dated~\filedate.}}
66 % \author{Mathieu Boretti \\ \texttt{[email protected]}}
67 %
68 % \maketitle
69 %
70 % \begin{abstract}
71 % This file describe the \textsf{syntrace} package. This package is intended for \LaTeX\ users who must deal with
72 % traces in synttree.
73 % \end{abstract}
74 %
75 % \section{Options}
76 %
77 % \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.
78 %
79 % \DescribeMacro{qtree} The |qtree| option add the Tree command of the qtree package to the auto reset command.
80 %
81 % \DescribeMacro{i-start} The |i-start| change the first label of trace to i instance of a.
82 %
83 % \section{Usage}
84 % The \textsf{syntrace} package add a way to deal with trace in tree produce using the \textsf{synttree} package.
85 %
86 % \DescribeMacro{\traceLabel} The |\traceLabel{label}| set and draw a end trace. The parameter is the label to use for
87 % the reference.
88 %
89 % \DescribeMacro{\traceReference} The |\traceReference{ref}| draw a trace linked with the specified reference.
90 %
91 % \DescribeMacro{\syntraceresetmacro} The |\syntraceresetmacro{commande name without slash}| add auto-reset to this command.
92 %
93 % \section{Examples}
94 % \subsection{Simply example with synttree}
95 % \begin{verbatim}
96 % \synttree[A %
97 % [B [C\traceLabel{l1}] [D]] %
98 % [E [F] [\traceReference{l1}]]%
99 % ]
100 % \end{verbatim}
101 % \synttree[A %
102 % [B [C\traceLabel{l1}] [D]] %
103 % [E [F] [\traceReference{l1}]]%
104 % ]
105 % \subsection{One complex example with synttree}
106 % \begin{verbatim}
107 % \synttree*[AgrP
108 % [DP\traceLabel{sujet1} [.t Le chat]]
109 % [Agr'
110 % [Arg [dort\traceLabel{verbe1}]]
111 % [TP
112 % [T'
113 % [T [\traceReference{verbe1}]]
114 % [VP
115 % [\traceReference{sujet1}]
116 % [V' [V [\traceReference{verbe1}]]]
117 % ]
118 % ]
119 % ]
120 % ]
121 % ]
122 % \end{verbatim}
123 % \synttree*[AgrP
124 % [DP\traceLabel{sujet1} [.t Le chat]]
125 % [Agr'
126 % [Arg [dort\traceLabel{verbe1}]]
127 % [TP
128 % [T'
129 % [T [\traceReference{verbe1}]]
130 % [VP
131 % [\traceReference{sujet1}]
132 % [V' [V [\traceReference{verbe1}]]]
133 % ]
134 % ]
135 % ]
136 % ]
137 % ]
138 % \subsection{One example with qtree}
139 % \syntraceaddresetmacro{Tree}
140 % \begin{verbatim}
141 % \Tree [.S [.NP subject\traceLabel{s1} ] [.VP [.V verb ] [.NP \traceReference{s1} ]]]
142 % \end{verbatim}
143 % \Tree [.S [.NP subject\traceLabel{s1} ] [.VP [.V verb ] [.NP \traceReference{s1} ]]]
144 % \section{Implementation}
145 %
146 % \begin{macro}{syntrace@startvalue}
147 % This counter define the start value of the trace numbering
148 % \begin{macrocode}
149 \newcounter{syntrace@startvalue}
150 \setcounter{syntrace@startvalue}{0}
151 % \end{macrocode}
152 % \end{macro}
153 % \begin{macro}{syntrace@labelcounter}
154 % This counter count the trace
155 % \begin{macrocode}
156 \newcounter{syntrace@labelcounter}
157 \setcounter{syntrace@labelcounter}{\arabic{syntrace@startvalue}}
158 % \end{macrocode}
159 % \end{macro}
160 % \begin{macro}{\thesyntrace@labelcounter}
161 % This macro display the value of the trace counter
162 % \begin{macrocode}
163 \renewcommand*{\thesyntrace@labelcounter}{%
164 \alph{syntrace@labelcounter}%
165 }
166 % \end{macrocode}
167 % \end{macro}
168 % \begin{macro}{\syntrace@labelletter}
169 % This macro display the default letter for the trace
170 % \begin{macrocode}
171 \newcommand*{\syntrace@labelletter}{%
172 \ensuremath{t}%
173 }
174 % \end{macrocode}
175 % \end{macro}
176 % \begin{macro}{\syntrace@displaytrace}
177 % This macro display the value of a trace
178 % \begin{macrocode}
179 \newcommand*{\syntrace@displaytrace}[1]{%
180 \raisebox{-.5\height}{\scriptsize\mbox{#1}}%
181 }
182 % \end{macrocode}
183 % \end{macro}
184 % \begin{macro}{\traceLabel}
185 % This macro add a start trace
186 % \begin{macrocode}
187 \newcommand*{\traceLabel}[1]{%
188 \refstepcounter{syntrace@labelcounter}%
189 \syntrace@displaytrace{\thesyntrace@labelcounter}%
190 \label{syntrace-#1}%
191 }
192 % \end{macrocode}
193 % \end{macro}
194 % \begin{macro}{\traceLabel}
195 % This macro add a reference to a trace
196 % \begin{macrocode}
197 \newcommand*{\traceReference}[1]{%
198 \syntrace@labelletter\syntrace@displaytrace{\ref{syntrace-#1}}%
199 }
200 % \end{macrocode}
201 % \end{macro}
202 % \begin{macro}{\syntrace@reset}
203 % This macro reset the trace counter
204 % \begin{macrocode}
205 \newcommand*{\syntrace@reset}{%
206 \setcounter{syntrace@labelcounter}{\arabic{syntrace@startvalue}}%
207 }
208 % \end{macrocode}
209 % \end{macro}
210 % \begin{macro}{\syntraceaddresetmacro}
211 % This macro add autoreset to a command and add a starred version to this command that have the default functionnality
212 % \begin{macrocode}
213 \newcommand*{\syntraceaddresetmacro}[1]{%
214 \expandafter\ifx%
215 \csname syntrace@old@#1\endcsname
216 \relax%
217 \PackageInfo{syntrace}{Adding auto-reset to #1}%
218 \expandafter\let\csname syntrace@old@#1\expandafter\endcsname%
219 \csname #1\endcsname%
220 \expandafter\def\csname#1\endcsname{\@ifstar{%
221 \csname syntrace@old@#1\endcsname%
222 }{%
223 \syntrace@reset%
224 \csname syntrace@old@#1\endcsname%
225 }%
226 }%
227 \else
228 \PackageWarning{syntrace}{#1 allready set as auto-reset}%
229 \fi
230 }
231 % \end{macrocode}
232 % \end{macro}
233 % \begin{macro}{\syntraceremoveresetmacro}
234 % This macro remove autoreset to a command
235 % \begin{macrocode}
236 \newcommand*{\syntraceremoveresetmacro}[1]{%
237 \expandafter\ifx%
238 \csname syntrace@old@#1\endcsname
239 \relax%
240 \PackageWarning{syntrace}{#1 is not set as auto-reset}%
241 \else
242 \PackageInfo{syntrace}{Removing auto-reset from #1}%
243 \expandafter\let\csname #1\expandafter\endcsname%
244 \csname syntrace@old@#1\endcsname%
245 \expandafter\let\csname syntrace@old@#1\expandafter\endcsname\relax%
246 \fi
247 }
248 % \end{macrocode}
249 % \end{macro}
250 % \Finale
251 \endinput