| 1 |
texdef -- Show definitions of TeX commands |
| 2 |
Version 1.10 -- 2025/02/17 |
| 3 |
Copyright (c) 2011-2025 Martin Scharrer <[email protected]> |
| 4 |
This program comes with ABSOLUTELY NO WARRANTY; |
| 5 |
This is free software, and you are welcome to redistribute it under certain conditions; |
| 6 |
|
| 7 |
Usage: |
| 8 |
texdef [options] commandname [commandname ...] |
| 9 |
latexdef [options] commandname [commandname ...] |
| 10 |
|
| 11 |
Other program names are possible. See the 'tex' option. Command names do not need to start with `\`. |
| 12 |
|
| 13 |
Options: |
| 14 |
--tex <format>, -t <format> : Use given format of TeX: 'tex', 'latex', 'context'. |
| 15 |
Variations of 'tex' and 'latex', like 'luatex', 'lualatex', 'xetex', 'xelatex' are supported. |
| 16 |
The postfix '-dev' for develop versions of the format is also supported (e.g. 'latex-dev'). |
| 17 |
The default is given by the used program name: 'texdef' -> 'tex', 'latexdef' -> 'latex', etc. |
| 18 |
--texoptions <options> : Call (La)TeX with the given options. |
| 19 |
--source, -s : Try to show the original source code of the command definition (L). |
| 20 |
--value, -v : Show value of command instead (i.e. \the\command). |
| 21 |
--Environment, -E : Every command name is taken as an environment name. This will show the definition of |
| 22 |
both \Macro\foo and \Macro\endfoo if \texttt{foo} is used as command name (L). |
| 23 |
--preamble, -P : Show definition of the command inside the preamble. |
| 24 |
--beforeclass, -B : Show definition of the command before \documentclass. |
| 25 |
--package <pkg>, -p <pkg> : (M) Load given tex-file, package or module depending on whether '*tex', '*latex' |
| 26 |
or 'context' is used. For LaTeX the <pkg> can start with `[<options>]` and end |
| 27 |
with `<pkgname>` or `{<pkgname>}`. |
| 28 |
--class <class>, -c <class> : (LaTeX only) Load given class instead of default ('article'). |
| 29 |
The <class> can start with `[<class options>]` and end |
| 30 |
with `<classname>` or `{<classname>}`. |
| 31 |
--environment <env>, -e <env> : (M) Show definition inside the given environment <env>. |
| 32 |
--othercode <code>, -o <code> : (M) Add other code into the preamble before the definition is shown. |
| 33 |
This can be used to e.g. load PGF/TikZ libraries. |
| 34 |
--before <code>, -b <code> : (M) Place <code> before definition is shown. |
| 35 |
The <code> can be arbitray TeX code and doesn't need be be balanced. |
| 36 |
--after <code>, -a <code> : (M) Place <code> after definition is shown. |
| 37 |
The <code> can be arbitray TeX code and doesn't need be be balanced. |
| 38 |
--find, -f : Find file where the command sequence was defined (L). |
| 39 |
--Find, -F : Show full filepath of the file where the command sequence was defined (L). |
| 40 |
--list, -l : List user level command sequences of the given packages (L). |
| 41 |
--list-defs, -L : List user level command sequences and their shorten definitions of the given packages (L). |
| 42 |
--list-all, -ll : List all command sequences of the given packages (L). |
| 43 |
--list-defs-all, -LL : List all command sequences and their shorten definitions of the given packages (L). |
| 44 |
--ignore-cmds <cs,cs,..>, -i : Ignore the following command sequence(s) in the above lists. (M) |
| 45 |
--ignore-regex <regex,..>, -I : Ignore all command sequences in the above lists which match the given Perl regular expression(s). (M) |
| 46 |
--pgf-keys, -k : Takes commands as pgfkeys and displays their definitions. Keys must use the full path but the common '.\@cmd' prefix is applied. |
| 47 |
--pgf-Keys, -K : Takes commands as pgfkeys and displays their definitions. Keys must use the full path. |
| 48 |
--version, -V : If used alone prints version of this script. |
| 49 |
(L) Together with -p or -c prints version of LaTeX package(s) or class, respectively. |
| 50 |
--edit : Opens the file holding the macro definition. Uses --Find and --source. (L) |
| 51 |
If the source definition can not be found the definition is printed as normal instead. |
| 52 |
--editor <editor> : Can be used to set the used editor. If not used the environment variables TEXDEF_EDITOR, EDITOR and |
| 53 |
SELECTED_EDITOR are read in this order. If none of these are set a list of default |
| 54 |
editors are tried. The <editor> string can include '%f' for the filename, '%n' for |
| 55 |
the line number and '%%' for a literal '%'. If no '%' is used '+%n %f' is added to |
| 56 |
the given command. |
| 57 |
--tempdir <directory> : Use given existing directory for temporary files. |
| 58 |
--help, -h : Print this help and quit. |
| 59 |
|
| 60 |
Long option can be shorten as long the are still unique. Short options can be combined. |
| 61 |
If the option 'environment', 'before' and 'after' are used toegether the |
| 62 |
produced code will be inserted in the given order (reversed order for 'after'). |
| 63 |
(M) = This option can be given multiple times. |
| 64 |
(L) = LaTeX only. Requires the packages 'filehook' and 'currfile'. |
| 65 |
|
| 66 |
Examples: |
| 67 |
Show the definition of '\chapter' with different classes ('article' (default), 'book' and 'scrbook'): |
| 68 |
|
| 69 |
latexdef chapter |
| 70 |
latexdef -c book chapter |
| 71 |
latexdef -c scrbook chapter |
| 72 |
|
| 73 |
Show value of `\textwidth` with different class options: |
| 74 |
|
| 75 |
latexdef -c [a4paper]{book} -v paperwidth |
| 76 |
latexdef -c [letter]{book} -v paperwidth |
| 77 |
|
| 78 |
Show definition of TikZ's '\draw' outside and inside a 'tikzpicture' environment: |
| 79 |
|
| 80 |
latexdef -p tikz draw |
| 81 |
latexdef -p tikz --env tikzpicture draw |
| 82 |
|
| 83 |
Show definition of TikZ's '\draw' inside a node, inside a 'beamer' frame in 'handout' mode: |
| 84 |
|
| 85 |
latexdef -c [handout]beamer -p tikz --env frame --env tikzpicture -b '\node {' -a '};' draw |
| 86 |
|
| 87 |
List all user level command sequences (macros) defined by the 'xspace' LaTeX package: |
| 88 |
|
| 89 |
latexdef -l -p xspace |
| 90 |
|