# Lilypond+TexLive(LuaLatex+lyluatex)+VS Code for mixing spectrum and text

Unexpectedly, it would be harder to preview your article, so copy it into your essays.

After many attempts, the best way to mix music and text at this stage has been achieved:

1. Combine the Latex typesetting (and the widespread availability of the population) with Lilypond's aesthetic advantages;

2. Complete input, compilation and browsing of finished products in the same editor;

3. Spectral surface codes can display between lines and in multiple lines like mathematical formulas;

4. There is no need to set environment variables, no need to operate from the command line.

Next, let's demonstrate the process of Lilypond, TexLive and VS Code.

-----------------------------------

# 1. Lilypond installation

lilypond provides music typesetting

# 2 TexLive

TexLive provides article typesetting

## 2.1 TexLive Installation

TexLive Tsinghua University Mirror Download See   Index of /CTAN/systems/texlive/Images/ |Tsinghua University Open Source Software Mirror

Double-click to open the iso file directly after downloading. Double-click to install it by pressing the position of the red box in the picture

## 2.2   lyluatex installation

lyluatex is the key to compiling lilypond code in Latex and must be installed. In addition, it can only be compiled under LuaLatex, as you will see later.

Open the Tex Live Manager and select all package s as shown below, then search for lyluatex. If it appears that lyluatex is already installed, you do not need to install it exclusively

# 3 VS code

VS Code integrates Latex and Lilypond editing environments

## 3.2 Plugin Latex Workshop

Latex Workshop is used to support Latex compilation and run on vs code

### 3.2.2 Configuration

Press Ctrl + Shift + P to bring up the command interface and enter preferences

Copy the following code in curly brackets (don't copy the curly brackets themselves), then save the settings

{
// Latex Workshop settings, copy from here

"latex-workshop.latex.autoBuild.run": "never",
"latex-workshop.intellisense.package.enabled": true,
"latex-workshop.message.error.show": false,
"latex-workshop.message.warning.show": false,
"latex-workshop.latex.tools": [
{
"name": "lualatex",
"command": "lualatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-shell-escape",　　　　//This command line is not typically present in the Latex Workshop settings on the web, so direct recipe errors
"%DOCFILE%"
]
}
],
"latex-workshop.latex.recipes": [
{
"name": "LuaLaTeX",
"tools": [
"lualatex"
]
},
],
"latex-workshop.latex.clean.fileTypes": [
"*.aux",
"*.bbl",
"*.blg",
"*.idx",
"*.ind",
"*.lof",
"*.lot",
"*.out",
"*.toc",
"*.acn",
"*.acr",
"*.alg",
"*.glg",
"*.glo",
"*.gls",
"*.ist",
"*.fls",
"*.log",
"*.fdb_latexmk"
],
"latex-workshop.latex.autoClean.run": "onFailed",
"latex-workshop.latex.recipe.default": "lastUsed",
"latex-workshop.view.pdf.internal.synctex.keybinding": "double-click",
"latex-workshop.view.pdf.external.viewer.command": "C:\\Program Files (x86)\\Adobe\\Acrobat DC\\Acrobat\\Acrobat.exe",　　　　　　　　//Double quotation marks are executable files of pdf browser, which can be changed according to the actual situation
"latex-workshop.view.pdf.viewer": "tab"　　//Copy to End Here
}    

# 4 Compile Files

Start by creating a new *.tex file in vs code and writing the code:

\documentclass{article}

%% The settings at the beginning ensure that Chinese is typed freely and can be used LuaLatex Compile. lyluatex Can only pass through LuaLatex To compile
\usepackage[UTF8]{ctex}

%% Use lyluatex Macro package to compile lilypond Sentence
\usepackage{lyluatex}

% geometry Macro packages can be used to resize paper flexibly
\usepackage{geometry}
\geometry{a4paper, scale=0.65}

%% For fear of too dense, adjust the line spacing

%% text
\begin{document}
\title{Use lyluatex Implement Spectral Mixing}
\author{lilypond Hand Residual Powder}

\maketitle

Build up lilypond and latex After the settings of, you can make music scores in various ways. For example:

Only input is required \textbackslash lilypond\{c' d' e'\},Can do line marking \lilypond{c' d' e'} As you can see.

Grammar in braces and lilypond The grammar in is consistent. For example, input\textbackslash lilypond\{  \textbackslash clef bass  \textbackslash omit Staff.TimeSignature
c' d' e'  \} And you can see that\underline{Bass notation}as well as\underline{Remove the beat number}after\lilypond{\clef bass \omit Staff.TimeSignature c' d' e'}Beating effect of.

Can also be used\textbackslash begin\{lilypond\} and \textbackslash end\{lilypond\} Direct Entry lilypond Environments, like editing mathematical formulas, edit music scores.

%% A blank line
\vspace*{0.5\baselineskip}

%% lilypond Environmental Science

\begin{lilypond}
music = \relative {
c d e
}
\score {
\new ChoirStaff \with {
instrumentName = "2 Fl."
} <<
\new Staff \transpose c c' \music
\new Staff {
\clef bass
\music
}
>>
}
\end{lilypond}

In this way, you can make use of Latex Can also take advantage of lilypond The score making advantage of, lilypond Clumsy typesetting is finally a good bye.

\end{document}

Because it is a tex file, the text appears on the left side of vs code after it is created, click it, and then click Recipe: LuaLaTex in the COMMANDS column

Finally, select View in VSCode Tab to see the results

Tags: Latex

Posted on Wed, 24 Nov 2021 14:34:29 -0500 by pherrick