Generalposition of optional parameter in a LaTeX command.

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
yoo
Posts: 5
Joined: Sun Nov 08, 2009 2:38 pm

position of optional parameter in a LaTeX command.

Post by yoo »

Usually LaTeX macro takes parameters in the form: \somecommand[opt-param1][opt-param2]{param1}{param2}

But the \blindlistlist command in the blindtext package takes an optional parameter after an obligatory parameter: \blindlistlist[<level>]{<env>}[<x>]

What is the benefit of taking an optional parameter after an obligatory parameter? And how do I define such a command?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

position of optional parameter in a LaTeX command.

Post by sommerfee »

yoo wrote:What is the benefit of taking an optional parameter after an obligatory parameter?
One could add optional parameters without getting incompatible to its previous syntax, e.g. extend its syntax from

\xxx[<o-arg 1>]{<m-arg>}

to

\xxx[<o-arg 1>]{<m-arg>}[<o-arg 2>]
And how do I define such a command?
LaTeX and their packages are Open Source, so just take a look at the code of \blindlistlist.
Last edited by sommerfee on Sun Nov 08, 2009 10:13 pm, edited 1 time in total.
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

position of optional parameter in a LaTeX command.

Post by josephwright »

You could use the LaTeX3 xparse package to do this easily:

Code: Select all

Code, edit and compile here:
\DeclareDocumentCommand \blintext {o +m o}{%
% Code
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Joseph Wright
Post Reply