lilypond LaTeX 集成

lilypond LaTeX 集成

我可以輕鬆地使用 LaTex 和 lilypond,但我正在從事一個需要使用 Latex 進行音樂摘錄的項目,我很難將 Latex 和 lilypond 整合起來。我可以從其中任何一個產生 pdf 文件,但 lilypond 的命令提示字元不允許我輸入任何命令。有什麼建議麼?

答案1

您的問題沒有詳細描述您嘗試過的內容或您的系統,所以我只能猜測。但根據我自己參與的使用 lilypond 預編譯乳膠文檔的項目,我可以推薦以下內容:

首先:

MainDev.lytex

\documentclass{article}

\usepackage{import}
\usepackage{graphics}

\begin{document}

\section{LilyPond Code integrated}

Test content

\begin{lilypond}
    \relative c' {
        c2 e2 \tuplet 3/2 { f8 a b } a2 e4 c2 e2 \tuplet 3/2 { f8 a b } a2 e4 c2 e2
        \tuplet 3/2 { f8 a b } a2 e4 c2 e2 \tuplet 3/2 { f8 a b } a2 e4 c2 e2 \tuplet
        3/2 { f8 a b } a2 e4 c2 e2 \tuplet 3/2 { f8 a b } a2 e4 c2 e2 \tuplet 3/2 { f8
        a b } a2 e4 }
\end{lilypond}

End of document

\end{document}

編譯:

  1. 我把這個檔案放在你專案的根目錄下
  2. 根層級還包含一個名為「LilyPondPrecompile」的資料夾
  3. 根級別還包含一個名為“src”的資料夾 - 我建議將除主文件之外的所有文件放在這裡。
  4. 在執行 MiKTeX 的 Windows 7 上,您可以建立一個 bat 文件,該文件將使用以下命令預先編譯您的文件:

    FOR %%A IN (*.lytex) DO ^
    (ECHO %%~nxA & "lilypond-book" --pdf -f LaTeX ^
                                   --include "src" ^
                                   --output "LilyPondPrecompile" "%%~nxA")
    
  5. 然後,您可以在新建立的資料夾「LilyPondPrecompile」中編譯根 tex 檔案(注意 - 可能需要定期清除此資料夾,因為 lilypond 似乎旨在更新文件,預設不會覆蓋。)

  6. 使用傳統方法編譯 tex 檔。

解釋性說明:上面的結構和命令列範例源自我的實踐,即在根目錄中為給定文檔儲存不超過1 個主可編譯文件,以便可以同時編譯任何文檔集合,而不會從子文件產生錯誤。

答案2

相關內容