I am quite new to LaTeX and as I was reading the LaTeX Wikibook I came upon the following general definition for a command in LaTeX here:
\commandname[option1,option2,...]{argument1}{argument2}...
However, later on in the Wikibook the syntax for creating a new command is given as:
\newcommand{name}[num][default]{definition}
Now given the general definition for a command in LaTeX I would have instead expected the following syntax for creating a new command:
\newcommand[num,default]{name}{definition}
A bit later on in the same section on creating macros in the LaTeX wikibook the syntax for creating a new environment is given as:
\newenvironment{name}[num][default]{before}{after}
Again, given the general definition I would have expected this instead:
\newenvironment[num,default]{name}{before}{after}
I would appreciate it greatly if somebody could clarify this inconsistency for me.
\newcommandwill invariably have the syntax\cmd{<arg1>}{<arg2>}...or\cmd[<opt>]{<arg1>}{<arg2>}.... Commands defined withxparsehave much more flexibility, and you can also define the commands by hand to have virtually any syntax you want. – Phelype Oleinik Oct 19 '19 at 14:59[]for optional arguments and{}for mandatory ones. Third type is()for coordinates, but those are pretty rare in the LaTeX format itself (picture-mode). There are some classes and packages however that break this general rule and add optional braced arguments, so not even those are safe. And the concept ofkey=valueoptional arguments is relatively young, so the older the macro the less likely they are used. – Skillmon Oct 19 '19 at 15:05key=valuesyntax will most likely never be fully expandable, so there might be macros which take normal and possibly multiple optional arguments in the distant future, whenkey=valuehas otherwise fully took over. – Skillmon Oct 19 '19 at 15:10key=valuemeans? – The Riddler Oct 19 '19 at 15:11\commandnameis not a standard macro, but rather an example of how to use a macro, while\newcommandis a LaTeX macro used to create new commands (replacing the original TeX\def\name#1#2...{definition}). – John Kormylo Oct 19 '19 at 15:14width=2in,rotate=90etc rather than having several arguments, or several different commands for different options. – alephzero Oct 19 '19 at 15:38lipsumcommads (e.g.\lipsum[1][1-3]) where are not allowed any arguments. And you an also face with constructs like\cmidrule{1-3}(rl)with thebooktabspackage, where the part in () is optional too. To clarify the question (or may be help to the confusion) think about this code:\def\bold*#1*{{\bfseries #1}} \def\italics<#1>{\textit{#1}}this allow you to use\bold*foo*or\italics<baz>. It is hard maintain a consistent syntax in hundreds of packages when you can make almost anything. – Fran Oct 19 '19 at 19:38