1

I do not like R and LaTeX. I simply love them. In R, I can get the arguments of any function using args(function_name) on command line. I wonder if we can get the list of all possible arguments of any LaTeX command. Any help will be highly appreciated. Thanks

  • 3
    Not really. If you try \show\section, you'll find it actually has no argument. – egreg Jul 16 '17 at 22:10
  • @egreg Technically, that is the answer. It just probably isn't the one the OP wants. – cfr Jul 17 '17 at 1:13
  • You are probably looking the LaTeX2e unofficial reference manual. – Henri Menke Jul 17 '17 at 1:48
3

TeX has about three hundred primitive commands, but just a few of them are ever directly used in a LaTeX document. There is no method available for showing their arguments and it would be rather useless anyway, for the above mentioned reason: you don't use them, it's macros that do.

To add a layer of complication, TeX macros don't really allow for optional arguments or *-variants: this is obtained by clever use of macros.

If you do something like

\def\foo#1{foo is #1}

then you can type in your document

\show\foo

which would stop the run of TeX and display

> \foo=macro:
#1->foo is #1.

but that's all you can get. More complicated commands such as \section will display even more mysterious information:

\section=\long macro:
->\@startsection {section}{1}{\z@ }{-3.5ex \@plus -1ex \@minus -.2ex}{2.3ex \@plus .2ex}{\normalfont \Large \bfseries }.

which means that \section has no argument whatsoever; what comes after \section in your typescript will be handed as an argument to \@startsection. Doing \show\@startsection will show a big amount of data much more mysterious than the above.

Moreover, \section is a command defined by the document class. Different classes may allow for different sets of arguments. The synopsis for \section (from a user's perspective) could be

\section*[<header and toc title>]{<title>}

with the explanation that when * is found, the optional argument is not allowed. However, this is true for article and other classes, but memoir allows for a different syntax

\section*[<header title>][<toc title>]{<title>}

(if a single optional argument is used, the result would be the same as for article).

What you can do is to rely upon manuals. For instance, the LaTeX2e unofficial reference manual describes the most important commands in the LaTeX kernel and in the standard article, report and book classes.

For other commands defined by additional packages, you should consult the respective documentation.

Programming languages such as R or Pari-GP can and do show the syntax for each command, maybe also telling the user what kind of argument is expected. There might be a way for doing something similar for LaTeX commands, but it would add a big burden on the package author (and no package provides such a thing except in documentation).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.