I am already very fond of the texdef tool, which is used on the command line, something like this:

$ texdef -t latex \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
% To increase the counter, use:
% ... or (add number 1):
% To set the counter value explicitly, use:
% 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?

  • 2
    I'm so glad you asked this as I had no idea anything like texdef existed... [Clearly I cannot answer your question - sorry.]
    – cfr
    Jun 26, 2014 at 1:37
  • 1
    Well I use a book if I want to look up such things. At first the LaTex Companion. It even shows related commands like \@addtoreset and \value. Btw: \theNameOfTheNewCounter is not the value but the representation of the counter. Jun 26, 2014 at 8:20

1 Answer 1


The NASA LaTeX site provides about the right amount of information for what you want: http://www.giss.nasa.gov/tools/latex/index.html

You could access it from the command line with a text browser like elinks. For example, on a Unixy system, you could put this in your .bash_aliases or other appropriate dot file:

function texhelp {
  elinks http://www.google.com/search?q="$1"+site:http://giss.nasa.gov/tools/latex

Usage: In the terminal, type texhelp newcounter.

NASA offers their whole documentation site for download, so you could do an offline version of this, still using the text browser; or you could strip the HTML files and then use grep, etc.

  • 1
    +1, this is a good idea. I could also imagine a similar setup with a texhelp "elvi" for SurfRaw. Aug 20, 2014 at 1:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .