Re: Creating marginal comments?

2016-12-05 Thread Knut Petersen

Hi Tapani!

Two problems:
1. I'm producing a hymnal with 100s of entries. To keep things tidy, those
hymns are in separate .ly files, and I then use lilypond-book to compile
them into one document. To embed every music file in a single (massive) .tex
document is not realistic at this stage of the project.


Well, I agree that it is a good idea to keep the hymns in separate files. TeX knows 
"\input".
But I do not know how much work would it be to edit your scores. It might be an 
easy
automatic process using sed, it might be complicated ...


2. I'm too much of a newbie to understand /how/ your method works. Would you
be able to explain it to me in simple/ish terms, or do I just have to go
away and buy a LaTeX manual and really learn the language properly? OR,
alternatively, can I just insert the \newcount commands into my preamble and
use the \def\callback[etc.] argument in the document?

I prepared a somewhat commented version of hymex.tex. Having a LaTex manual
as well as the TeXbook is always a good idea.

cu,
 Knut
\NeedsTeXFormat{LaTeX2e}
%
% Translate with 
% lualatex (or xelatex) --shell-escape
%
% Postprocess the pdf with
% gs -dNOPAUSE -q -sOutputFile=hymexc.pdf -sDEVICE=pdfwrite -dBATCH *.font.ps hymex.pdf
%
\documentclass[10pt]{letter}
%
% We use geometry to define A5 page parameters. After that quire.tex
% from Midnight Macros is used to redefine shipout routines to
% put these pages on A4 sheets. \quire{n} defines the number of A5
% pages for each quire. This probably is the only parameter you want
% to adapt to your needs.
%
% See: tug.ctan.org/macros/generic/midnight/midnight.pdf
%
\usepackage{geometry}
\geometry{a5paper,left=2cm,right=3cm,top=1.5cm,bottom=1.5cm,twoside,
 marginparsep=3mm,marginparwidth=1.9cm}
\input quire.tex
   \paperwidth=2\paperwidth  \shhtotal=\paperwidth   \htotal=0.5\paperwidth
   \vtotal=\paperheight  \horigin=1in\vorigin=1in
   \shvoffset=-1in   \shvcorrection=0pt  \shthickness=0pt
   \shhcorrection=0pt\shoutline=0pt  \shstaplewidth=0pt
   \shstaplelength=0pt   \shcrop=0pt \shfootline={}
   \def\supereject{\par\penalty-2}
   \latexquire
   \quire{8} % You might want to change this, see midnight.pdf

\usepackage[english,german]{babel}
\selectlanguage{german}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\DeclareUTFcharacter[\UTFencname]{x201C}{\grqq}
\DeclareUTFcharacter[\UTFencname]{x201E}{\glqq}
\setmainfont{CMU Serif}
\setsansfont{CMU Sans Serif}
\setmonofont{CMU Typewriter Text}
\usepackage{graphicx}
\usepackage{shellesc}
\usepackage{soul}
\usepackage{calc}

% Define our name space
%===
% file name prefix for all our temporary files
\def\tmpNamePrefix{tmplily}
% file name prefix for all our fragment files
\def\tmpFragPrefix{\tmpNamePrefix frag}

% Files we construct and use
%
% main lilypond source file
\def\tmpNameMain{\tmpNamePrefix .ly}
\newwrite\tmpFileMain
% head part, included by main file
\def\tmpNameHead{\tmpNamePrefix head.ly}
\newwrite\tmpFileHead
% paper definition part, included by main file
\def\tmpNamePaper{\tmpNamePrefix paper.ly}
\newwrite\tmpFilePaper
% tail part, included by main file  
\def\tmpNameTail{\tmpNamePrefix tail.ly}
\newwrite\tmpFileTail
% name of pdf construced by lilypond from the files above
\def\tmpNamePdf{\tmpNamePrefix .pdf }
% name of fragment count file (also provided by lilypond)
\def\tmpNameFragCount{\tmpNamePrefix -systems.count }
\newread\fragcountfile

% Define some counters
%==
\newcount\fragcount % holds the number of the lilyfrag environment
\newcount\fragpagecount % holds the number of pages in the pdf constructed by lilypond
\newcount\fragpagenum % holds the page number currently processed


% This defines how we call lilypond. Don't change the parameters unless you really
% know what you are doing:

\def\lilycommand{lilypond -b -dbackend=eps -dgs-never-embed-fonts=\#t -dfont-export-dir=./ }

%
% The following code is needed by the definition of the lily* environments below.
% The typical lilypond user does not need to understand what's going on here below:
%

{
  \catcode`|=0 \catcode`[=1 \catcode`]=2 \catcode`\#=12
  \catcode`\{=12 \catcode`\}=12 \catcode`\\=12
  |gdef|eohead[\end{lilyhead}]
  |gdef|eofrag[\end{lilyfrag}]
  |gdef|eotail[\end{lilytail}]
  |gdef|hashtag[#]
  |gdef|escape[\]
  |gdef|definepaper[\definepaper]
]

{
  \obeylines
  \gdef\doline#1
  {
\def\oneline{#1}
\ifx\oneline\eohead\def\next{\end{lilyhead}}\else
\ifx\oneline\eofrag\def\next{\end{lilyfrag}}\else
\ifx\oneline\eotail\def\next{\end{lilytail}}\else 
\ifx\oneline\definepaper\immediate\write\tmpFile{\escape include "\tmpNamePaper"}\let\next\doline
\else\immediate\write\tmpFile{\oneline}\let\next\doline
\fi\fi\fi\fi\next%
  }
}

%
% Define the lilyhead, lilytail and lilyfrag environments.
%
% The lilyhead environment has no arguments. Lilypond 

Re: Creating marginal comments?

2016-12-01 Thread tapani
Knut Petersen wrote
> Am 29.11.2016 um 13:02 schrieb tapani:
>> I am producing a hymnal, using Lilypond and lilypond-book with xelatex. I
>> would like to insert biblical references in the margin of the page,
>> parallel
>> with the lyrics.
>>
>> For example, in "Hark, the Herald Angels Sing", the lyrics "Ris'n with
>> healing in his wings" would have "Mal. 4:2" in the margin.
>>
>> In TeX like systems, this is easily done with the \marginnote command.
>>
> 
> So do use TeX ;-) Put the attached files in an empty directory, don't
> forget to make mkhymex and mypdfcrop
> executable, then run ./mkhymex. You'll get an 8-page hymnal book with some
> example marginal notes.
> Two A5 pages on every side of an A4 sheet, correctly arranged for
> printing.

Thank you. I don't have everything installed on my system to make this
compile correctly, but even then I can see that it works.

Two problems:
1. I'm producing a hymnal with 100s of entries. To keep things tidy, those
hymns are in separate .ly files, and I then use lilypond-book to compile
them into one document. To embed every music file in a single (massive) .tex
document is not realistic at this stage of the project.

2. I'm too much of a newbie to understand /how/ your method works. Would you
be able to explain it to me in simple/ish terms, or do I just have to go
away and buy a LaTeX manual and really learn the language properly? OR,
alternatively, can I just insert the \newcount commands into my preamble and
use the \def\callback[etc.] argument in the document?

Sorry to be an ignoramus!
Tapani





--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Creating-marginal-comments-tp197250p197446.html
Sent from the User mailing list archive at Nabble.com.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Creating marginal comments?

2016-11-30 Thread Simon Albrecht

On 29.11.2016 21:33, Gerdau, Michael wrote:

and LilyPond can’t even handle multiple columns on one page, so you’d

I may have a wrong perception as to what you mean by "multiple columns".

For my own uses I regularly create scores (and texts) that span multiple columns
and are aligned like a table.

There actually are several ways to do that in lilypond AFAIC.


Which ways would you be referring to? You can’t say

\paper {
  columns = 2
}

Also, there is no way in markup to have text automatically flow over 
more than one column, it has to be done all manually.


Best, Simon

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Creating marginal comments?

2016-11-30 Thread Knut Petersen

Am 29.11.2016 um 13:02 schrieb tapani:

I am producing a hymnal, using Lilypond and lilypond-book with xelatex. I
would like to insert biblical references in the margin of the page, parallel
with the lyrics.

For example, in "Hark, the Herald Angels Sing", the lyrics "Ris'n with
healing in his wings" would have "Mal. 4:2" in the margin.

In TeX like systems, this is easily done with the \marginnote command.



So do use TeX ;-) Put the attached files in an empty directory, don't forget to 
make mkhymex and mypdfcrop
executable, then run ./mkhymex. You'll get an 8-page hymnal book with some 
example marginal notes.
Two A5 pages on every side of an A4 sheet, correctly arranged for printing.

hymex.tex is the hymnal example file to be compiled by lualatex or xelatex.
mkhymex is a script to translate hymex.tex to hymexc.pdf.
mypdfcrop is needed because pdfcrop is broken for pdfs without embedded fonts.

Only recent versions of luaLatex and xelatex will work. For lualatex that means 
version 0.8x won't work.
hymex.tex requires quire.tex provided by the midnight macro package.

You need a recent lilypond. Recent means very recent. The 
"-dgs-never-embed-fonts" must be present.

You need ghostscript. You'll need the current version.

cu,
 Knut
#!/bin/bash

xelatex --shell-escape hymex.tex
if [ $? -ne 0 ]; then echo "ABORT";exit;else echo "OK";fi

gs -dNOPAUSE -q -sDEVICE=pdfwrite -dBATCH -sOutputFile=hymexc.pdf *.font.ps 
hymex.pdf
if [ $? -ne 0 ]; then echo "ABORT";exit;else echo "OK";fi

rm -f tmplily* hymex.log hymex.aux
#!/bin/bash

SOURCE=$1.pdf
TARGET=$1-crop.pdf

HRBB=`gs -sDEVICE=bbox -dBATCH -dNOPAUSE -c save pop -f *.font.ps -f $SOURCE 
2>&1 | \
  grep "%%HiResBoundingBox:" | \
  sed -e "s/%%HiResBoundingBox: \([[:print:]]*\)/\1/"`

echo Cropping $SOURCE, result is $TARGET
gs  -o $TARGET -sDEVICE=pdfwrite -dEmbedAllFonts=false -dUseCropBox=true -c 
"[/CropBox [$HRBB] /PAGES pdfmark" -f *.font.ps -f $SOURCE 2>&1 > /dev/null
\NeedsTeXFormat{LaTeX2e}
%
% Übersetzen mit "lualatex --shell-escape wm15fom"
%
\documentclass[11pt]{letter}
%
% Der Einfachheit halber verwenden wir hier geometry zum
% Setzen der diversen Seitenparameter und im Anschluß das
% uralte quire.tex aus den Midnight Macros, um je zwei Seiten
% auf einen A4-Bogen zu kombinieren.
%
\usepackage{geometry}
\geometry{papersize={14.85cm,21cm},left=1.5cm,right=2.5cm,top=1.5cm,bottom=1.5cm,twoside,
 marginparsep=3mm,marginparwidth=1.9cm}
\input quire.tex
   \paperwidth=2\paperwidth  \shhtotal=\paperwidth   \htotal=0.5\paperwidth
   \vtotal=\paperheight  \horigin=1in\vorigin=1in
   \shvoffset=-1in   \shvcorrection=0pt  \shthickness=0pt
   \shhcorrection=0pt\shoutline=0pt  \shstaplewidth=0pt
   \shstaplelength=0pt   \shcrop=0pt \shfootline={}
   \def\supereject{\par\penalty-2}
   \latexquire   \quire{8}
\usepackage[english,german]{babel}
\selectlanguage{german}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\DeclareUTFcharacter[\UTFencname]{x201C}{\grqq}
\DeclareUTFcharacter[\UTFencname]{x201E}{\glqq}
\setmainfont{CMU Serif}
\setsansfont{CMU Sans Serif}
\setmonofont{CMU Typewriter Text}
\usepackage{graphicx}
\usepackage{shellesc}
\usepackage{soul}
\usepackage{calc}


\def\tmpNamePrefix{tmplily}
\def\tmpFragPrefix{\tmpNamePrefix frag}
\def\tmpNameFull{\tmpNamePrefix .ly}
\def\tmpNameHead{\tmpNamePrefix head.ly}
\def\tmpNamePaper{\tmpNamePrefix paper.ly}
\def\tmpNamePdf{\tmpNamePrefix .pdf }
\def\tmpNameTail{\tmpNamePrefix tail.ly}

\def\lilycommand{lilypond -b -dbackend=eps -dgs-never-embed-fonts=\#t -dfont-export-dir=./ }

\newwrite\tmpFileMain
\newwrite\tmpFileHead
\newwrite\tmpFileTail
\newwrite\tmpFilePaper

\newread\fragcountfile

\newcount\fragcount
\newcount\fragpagecount
\newcount\fragpagenum

{
  \catcode`|=0 \catcode`[=1 \catcode`]=2 \catcode`\#=12
  \catcode`\{=12 \catcode`\}=12 \catcode`\\=12
  |gdef|eohead[\end{lilyhead}]
  |gdef|eofrag[\end{lilyfrag}]
  |gdef|eotail[\end{lilytail}]
  |gdef|hashtag[#]
  |gdef|escape[\]
  |gdef|definepaper[\definepaper]
]

{
  \obeylines
  \gdef\doline#1
  {
\def\oneline{#1}
\ifx\oneline\eohead\def\next{\end{lilyhead}}\else
\ifx\oneline\eofrag\def\next{\end{lilyfrag}}\else
\ifx\oneline\eotail\def\next{\end{lilytail}}\else 
\ifx\oneline\definepaper\immediate\write\tmpFile{\escape include "\tmpNamePaper"}\let\next\doline
\else\immediate\write\tmpFile{\oneline}\let\next\doline
\fi\fi\fi\fi\next%
  }
}

\makeatletter

\newcommand{\zeit}[2]{#1%
 \sbox\z@ T%
 \vbox to\ht\z@{\hbox{\check@mathfonts
 \fontsize\ssf@size\z@
 \math@fontsfalse\selectfont
 \setul{.17em}{.03em}\,\ul{#2}\resetul}%
 \vss}~Uhr}
 
 
\newenvironment{lilyfrag}[2]{
  \global\advance\fragcount by 1
  \immediate\openout\tmpFileMain=\tmpNameFull
  \gdef\tmpFile{\tmpFileMain}
  \immediate\write\tmpFileMain{\escape include "\tmpNameHead"}
  \immediate\openout\tmpFilePaper=\tmpNamePaper
  

Re: Creating marginal comments?

2016-11-29 Thread Gerdau, Michael
> and LilyPond can’t even handle multiple columns on one page, so you’d 

I may have a wrong perception as to what you mean by "multiple columns".

For my own uses I regularly create scores (and texts) that span multiple columns
and are aligned like a table.

There actually are several ways to do that in lilypond AFAIC.

Maybe you could elaborate a bit more as to what you are missing?

Kind regards,
Michael
--
Michael Gerdau   email: m...@qata.de
GPG-keys available on request or at public keyserver

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Creating marginal comments?

2016-11-29 Thread Simon Albrecht

On 29.11.2016 13:02, tapani wrote:

I am producing a hymnal, using Lilypond and lilypond-book with xelatex. I
would like to insert biblical references in the margin of the page, parallel
with the lyrics.

For example, in "Hark, the Herald Angels Sing", the lyrics "Ris'n with
healing in his wings" would have "Mal. 4:2" in the margin.

In TeX like systems, this is easily done with the \marginnote command.

Is there a practical way of doing this within Lilypond: of inserting
something like \mark or \markup in the \lyricmode environment such that it
will place the comment automatically in the outer margin of the page?


It would not appear so. There is no actual command for this in LilyPond, 
and LilyPond can’t even handle multiple columns on one page, so you’d 
have to resort to very laborious \markup constructions encompassing 
entire pages. I don’t think this is worthwhile. Maybe you’d be better 
off modifying the resulting pdf with another program (perhaps Scribus, 
or Adobe InDesign)?


Best, Simon

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Creating marginal comments?

2016-11-29 Thread tapani
I am producing a hymnal, using Lilypond and lilypond-book with xelatex. I
would like to insert biblical references in the margin of the page, parallel
with the lyrics.

For example, in "Hark, the Herald Angels Sing", the lyrics "Ris'n with
healing in his wings" would have "Mal. 4:2" in the margin.

In TeX like systems, this is easily done with the \marginnote command.

Is there a practical way of doing this within Lilypond: of inserting
something like \mark or \markup in the \lyricmode environment such that it
will place the comment automatically in the outer margin of the page?

Many thanks.
Tapani

[There is a laborious hack to do this in XeLaTeX, but that involves finding
the right .tex file produced for that line of music by lilypond-book, and
then inserting \marginnote into that file. Not a good method.]



--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Creating-marginal-comments-tp197250.html
Sent from the User mailing list archive at Nabble.com.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user