I'm sure this is such a limited and simplistic MWE that I may not be reporting perfectly the actual issue, but I'll give this a shot.
I'm observing that the lilypond environment read by either lyluatex or lilypond-book is capable of importing modularized content in distinct files using the \include command. My problem is that it doesn't seem to work for all sequences. For example
\score {
<<
\unfoldRepeats{\tune}
>>
}
can't be sourced in a separate file, but as the MWE will show, the command itself when included in the lilypond environment block directly works just fine. Interestingly I wasn't expecting to have to use = inbetween \include and the filename as that isn't used in the lilypond files if I'm compiling them directly, but it seems to be needed in the latex.
\documentclass[letter,fontsize=12pt]{article}
\usepackage{import}
\usepackage{graphics}
\usepackage{grffile}
\usepackage{luatexbase}
\usepackage[program=lilypond]{lyluatex}
\begin{document}
Both files explicitly written out. No include statement in lilypond to process.
\begin{lilypond}
% file 1: test.ly
global = {
\key b \minor
\time 9/8
}
tune = \absolute {
\global
% Music follows here.
\relative c' { c8 d e f g a b c c }
\bar ":|."
}
% file 2: Settings.ly
\score {
<<
\unfoldRepeats{\tune}
>>
}
\end{lilypond}
Music imported from lilypond file with explicitly printing
\begin{lilypond}
%\version "2.18.2"
\include = "test1.ly"
tune = \transpose c d {\first}
\score {
<<
\unfoldRepeats{\first}
>>
}
\end{lilypond}
Music imported from multiple lilypond file with explicitly printing (to prove the files aren't overwriting each other in memory)
\begin{lilypond}
%\version "2.18.2"
\include = "test1.ly"
\include = "test2.ly"
first = \transpose c d {\first}
second = \transpose c b {\second}
\score {
<<
\unfoldRepeats{\first\second}
>>
}
\end{lilypond}
%These options don't work
%\begin{lilypond}
%% file 1: test.ly
% global = {
% \key b \minor
% \time 9/8
% }
% tune = \absolute {
% \global
% % Music follows here.
% \relative c' { c8 d e f g a b c c }
% \bar ":|."
% }
% tune = \transpose c d {\tune}
% \include = "CreateScore.ly"
%\end{lilypond}
%\begin{lilypond}
% \version "2.18.2"
% \include = "test.ly"
% tune = \transpose c d {\tune}
% \include = "CreateScore.ly"
%\end{lilypond}
\end{document}
My first hypothesis was that this was the difference between variables and commands, but was unable to prove this because I could work with notes not saved in variables as well.
I've tried dozens of permutations and tried to simplify the question to what I think the root issue is, but as I've said, I may have simplified it to far to make the actual problem visible.
I've tried absolute paths and as you can see from the MWE I've isolated the "type" of block that fails when modularized or externalized.
I'm compiling from miktex with a bat file that looks like this, which should run on any windows architecture running miktex:
Del "*.pdf"
:CheckOS
IF "%PROCESSOR_ARCHITECTURE%"=="x86" (GOTO 32BIT) ELSE (GOTO 64BIT)
:64BIT
ECHO 64-bit compiling
SET MikTexPath=C:\Program Files\MiKTeX 2.9\miktex\bin\x64\
GOTO END
:32BIT
ECHO 32-bit compiling
SET MikTexPath=C:\Program Files\MiKTeX 2.9\miktex\bin\
GOTO END
:END
SET TeXCompilier=lualatex.exe
FOR %%A IN (*.lytex) DO (
"%MikTexPath%%TeXCompilier%" -shell-escape "%%~nxA"
)
If I uncomment the first block of the MWE that's currently commented out here's the error I get.
This is LuaTeX, Version 1.07.0 (MiKTeX 2.9.6650 64-bit)
system commands enabled.
(./test.lytex
LaTeX2e <2017-04-15>
(using cache: C:/Users/EngBIRD/AppData/Local/MiKTeX/2.9/luatex-cache/generic)
luaotfload | main : initialization completed in 0.609 seconds
Babel <3.18> and hyphenation patterns for 1 language(s) loaded.
("C:/Program Files/MiKTeX 2.9/tex/latex/base/article.cls"
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
("C:/Program Files/MiKTeX 2.9/tex/latex/base/size10.clo"(load luc: C:/Users/Ste
phen/AppData/Local/MiKTeX/2.9/luatex-cache/generic/fonts/otl/lmroman10-regular.
luc))) ("C:/Program Files/MiKTeX 2.9/tex/latex/import/import.sty")
("C:/Program Files/MiKTeX 2.9/tex/latex/graphics/graphics.sty"
("C:/Program Files/MiKTeX 2.9/tex/latex/graphics/trig.sty")
("C:/Program Files/MiKTeX 2.9/tex/latex/graphics-cfg/graphics.cfg")
("C:/Program Files/MiKTeX 2.9/tex/latex/graphics-def/luatex.def"))
("C:/Program Files/MiKTeX 2.9/tex/latex/oberdiek/grffile.sty"
("C:/Program Files/MiKTeX 2.9/tex/generic/oberdiek/ifpdf.sty")
("C:/Program Files/MiKTeX 2.9/tex/generic/ifxetex/ifxetex.sty")
("C:/Program Files/MiKTeX 2.9/tex/latex/oberdiek/kvoptions.sty"
("C:/Program Files/MiKTeX 2.9/tex/latex/graphics/keyval.sty")
("C:/Program Files/MiKTeX 2.9/tex/generic/oberdiek/ltxcmds.sty")
("C:/Program Files/MiKTeX 2.9/tex/generic/oberdiek/kvsetkeys.sty"
("C:/Program Files/MiKTeX 2.9/tex/generic/oberdiek/infwarerr.sty")
("C:/Program Files/MiKTeX 2.9/tex/generic/oberdiek/etexcmds.sty"
("C:/Program Files/MiKTeX 2.9/tex/generic/oberdiek/ifluatex.sty"))))
("C:/Program Files/MiKTeX 2.9/tex/generic/oberdiek/pdftexcmds.sty"))
("C:/Program Files/MiKTeX 2.9/tex/luatex/luatexbase/luatexbase.sty"
("C:/Program Files/MiKTeX 2.9/tex/luatex/ctablestack/ctablestack.sty"))
("C:/Program Files/MiKTeX 2.9/tex/lualatex/lyluatex/lyluatex.sty"
("C:/Program Files/MiKTeX 2.9/tex/latex/xkeyval/xkeyval.sty"
("C:/Program Files/MiKTeX 2.9/tex/generic/xkeyval/xkeyval.tex"
("C:/Program Files/MiKTeX 2.9/tex/generic/xkeyval/xkvutils.tex")))
("C:/Program Files/MiKTeX 2.9/tex/latex/graphics/graphicx.sty")
("C:/Program Files/MiKTeX 2.9/tex/latex/minibox/minibox.sty"
("C:/Program Files/MiKTeX 2.9/tex/latex/l3kernel/expl3.sty"
("C:/Program Files/MiKTeX 2.9/tex/latex/l3kernel/expl3-code.tex")
("C:/Program Files/MiKTeX 2.9/tex/latex/l3kernel/l3pdfmode.def")))
("C:/Program Files/MiKTeX 2.9/tex/latex/environ/environ.sty"
("C:/Program Files/MiKTeX 2.9/tex/latex/trimspaces/trimspaces.sty"))
("C:/Program Files/MiKTeX 2.9/tex/latex/currfile/currfile.sty"
("C:/Program Files/MiKTeX 2.9/tex/latex/filehook/filehook.sty"))
("C:/Program Files/MiKTeX 2.9/tex/latex/pdfpages/pdfpages.sty"
("C:/Program Files/MiKTeX 2.9/tex/latex/base/ifthen.sty")
("C:/Program Files/MiKTeX 2.9/tex/latex/tools/calc.sty")
("C:/Program Files/MiKTeX 2.9/tex/latex/eso-pic/eso-pic.sty"
("C:/Program Files/MiKTeX 2.9/tex/generic/oberdiek/atbegshi.sty")
("C:/Program Files/MiKTeX 2.9/tex/latex/xcolor/xcolor.sty"
("C:/Program Files/MiKTeX 2.9/tex/latex/graphics-cfg/color.cfg")))
("C:/Program Files/MiKTeX 2.9/tex/latex/pdfpages/ppluatex.def"))
("C:/Program Files/MiKTeX 2.9/tex/latex/metalogo/metalogo.sty"))
LaTeX Warning: Unused global option(s):
[letter,fontsize=12pt].
(./test.aux) ("C:/Program Files/MiKTeX 2.9/tex/context/base/supp-pdf.mkii"
[Loading MPS to PDF converter (version 2006.09.02).]
) ("C:/Program Files/MiKTeX 2.9/tex/latex/oberdiek/epstopdf-base.sty"
("C:/Program Files/MiKTeX 2.9/tex/latex/oberdiek/grfext.sty"
("C:/Program Files/MiKTeX 2.9/tex/generic/oberdiek/kvdefinekeys.sty")))
("C:/Program Files/MiKTeX 2.9/tex/latex/oberdiek/pdflscape.sty"
("C:/Program Files/MiKTeX 2.9/tex/latex/graphics/lscape.sty"))(load luc: C:/Users/EngBIRD/AppData/Local/MiKTeX/2.9/luatex-cache/generic/fonts/otl/lmsans10-reg
ular.luc)(load luc: C:/Users/EngBIRD/AppData/Local/MiKTeX/2.9/luatex-cache/generic/fonts/otl/lmmono10-regular.luc)
Module lyluatex Warning: Found something incompatible with `fragment`
(lyluatex) (or `relative`). Setting them to false.
(lyluatex) on input line 33
Module lyluatex Warning: Found something incompatible with `fragment`
(lyluatex) (or `relative`). Setting them to false.
(lyluatex) on input line 46
Module lyluatex Warning: Found something incompatible with `fragment`
(lyluatex) (or `relative`). Setting them to false.
(lyluatex) on input line 62
(lyluatex) Compiling score tmp-ly/026dbc682ca7ab76ec54eb50caff61b9 with LilyPond executable 'lilypond'.
-:30:2: error: unrecognized string, not in text script or \lyricmode
{global = { \key b \minor \time 9/8 } tune = \absolute { \global \relative c' {c8 d e f g a b c c } \bar ":|." } tune = \transpose c d {\tune } \include = "CreateScore.ly"}
-:30:9: error: syntax error, unexpected '='
{global = { \key b \minor \time 9/8 } tune = \absolute { \global \relative c' {c8 d e f g a b c c } \bar ":|." } tune = \transpose c d {\tune } \include = "CreateScore.ly"}
-:30:39: error: unrecognized string, not in text script or \lyricmode
{global = { \key b \minor \time 9/8 }
tune = \absolute { \global \relative c' {c8 d e f g a b c c } \bar ":|." } tune = \transpose c d {\tune } \include = "CreateScore.ly"}
-:30:44: error: syntax error, unexpected '='
{global = { \key b \minor \time 9/8 } tune = \absolute { \global \relative c' {c8 d e f g a b c c } \bar ":|." } tune = \transpose c d {\tune } \include = "CreateScore.ly"}
-:30:58: error: unknown escaped string: `\global'
{global = { \key b \minor \time 9/8 } tune = \absolute {\global \relative c' {c8 d e f g a b c c } \bar ":|." } tune = \transpose c d {\tune } \include = "CreateScore.ly"}
-:30:58: error: unrecognized string, not in text script or \lyricmode
{global = { \key b \minor \time 9/8 } tune = \absolute {\global \relative c' {c8 d e f g a b c c } \bar ":|." } tune = \transpose c d {\tune } \include = "CreateScore.ly"}
-:30:115: error: unrecognized string, not in text script or \lyricmode
{global = { \key b \minor \time 9/8 } tune = \absolute { \global \relative c' {c8 d e f g a b c c } \bar ":|." }
tune = \transpose c d {\tune } \include = "CreateScore.ly"}
-:30:120: error: syntax error, unexpected '='
{global = { \key b \minor \time 9/8 } tune = \absolute { \global \relative c' {c8 d e f g a b c c } \bar ":|." } tune = \transpose c d {\tune } \include = "CreateScore.ly"}
-:30:138: error: unknown escaped string: `\tune'
{global = { \key b \minor \time 9/8 } tune = \absolute { \global \relative c' {c8 d e f g a b c c } \bar ":|." } tune = \transpose c d {\tune } \include = "CreateScore.ly"}
-:30:138: error: unrecognized string, not in text script or \lyricmode
{global = { \key b \minor \time 9/8 } tune = \absolute { \global \relative c' {c8 d e f g a b c c } \bar ":|." } tune = \transpose c d {\tune } \include = "CreateScore.ly"}
-:30:155: error: invalid character: `='
{global = { \key b \minor \time 9/8 } tune = \absolute { \global \relative c' {c8 d e f g a b c c } \bar ":|." } tune = \transpose c d {\tune } \include = "CreateScore.ly"}
-:30:155: error: syntax error, unexpected $undefined
{global = { \key b \minor \time 9/8 } tune = \absolute { \global \relative c' {c8 d e f g a b c c } \bar ":|." } tune = \transpose c d {\tune } \include = CreateScore.ly"}
C:/Home/Personal/Dropbox/CurrentMWE/CreateScore.ly:4:16: error: unknown escaped string: `\tune'
\unfoldRepeats{\tune}
C:/Home/Personal/Dropbox/CurrentMWE/CreateScore.ly:4:16: error: unrecognized string, not in text script or \lyricmode
\unfoldRepeats{\tune}
-:30:1: error: errors found, ignoring music expression
{global = { \key b \minor \time 9/8 } tune = \absolute { \global \relative c' {c8 d e f g a b c c } \bar ":|." } tune = \transpose c d {\tune } \include = "CreateScore.ly"}
fatal error: failed files: "-"
C:/Program Files/MiKTeX 2.9/tex/latex/base/ltluatex.lua:109:
Module lyluatex Error:
(lyluatex) LilyPond failed to compile the score.
(lyluatex) If you need more information
(lyluatex) than the above message,
(lyluatex) please retry with option debug=true.
(lyluatex)
(lyluatex) As the input code has been automatically wrapped
(lyluatex) with a music expression, you may try repeating
(lyluatex) with the `nofragment` option.
(lyluatex) on input line 80
stack traceback:
[C]: in function 'error'
C:/Program Files/MiKTeX 2.9/tex/latex/base/ltluatex.lua:109: in function
<C:/Program Files/MiKTeX 2.9/tex/latex/base/ltluatex.lua:108>
(...tail calls...)
...gram Files/MiKTeX 2.9/tex/lualatex/lyluatex/lyluatex.lua:633: in function '
check_compilation'
...gram Files/MiKTeX 2.9/tex/lualatex/lyluatex/lyluatex.lua:1171: in function
'write_latex'
...gram Files/MiKTeX 2.9/tex/lualatex/lyluatex/lyluatex.lua:1105: in function
'process'
[\directlua]:1: in main chunk.
\ly@compilescore ...directlua {ly.score:process()}
l.80 \end{lilypond}
?
\includeis a lilypond command, not LaTeX so I don't think there's an\inputequivalent. http://lilypond.org/doc/v2.19/Documentation/notation/including-lilypond-files – EngBIRD Apr 06 '18 at 22:27Module lyluatex Error: LilyPond could not be started.the one tex warning I can help withfontsize=12ptshould be simply12ptwitharticleclass. – David Carlisle Apr 07 '18 at 07:40\luatexluaescapestringand this can get awfully wrong if the command doesn't see the actual string but only an include command. E.g. the single quote after\relative clooks problematic. – Ulrike Fischer Apr 07 '18 at 08:06