lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Rationale for LaTeX lilypond-book syntax?


From: David Kastrup
Subject: Re: Rationale for LaTeX lilypond-book syntax?
Date: Sun, 18 Apr 2010 17:59:10 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.92 (gnu/linux)

Francisco Vila <address@hidden> writes:

> 2010/4/18 David Kastrup <address@hidden>:
>>
>> Hi,
>>
>> the "LaTeX" syntax for lilypond-book happens to be something like
>>
>> \begin[verbatim,fragment]{lilypond}
>>  \relative c' { c << { d e } { b c } >> <c es g> }
>> \end{lilypond}
>>
>> Unfortunately, this is quite annoying since actual optional arguments
>> for environments come _after_ the environment name in LaTeX, like
>>
>> \begin{lilypond}[verbatim,fragment]
>>  \relative c' { c << { d e } { b c } >> <c es g> }
>> \end{lilypond}
>>
>> This is not academic: the current syntax prohibits making a TeX
>> implementation of lilypond-book (where TeX could write out the lilypond
>> environments and macros itself and run lilypond at the end of the TeX
>> run).  It also confuses the heck out of LaTeX-savvy editors which fail
>> to recognize the current syntax, making indentation and other supporting
>> functionality fail.
>>
>> Would it be feasible to obsolete the first syntax and support (and
>> recommend) the second syntax?
>
> I use spanish option in the babel package and the syntax is
>
>   \usepackage[spanish]{babel}
>
> Is this also considered obsolete?

What makes you think that?  The normal place for optional arguments in
LaTeX is before the required (if any arguments) of a command.  The
command here is \usepackage.  \usepackage is somewhat weird in that you
can followup with another optional argument _after_ the required
argument, like

\usepackage[spanish]{babel}[2006/01/20]

which tells LaTeX to complain when the version of babel loaded is older
than 2006/01/20.  But in general, optional arguments come after the
command name in question.

\begin itself, however, does not have optional arguments.
\begin{someenvironment} however, may have optional arguments.  LaTeX
parses from the left to right: whether an environment may have optional
arguments can be decided only after the environment has been specified.
So the optional characters for an environment come after the name.

If I write

\documentclass{minimal}
\newenvironment{example}[2][default]{\message{arg1: #1, arg2: #2.}}{}
\begin{document}
\begin{example}{Blubb}
\end{example}
\begin{example}[ups]{Bla}
\end{example}
\end{document}

then I get

arg1: default, arg2: Blubb. arg1: ups, arg2: Bla.

as output.  You can see that \newenvironment has a quite specific syntax
for optional arguments.

-- 
David Kastrup





reply via email to

[Prev in Thread] Current Thread [Next in Thread]