Debian Codegraph @

texmf-dist/doc/support/texdef/texdef.tex

raw
1 \documentclass{ydoc}
2 \usepackage{tabularx}
3
4 \title{The \textsf{texdef} script}
5 \author{Martin Scharrer}
6 \email{[email protected]}
7 \repository{https://github.com/MartinScharrer/texdef}
8 \date{Version 1.10 -- 2025/02/17}
9
10 \makeatletter
11 \DeclareRobustCommand{\LATeX}{%
12 (L\kern -.36em{\sbox \z@ T\vbox to\ht \z@ {\hbox {\check@mathfonts \fontsize \sf@size \z@ \math@fontsfalse \selectfont A}\vss }}\kern -.075em)\kern -.15em\TeX
13 }
14 \makeatother
15
16 \newenvironment{options}{%
17 \def\cstart{\begingroup\ttfamily\par\noindent\ignorespaces}%
18 \def\csep{\endgroup\begingroup\list {}{}\item \relax}%
19 \def\cend{\endlist\par\medskip\endgroup\cstart}%
20 \cstart
21 }{%
22 \endgroup
23 }
24
25 \begin{document}
26 \maketitle
27
28 \begin{abstract}
29 This Perl script shows the definition of \LATeX\ commands in a similar way as the \TeX\ primitive \Macro\show.
30 It is intended to allow users to quickly see the definitions of user level or internal package macros as well as the
31 values of registers. The given commands are compiled internally with \LATeX\ and the output of \Macro\show is formatted
32 and shown to the user.
33 \end{abstract}
34
35 \tableofcontents
36
37
38 \section{Usage}
39 The script executable is called \texttt{texdef} (or maybe \texttt{texdef.pl}).
40 A normal installation is supposed to also install it as \texttt{latexdef} (e.g.\ using a symlink to \texttt{texdef}) in order to
41 allow for quick access to the \LaTeX\ format. Further format shortcuts are possible as explained in the installation section.
42
43 \parindent=0pt
44 \DescribeScript{texdef}[<options>]~<commandname>~[<commandname>~!\ldots!]
45 \DescribeScript{latexdef}[<options>]~<commandname>~[<commandname>~!\ldots!]
46
47 Other program names are possible. See the \texttt{tex} option. Command names do not need to start with `|\|'.
48
49 \subsection*{Options}
50 The following options can be used:
51 \par\medskip
52
53 \begin{options}
54 --tex \MacroArgs<format>, -t \MacroArgs<format> \csep Use given format of TeX: 'tex', 'latex', 'context'.
55 Variations of 'tex' and 'latex', like 'luatex', 'lualatex', 'xetex', 'xelatex' are supported.
56 The postfix '-dev' for develop versions of the format is also supported (e.g. 'latex-dev').
57 The default is given by the used program name: 'texdef' -> 'tex', 'latexdef' -> 'latex', etc.\cend
58 --texoptions \MacroArgs<options> \csep Call \LaTeX/\TeX{} with the given options.\cend
59 --source, -s \csep Try to show the original source code of the command definition (L).\cend
60 --value, -v \csep Show value of command instead (i.e. \Macro\the\AlsoMacro\command).\cend
61 --preamble, -P \csep Show definition of the command inside the preamble.\cend
62 --Environment, -E \csep Every command name is taken as an environment name. This will show the definition of
63 both \Macro\foo and \Macro\endfoo if \texttt{foo} is used as command name (L).\cend
64 --beforeclass, -B \csep Show definition of the command before \Macro\documentclass.\cend
65 --package \MacroArgs<pkg>, -p \MacroArgs<pkg> \csep (M) Load given tex-file, package or module depending on whether '*tex', '*latex'
66 or 'context' is used. For LaTeX the \MacroArgs<pkg> can start with `[<options>]` and end
67 with \MacroArgs<pkgname> or \MacroArgs{<pkgname>}.\cend
68 --class \MacroArgs<class>, -c \MacroArgs<class> \csep (LaTeX only) Load given class instead of default ('article').
69 The \MacroArgs<class> can start with \MacroArgs[<class options>] and end
70 with \MacroArgs<classname> or \MacroArgs{<classname>}.\cend
71 --environment \MacroArgs<env>, -p \MacroArgs<env> \csep (M) Show definition inside the given environment \MacroArgs<env>.\cend
72 --othercode \MacroArgs<code>, -o \MacroArgs<code> \csep (M) Add other code into the preamble before the definition is shown.
73 This can be used to e.g. load PGF/TikZ libraries.\cend
74 --before \MacroArgs<code>, -b \MacroArgs<code> \csep (M) Place \MacroArgs<code> before definition is shown.
75 The \MacroArgs<code> can be arbitray TeX code and doesn't need be be balanced.\cend
76 --after \MacroArgs<code>, -a \MacroArgs<code> \csep (M) Place \MacroArgs<code> after definition is shown.
77 The \MacroArgs<code> can be arbitray TeX code and doesn't need be be balanced.\cend
78 --find, -f \csep Find file where the command sequence was defined (L).\cend
79 --Find, -F \csep Show full filepath of the file where the command sequence was defined (L).\cend
80 --list, -l \csep List user level command sequences of the given packages (L).\cend
81 --list-defs, -L \csep List user level command sequences and their shorten definitions of the given packages (L).\cend
82 --list-all, -ll \csep List all command sequences of the given packages (L).\cend
83 --list-defs-all, -LL \csep List all command sequences and their shorten definitions of the given packages (L).\cend
84 --ignore-cmds \MacroArgs<cs,cs,..>, -i \csep Ignore the following command sequence(s) in the above lists. (M)\cend
85 --ignore-regex \MacroArgs<regex,..>, -I \csep Ignore all command sequences in the above lists which match the given Perl regular expression(s). (M)\cend
86 --pgf-keys, -k \csep Takes commands as \pkg{pgfkeys} and displays their definitions. Keys must use the full path but the common '.\@cmd' prefix is applied.\cend
87 --pgf-Keys, -K \csep Takes commands as \pkg{pgfkeys} and displays their definitions. Keys must use the full path.\cend
88 --version, -V \csep If used alone prints version of this script.
89 (L) Together with -p or -c prints version of LaTeX package(s) or class, respectively.\cend
90 --edit \csep Opens the file holding the macro definition. Uses |--Find| and |--source|.
91 If the source definition can not be found the definition is printed as normal instead. (L)\cend
92 --editor <editor> \csep Can be used to set the used editor. If not used the environment variables |TEXDEF_EDITOR|, |EDITOR| and
93 |SELECTED_EDITOR| are read in this order. If none of these are set a list of default
94 editors are tried. The |<editor>| string can include `|%f|' for the filename, `|%n|' for
95 the line number and `|%%|' for a literal `|%|'. If no `|%|' is used `|+%n %f|' is added to
96 the given command.\cend
97 --tempdir <directory> \csep Use given existing directory for temporary files.\cend
98 --help, -h \csep Print this help and quit.\cend
99 \end{options}
100
101 \noindent \textbf{Notes:}\\
102 Long option can be shorten as long the are still unique. Short options can be combined.
103 If the option 'environment', 'before' and 'after' are used toegether the
104 produced code will be inserted in the given order (reversed order for 'after').\\
105 (M) = This option can be given multiple times.\\
106 (L) = LaTeX only. Requires the packages 'filehook' and 'currfile'.
107
108
109 \section{Installation}\label{sec:install}
110
111 The latest official release of the script can be obtained from CTAN under \url{http://mirrors.ctan.org/support/texdef/texdef.pl}.
112 The latest develop version (which can be unstable!) can be obtained from the source code repository under
113 \url{https://github.com/MartinScharrer/texdef/src/tip/texdef.pl}.
114
115 For installation the script file |texdef.pl| must simply renamed to |texdef| and be copied to a location suitable for executables,
116 i.e. a directory in the |PATH|, e.g.\ |/usr/bin| or |/usr/local/bin| for Linux/Unix.
117 The script should be set as \emph{executable}, i.e. |chmod +x texdef.pl| for Linux/Unix.
118 This is not required for MS Windows.
119
120 This script can show the definitions of commands with different formats of TeX
121 (|tex|, |etex|, |latex|, |pdftex|, |pdfetex|, |pdflatex|, |xetex|, |xelatex|, |context|, \ldots).
122 The format can be given using an command line option or over the \emph{script name},
123 i.e.\ if the script is called |texdef| it will use |tex|, but called |latexdef|
124 it will use |latex| and so on.
125 The script can be simply copied several times, but creating \emph{symbolic links}
126 to the real script is enough on operation systems/file systems which support
127 this.
128 At least the two variations |texdef| and |latexdef| should be installed.
129
130
131 \subsection*{Requirements}
132
133 The |texdef| program is a Perl script which needs a Perl interpreter to work.
134 Informations about installing Perl can be found at \url{http://www.perl.org/get.html}.
135
136 The script calls a TeX compiler (|tex|, |latex|, \ldots) to display the definition of commands/macros.
137 Therefore \LATeX\ must also be installed.
138 Informations about installing \LATeX\ can be found at \url{http://www.latex-project.org/ftp.html}.
139
140
141
142
143 \subsection*{Quick Install Nodes for Linux/Unix}
144
145 \begin{verbatim}
146 cp texdef.pl /usr/local/bin/
147 cd /usr/local/bin
148 ln -s texdef.pl texdef
149 ln -s texdef.pl latexdef
150 ln -s texdef.pl etexdef
151 ln -s texdef.pl luatexdef
152 ln -s texdef.pl lualatexdef
153 ln -s texdef.pl pdftexdef
154 ln -s texdef.pl pdflatexdef
155 ln -s texdef.pl xetexdef
156 ln -s texdef.pl xelatexdef
157 ln -s texdef.pl 'some other TeX format of your choice'
158 \end{verbatim}
159
160 \noindent or use the Makefile (defaults to |/usr/local/bin|)
161
162 \begin{verbatim}
163 make install INSTALLDIR=/your/path
164 \end{verbatim}
165
166 \section{Examples}
167 Show the definition of \Macro\chapter with different classes (\cls{article} (default), \cls{book} and \cls{scrbook}):
168
169 \begin{verbatim}
170 latexdef chapter
171 latexdef -c book chapter
172 latexdef -c scrbook chapter
173 \end{verbatim}
174
175 Show value of \Macro\textwidth with different class options:
176
177 \begin{verbatim}
178 latexdef -c [a4paper]{book} -v paperwidth
179 latexdef -c [letter]{book} -v paperwidth
180 \end{verbatim}
181
182 Show definition of TikZ's \Macro\draw outside and inside a \env{tikzpicture} environment:
183
184 \begin{verbatim}
185 latexdef -p tikz draw
186 latexdef -p tikz --env tikzpicture draw
187 \end{verbatim}
188
189 Show definition of TikZ's \Macro\draw inside a node, inside a \cls{beamer} frame in \opt{handout} mode:
190
191 \begin{verbatim}
192 latexdef -c [handout]beamer -p tikz --env frame \
193 --env tikzpicture -b '\node {' -a '};' draw
194 \end{verbatim}
195
196 List all user level command sequences (macros) defined by the \pkg{xspace} LaTeX package:
197
198 \begin{verbatim}
199 latexdef -l -p xspace
200 \end{verbatim}
201
202
203 \section{Changelog}
204
205 \subsection*{v1.9 from 2020/09/27}
206 \begin{itemize}
207 \item Added support for develop versions of the formats, e.g.\ "latex-dev".
208 \end{itemize}
209
210 \subsection*{v1.8c from 2010/01/15}
211 \begin{itemize}
212 \item Changed path printing format to native format of the used OS
213 (e.g. under Windows file paths now habe `\textbackslash' instead of `/')
214 \end{itemize}
215
216 \subsection*{v1.8a from 2018/03/28}
217 \begin{itemize}
218 \item Further fixes of braces in regexs to avoid ``Unescaped left brace in regex is deprecated'' warnings or errors.
219 \end{itemize}
220
221 \subsection*{v1.8 from 2018/03/25}
222 \begin{itemize}
223 \item Added "dvitex" and "dvilatex" as formats. These will set DVI mode on "tex" or "latex".
224 \item Escaped further braces in regexs to avoid warnings or errors.
225 \item Added option "--texoptions" to allow the passing of compiler options for special cases.
226 \end{itemize}
227
228 \subsection*{v1.7c from 2017/12/09}
229 \begin{itemize}
230 \item Fixed 'Unescaped left brace in regex is deprecated' warning.
231 Thanks goes to Paulo Cereda <[email protected]> for providing the patch.
232 \end{itemize}
233
234 \subsection*{v1.7b from 2012/05/15}
235 \begin{itemize}
236 \item Added support for \Macro\chardef, \Macro\countdef, \Macro\dimendef, \Macro\mathchardef, \Macro\myskip, \Macro\skipdef and \Macro\toksdef.
237 \item Added support for \Macro\newbox, \Macro\newcount, \Macro\newdimen, \Macro\newif, \Macro\newinsert, \Macro\newread, \Macro\newskip, \Macro\newtoks, \Macro\newwrite.
238 \item Added support for \Macro\newif and \Macro\newcount.
239 \item Changed internal processing order to put more frequently used elements first.
240 \end{itemize}
241
242 \subsection*{v1.7a from 2012/05/08}
243 \begin{itemize}
244 \item Fix for currfile v0.6.
245 \end{itemize}
246
247 \subsection*{v1.7 from 2012/05/07}
248 \begin{itemize}
249 \item Changed "--help" to return status code 0.
250 \item Changed Windows default editor to texworks. Fixed If-statement.
251 \item Fixed bug which reported name of included subpackages.
252 \item Added option "--edit".
253 \item Added "--editor" option and better editor handling.
254 \item Added variable substitution for editor.
255 \item Added support for "TEXDEF_EDITOR" variable. Added Mac "open" command.
256 \item Fixed for behaviour when -s is used (correct name in message; do not follow protected macros etc.)
257 \end{itemize}
258
259 \subsection*{v1.6 from 2012/05/02}
260 \begin{itemize}
261 \item Changed implementation of -E option to work better with new environment source code.
262 \item Added code to detect environment source definitions.
263 \item Added -E option.
264 \item Changed "flavour" to "format".
265 \item Added support for \Macro\let.
266 \item Added fallback for when the source code can not be found. Added support for -F with "latex.ltx".
267 \end{itemize}
268
269 \subsection*{v1.5 from 2012/04/29}
270 \begin{itemize}
271 \item Added experimental --source option to show source code of the definitions.
272 \item Script now works correctly under MS Windows.
273 \end{itemize}
274
275 \subsection*{v1.4 from 2011/07/28}
276 \begin{itemize}
277 \item Added -F option to display file path.
278 \item Added basic support for pdfkeys using -k and -K options.
279 \item Added -V option to print version numbers of LaTeX packages or classes.
280 \item Added '--tempdir' option to specify the location of the temporary files. Useful for debugging.
281 \end{itemize}
282
283
284
285 \end{document}
286