LyXInset inside float error

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
tburn
Posts: 9
Joined: Fri Aug 29, 2014 9:17 am

Inset inside float error

Post by tburn »

Hi all,
I have a LilyPond inset inside a float:Figure. Im getting the error
Undefined control sequence.
Argument of \@caption has an extra }.
Paragraph ended before \@caption was complete.

If I just have the lilypond inset by itself it works fine.

Can anyone help please?
Thanks,
Tommy

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Re: Inset inside float error

Post by Stefan Kottwitz »

Hi Tommy,

it seems there's a fragile macro which breaks while moving to the list of figures. Protect the macro, that is, write a \protect right before the problematic macro. Or add an optional caption.

Perhaps export your LyX document into LaTeX and post the relevant part here, the code of the figure. Then we could tell you in detail.

Stefan
LaTeX.org admin
tburn
Posts: 9
Joined: Fri Aug 29, 2014 9:17 am

Inset inside float error

Post by tburn »

Hi, Thanks for your reply,
The code can be found here:

Code: Select all

by the original. This has given the final work a much deeper feel,
and it integrates with the story much better.

\begin{figure}
\protect\caption{
\begin{lilypond}[staffsize=18]

\version "2.18.2"
\header {   title = "Symphony"   composer = "Tommy Burn"   opus = "Op. 9" }
\relative c'{   \set Score.alternativeNumberingStyle = #'numbers   \repeat volta 3 { c4 d e f | }     \alternative {       { c4 d e f | c2 d \break }       { f4 g a b | f4 g a b | f2 a | \break }       { c4 d e f | c2 d }     }   c1 \break   \set Score.alternativeNumberingStyle = #'numbers-with-letters   \repeat volta 3 { c,4 d e f | }     \alternative {       { c4 d e f | c2 d \break }       { f4 g a b | f4 g a b | f2 a | \break }       { c4 d e f | c2 d }     }   c1 }
\end{lilypond}
}


\end{figure}

\end{abstract}
As the composer I approached the task with a number of objectives
I wanted to achieve.
Im not sure what you mean by macro? There is a \protect before \caption. Is this what you mean?
Many thanks,
Tommy Burn
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Inset inside float error

Post by Johannes_B »

You have a figure environment (placing the figure to where it fits best) generating the need to reference it by a number and describe it (the figure), i.e. the caption.
Your figure-environment does not include an image (or something else), but a caption containing lilypond code. As the content of the caption is printed to the list of figures as well, nearly all commands inside the caption argument break. You can prevent the breaking by putting a \protect in front of the breaking command (also called macro). In your case, you have an environment inside the caption. Are you sure this should go to the caption?

You didn't post a minimal example and i don't have any experience with lilypond, so i can't be really helpful.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
tburn
Posts: 9
Joined: Fri Aug 29, 2014 9:17 am

Re: Inset inside float error

Post by tburn »

Yes, Thanks so much, That fixed it.
I didn't realise i was putting it as a caption. I thought I was puttting it as a figure. I moved it outside of the caption and wrote appropriatley in the caption box and it works.
Thanks loads.
Tommy
Post Reply