Closed uliska closed 6 years ago
It seems \includegraphics
doesn't like commands with optional argument. This MWE causes the same trouble:
\documentclass{scrartcl}
\usepackage{graphicx}
\begin{document}
\newcommand\abc[1][]{abc}
\includegraphics{\abc}
\end{document}
while this one doesn't:
\documentclass{scrartcl}
\usepackage{graphicx}
\begin{document}
\newcommand\abc[1]{abc}
\includegraphics{\abc{}}
\end{document}
I guess this comes from some expansion trick, but that's beyond my TeX skills… @rpspringuel Any idea ?
If it is indeed an expansion issue then \expandafter\includegraphics{\abc}
should do the trick. This tells LaTeX to expand \abc
before attempting to expand \includegraphics
(which is probably what you want, since \abc
is meant to evaluate to the name of the file to be used as the argument for \includegraphics
).
Unfortunately not:
\expandafter\includegraphics{\lily[raw-pdf]{ c' }}
=>
! TeX capacity exceeded, sorry [input stack size=5000].
<argument> \@protected@testopt \lily
\\lily {}[raw-pdf]{ c' }
l.19 ...dafter\includegraphics{\lily[raw-pdf]{ c' }}
---
\expandafter\includegraphics{\lily{ c' }}
=>
! TeX capacity exceeded, sorry [input stack size=5000].
<argument> \@protected@testopt \lily
\\lily {}{ c' }
l.19 \expandafter\includegraphics{\lily{ c' }}
71651567dd4ed9c4feec8a9ba4201fc53658def9 should fix this. The syntax becomes:
\newcommand\mylily[1]{%
\lily[raw-pdf]{#1}%
\includegraphics{\lysystems}%
}
\mylily{ c' }
And sorry: I forgot to submit it as a PR.
Thank you. I've added some details (we don't want the "systems" output for inline scores) and changed my command to
\newcommand\mylily[2][]{%
\lily[raw-pdf,#1]{#2}%
\includegraphics{\lyscore}%
\let\lyscore\undefined%
}
\mylily{ c' }
\mylily[inline-staffsize=24]{ c' }
I'll create a proof-of-concept implementation in lilyglyphs ASAP.
I think we should undefine \lyscore
ourselves; I'm going to do that.
Just changed it in cd04db912e7ee8da86257c7b1957d9dcc1ec87c0:
\lyscore
is undefined if raw-pdf=false
;insert=inline
and there are several systems (which shouldn't, but could occur), a list is returned (as with insert=systems
).So here is what I eventually did:
\lyscore
has a mandatory argument, that may be empty, in which case it will default to 1;\lyscore{hoffset}
returns the left protrusion;\lyscore{nsystems}
returns the number of systems (or 1 with insert=fullpage
);\lyscore{N}
with N being a number returns:
insert=fullpage
;That way:
insert=inline
), he'll get them;Another change in 02f476c8a5e74319dce047dfdbc71231b3a7e801: all systems are now accessible from \lyscore
, not only those specified in range
.
Just to let you know that I've been off yesterday and won't be able to look into it during the day either.
OK, I've looked into it. I must admit I don't fully understand the behaviour yet. It would be nice if you could describe it in the manual.
But I could update the sample I made for myself did work, and I'm confident I can make the lilyglyphs sample command tomorrow.
I've no time just now for the doc, but here is a dirty example:
\documentclass{scrartcl}
\usepackage{lyluatex}
\usepackage{pgffor}
\begin{document}
\newcommand\mylily[2][]{%
\lily[insert=systems,raw-pdf,#1]{#2}%
\foreach \n in {1,...,\lyscore{nsystems}}{\noindent\includegraphics{\lyscore{\n}}\\}%
}
\mylily{ c' d' e' f' \break d' }
\mylily[staffsize=24]{ c' }
\end{document}
I'm at a loss with wrapping
\lily[raw-pdf]
in an includegraphics command.When I do
it works and "correctly" prints the file name to the document.
But when I try
I get
before the Lilypond file is even compiled.