I am already very fond of the texdef
tool, which is used on the command line, something like this:
$ texdef -t latex \newcounter
\newcounter:
macro:#1->\expandafter \@ifdefinable \csname c@#1\endcsname {\@definecounter {#1}}\@ifnextchar [{\@newctr {#1}}{}
That is, we can lookup: search for and find the definition of \newcounter
from the command line - which I think is great.
However, often I am in need for something else. Like right now, I need to use \newcounter
, and since I rarely use counters, I've completely forgotten what the correct syntax of usage (i.e. where I use \the
and stuff). And then I always have to look up online :)
, which means search engine, then click on hits, then it's not always the information that I hoped for, then back in browser, etc etc.. And not the least, I cannot be offline for this process.
So, basically, what I'd need is a command line tool, with which I can look up some short information about a command, and hopefully an example; for instance, here's a pseudo:
$ texexampleref \newcounter
% \newcounter: creates a new counter (dimen?)
% example usage:
% create a new counter that is automatically set to zero
\newcounter{NameOfTheNewCounter}
% To increase the counter, use:
\stepcounter{NameOfTheNewCounter}
% ... or (add number 1):
\addtocounter{NameOfTheNewCounter}{1}
% To set the counter value explicitly, use:
\setcounter{NameOfTheNewCounter}{12}
% To show the counter value (typeout)
\typeout{ Counter value is: \theNameOfTheNewCounter }
% ...
Here, I borrowed a bit from LaTeX/Counters - Wikibooks as content. Basically, I'd hope for the info lines to be prefixed with a percent sign %
-- so that the entire example snippet is pastable, say, in a pdflatex
terminal shell; and it would be "compilable", in the sense that it would produce some output there in the terminal (at least a typeout to standard output). And of course - at least in this case - the same example can be delivered for queries about \stepcounter
and \addtocounter
and \setcounter
, too.
I kind of doubt this exists - for while not terribly comlicated, I can imagine this tool to be a maintenance nightmare :)
(although, I could also imagine a superlong Community Wiki here, with user-editable examples, which could serve as one downloadable database source for the tool ... or, if there is a single command used for marking examples in .dtx
files and such, maybe examples could be automatically harvested). But still, I'd like to know for sure - so my question is: is there such a tool out there?
texdef
existed... [Clearly I cannot answer your question - sorry.]\@addtoreset
and\value
. Btw:\theNameOfTheNewCounter
is not the value but the representation of the counter.