jperon / lyluatex

Alternative à lilypond-book pour lualatex
MIT License
58 stars 12 forks source link

caption option #102

Closed uliska closed 6 years ago

uliska commented 6 years ago

It may seem unnecessary but I want to add a caption option that inserts a caption before or after the score.

While captions can easily be entered manually it will be necessary when integrated with musicexamples. In that case lyluatex will implicitly produce an environment (or command for fullpage scores) and wrap the score in it. In this situation we have to inject the caption programmatically.

captionbefore (false) will insert the caption before the score, default is after.

jperon commented 6 years ago

It should be discussed further in #50, but why make lyluatex implicitly wrap an environment or a command, while its commands could be wrapped within musicexamples package ?

uliska commented 6 years ago

Because this is a convenience, especially when thinking about implicitly calling all this from Pandoc.
Instead of

\begin{musicExampleNonFloat}
    \begin{lilypond}
      % some LilyPond code
    \end{lilypond}
    \caption{Single system music example (non-floating)}
    \label{xmp:single-system-non-floating}
\end{musicExampleNonFloat}

I can write

\begin{lilypond}[caption={My caption},label=single-system-non-floating]
  % some LilyPond code
\end{lilypond}

and have it laid out automatically.

For example all the scores in our documents that have so far been spaced so-so because they are simply put into paragraphs (too close to the text, no caption) will automagically look better with that integration.

jperon commented 6 years ago

Sure, but what I mean is that you could have:

begin{musicExampleNonFloat}[caption={My caption}]
  % some LilyPond code
\end{musicExampleNonFloat}

with the definition of musicExampleNonFloat wrapping ly.

uliska commented 6 years ago

OK, I see we have to indeed discuss this further.

I also have to think more about the issue, but I am quite sure that we'll be better off if lyluatex uses musicexamples than the other way round (also because I would like to try to keep musicexamples free of the LuaLaTeX dependency).

uliska commented 6 years ago

I've just stumbled over this again, and I'll implement something:

When a caption is set the score will be wrapped in an environment, by default figure. Through a command similar to \lysetverbenv it will be possible to change that to an arbitrary environment.

In a later step (probably after the next release) I'll change that so that when musicexamples is loaded the environment is initially set to a musicexamples environment. That way I'll have my functionality of automatic detection while not enforcing it.