texstudio-org / texstudio

TeXstudio is a fully featured LaTeX editor. Our goal is to make writing LaTeX documents as easy and comfortable as possible.
http://www.texstudio.org/
GNU General Public License v3.0
2.77k stars 343 forks source link

Lilypond Plug-In for TeXstudio #236

Closed hegelkoenig closed 6 years ago

hegelkoenig commented 6 years ago

An excellent feature would be a plug-in, in which GNU Lilypond is integrated into TeXstudio. One can generate LaTeX files with music in a workaround with lilypond-book, but the flip-side is that one cannot generate .pdf previews in TeXstudio or other common LaTeX programs.

For example if something like this:

\documentclass[12pt, a4paper]{article}
%\usepackage{graphicx}
\begin{document}
    \textbf{C Major} \\
    %\noindent\includegraphics{c_major_scale.pdf}
    \begin{lilypond}
        #(set! paper-alist (cons '("mein Format" . (cons (* 16 cm) (* 3 cm))) paper-alist))
        \paper { 
            #(set-paper-size "mein Format") oddHeaderMarkup = "" evenHeaderMarkup = "" oddFooterMarkup = "" evenFooterMarkup = "" 
        }
        \layout { 
            indent = #0
        }
        \relative c' 
        {
            c16-1 d e f-1 g a b c-1 
            d e f-1 g a b c-5 b |
            a g f e-3 d c b-4 a 
            g f e-3 d c4 
            \bar"|."
        }
    \end{lilypond}
\end{document}

would generate something like this:

minexample.pdf

This would mean writing music with lilypond wouldn't have to be so complicated with lilypond-book or a few dozen snippet files that all have to separately converted into .pdf's. Instead, TeXstudio would be the ideal program to write all kinds of music books and sheet music.

dbitouze commented 6 years ago

Aside remark: are aware of https://ctan.org/pkg/lyluatex ?

hegelkoenig commented 6 years ago

No I wasn't. Included the package, doesn't seem to work with TeXstudio. None of the commands are recognised. In the package documentation the program TeXlive was used, I'll have a go with that. Would still prefer to use TeXstudio, as it has been flawless up until now.

dbitouze commented 6 years ago

It does work, but you have to define your own User Command in Options → Configure TeXstudio → Build → User Commands:

  1. Click on "+ Add"
  2. in the first box: user0:user0:lyluatex (for instance)
  3. in the second box: lualatex --shell-escape %
  4. Click on "OK".

Now, open your file and run it with Alt+Maj+F1 (or visit Tools → User → 1: lyluatex).

The unrecognized commands by TXS may be recognized by (Lua)LaTeX: just is missing a .cwl file for all LilyPond macros (see section "4.13 Description of the cwl format" in TXS' manual).

TeX Live is not a problem: it is a TeX distribution, just as MiKTeX is, nothing to do with the LaTeX IDE as TXS is.

hegelkoenig commented 6 years ago

Tried it, seems to be doing something, but I get the following error:

Der Befehl "lilypond" ist entweder falsch geschrieben oder konnte nicht gefunden werden.

...ta/Local/Programs/MiKTeX 2.9/tex/latex/base/ltluatex.lua:109: 
Module lyluatex Error: LilyPond could not be started.
(lyluatex)             Please check that LuaLaTeX is started with the
(lyluatex)             --shell-escape option, and that 'program'
(lyluatex)             points to a valid LilyPond executable.
(lyluatex)             on input line 1

Translation: the command "lilypond" is either written wrong or cannot be found.

dbitouze commented 6 years ago

Is lilypond in your PATH?

hegelkoenig commented 6 years ago

Probably not; how do I put it there?

dbitouze commented 6 years ago

Well, I'm a Linux user so I'm far from being a Windows expert. See e.g. "Running on the command-line" at http://lilypond.org/windows.html.

hegelkoenig commented 6 years ago

Followed the directions there, still no banana. I'll raise an issue for the lyluatex package and see if someone can help me there. Thanks a lot :)

hegelkoenig commented 6 years ago

https://github.com/jperon/lyluatex/issues/204