3

This problem is similar to the one here and it is based on the referenced post that I became aware of arara.

What I'm trying to do is also automate the multi-step process of generating a pdf from a music.lytex file.

lilypond-book --output=out --pdf music.lytex 
cd out/
pdflatex music.tex
pdflatex music.tex

I have created the lilypond rule as per the referenced posting (pointed to by araraconfig.yml):

!config
# Mainfile rule for arara
# author: Marco Daniel
# requires arara 3.0+
identifier: lilypond
name: Lilypond
command: <arara> lilypond-book @{format} @{options} @{output} "@{file}"
arguments:
- identifier: format
  flag: <arara> --format=@{parameters.latex-programm}
  default: <arara> --format=latex
- identifier: options
  flag: <arara> @{parameters.options}
- identifier: output
  flag: <arara> --output=@{parameters.output}

I'm hoping for some insight as to whether the rule is correctly configured for the requirements of the task, and how exactly the arara directives should be configured in the lytex file. Currently I have tried variations on:

% arara: lilypond {options: --output=out --pdf music.tex}
% arara: pdflatex: { files: [ out/music.tex ] }

But I am ending up with:

  __ _ _ __ __ _ _ __ __ _ 
 / _` | '__/ _` | '__/ _` |
| (_| | | | (_| | | | (_| |
 \__,_|_|  \__,_|_|  \__,_|

Apparently, there's an invalid directive at line 1. Please take a
look and fix it.

It seems like the word lilypond-book would need to be there in the arara directive, unless that is coming from the rule. I tried removing some of the arguments from the command in the rule.yaml file, but so far my ignorance is winning the argument.

  • One thing I noticed is a missing colon from the first arara directive. New error is: Running Lilypond... FAILURE. – MikeiLL Aug 17 '16 at 15:13
3

Good news. One of the arara developers helped me solve the problem.

The solution ends up being quiet simple. The only limitation is that we are not outputting the lilypond-book content to a subdirectory as originally planned.

At the top of the music.lytex file (after configuring arara as directed in the referenced post), add the following two directives:

% arara: lilypond: {options: "--pdf"}
% arara: pdflatex: { files: [ 'hymnal.tex' ] }

Now make a file called render.sh containing something like the following:

arara music.lytex
pdflatex music.tex
find . -maxdepth 1 -type d -name '??' -exec rm -rf {} \;
rm *.aux *.bcf *.dep *.out *.run.xml *.tex *.toc tmpx*
open music.pdf

And render and view the resultant pdf file by calling it with bash:

bash render.sh

The middle three lines in the bash script:

pdflatex music.tex

This is because pdflatex needs to be run a second time in order to generate the table of contents.

find . -maxdepth 1 -type d -name '??' -exec rm -rf {} \;

What this line does is remove all of the temporary directories created by the lilypond-book command, which would, if generating into a subdirectory (with the --output=out) flag, be neatly contained in there.

rm *.aux *.bcf *.dep *.out *.run.xml *.tex *.toc tmpx*

All the other temporary files that might interfere with subsequent renderings. NOTE: I may end up deciding (realizing) that the .tex file needs to and can without interference remain.

Thanks, arara crew. Long live the arara bird and Brazilian hospitality!

| improve this answer | |
  • Please correct me if I missed something, but if you aren't directing the output of lilypond-book to a subdirectory, how have you prevented it from overwriting your source files that may also be in different directories? Thanks! – EngBIRD Jan 7 '17 at 16:38
  • What files are you thinking would be overwritten? The output files are all overwritten every time I re-render the main file, which is time-consuming, but I don't believe any of the source files (lytex, ly, image) are being overwritten. – MikeiLL Jan 7 '17 at 17:20
  • My experience is if you have a file that includes content and an include lilypond command, that file is overwritten with the pdf or eps includegraphics commands that lilypond book precompiles for latex. This means, that if your processing your lilypond as you write your files, you loose the ability to keep both updated simultaneously. Perhaps the description in this question can make my experience clearer. If you don't have this problem, it may be the answer I've been looking for: tex.stackexchange.com/questions/272853/… – EngBIRD Jan 7 '17 at 17:56
  • Unfortunately a "clean working directory" is not what I have here. github.com/MikeiLL/hymnal-Vol-II Most of the junk is my working directory is git-ignored. Not sure if I understand the question thoroughly, but my main file has a lytex extension and renders a .tex file. – MikeiLL Jan 8 '17 at 0:25
  • That must be it. I can't use a lytex extension, at least not as I have implemented my non arrara solution, so I ended up overwritting my tex files with more tex files... Thanks! and Sorry to have wasted your time. – EngBIRD Jan 8 '17 at 1:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.