[OS X TeX] tex'ing newcommands
Jonathan Kew
jonathan_kew at sil.org
Wed May 26 14:47:04 EDT 2004
On 26 May 2004, at 6:38 pm, William F. Adams wrote:
> On Wednesday, May 26, 2004, at 01:29 PM, Donal Day wrote:
>
>> Does there exist a tool that will read this file of definitions,
>> strip out the definitions, put each on a line and render them into a
>> latex document? I would then compile it and keep the output as a
>> handy reference. If so, I could usefully share this file and the list
>> of commands with my collaborators so we can all benefit.
>
> One can replace \def with your own command (say \mef) and then have a
> switch at the beginning of the file which determines how \mef is
> defined, whether it makes a command or typesets its argument.
>
No need to replace anything in the file. Create a file "printdefs.ltx",
something like this:
% - - - - - printdefs.ltx - - - - -
\def\mydefsfile{mydefinitions.tex}
\documentclass{article}
\begin{document}
\noindent Definitions in {\tt\mydefsfile}:
% redefine \def and \newcommand; note that we don't handle parameters!
\let\Def=\def
\def\def#1#2{{\let\def=\Def \noindent {\tt\string #1} : #2\par}}
\let\newcommand=\def
% lots of standard LaTeX macros will break now,
% so we go for more primitive methods...
\csname @@input\endcsname \mydefsfile
% need to restore this before \end{document}
\let\def=\Def
\end{document}
% - - - - - end of file - - - - -
Change the filename defined at the beginning, of course. Run this
through LaTeX, and you should get a listing.
One warning: this won't work for definitions of commands with
parameters; that would take quite a bit more effort, I'd think.
JK
-----------------------------------------------------
Post: <mailto:MacOSX-TeX at email.esm.psu.edu>
Please see <http://www.esm.psu.edu/mac-tex/> for list
guidelines, information, and LaTeX/TeX resources.
More information about the MacOSX-TeX
mailing list