\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-20000} \latexquire \quire{4} % 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 code put inside of a lilyhead % environment will be written to the \tmpNameHead file. % % The lilytail environment has no arguments. Lilypond code put inside of a lilytail % environment will be written to the \tmpNameTail file. % % The lilyfrag environment has two arguments, the page width and the page height % to be used by lilypond. Both argument must be given, both must be a number followed % by a space followed by a unit: % % valid example : \begin{lilyfrag}{9.85 cm}{21 cm} % % invalid examples: \begin{lilyfrag}{9.85 cm}{21cm} % \begin{lilyfrag}{9.85cm}{21 cm} % \begin{lilyfrag}{}{} % % You are free to put anything you like into the lilyhead, lilyfrag and lilytail environments, % of course it must be valid lilypond code. lilyhead and lilytail might be used to define % an empty file, but they both must be used once prior to any use of lilyfrag. % % You might use \definepaper inside of the lilypond code: The paper definition constructet % from the lilyfrag arguments will be included at that place. If it is used, % \definepaper must be put without anything else on a single line, even a single space will break the code. % The same is true for \end{lilyhead} \end{lilfrag} and \end{lilytail}: These commands must % be put without anything else on a single line, even a single space will break the code. % % Whenever a lilyfrag environment is processed, it % - writes a lilypond paper-alist definition constructed from the two arguments % to the file given by the definition of \tmpNamePaper above. % - writes a command to include the \tmpNameHead file to the \tmpNameMain file % - writes the contents of the lilyfrag environment to the \tmpNameMain file % - writes a command to include the \tmpNameTail file to the \tmpNameMain file % - executes \lilycommand \tmpNameMain % - moves the pdfs created by lilypond to \tmpFragPrefix\the\fragcount-\the\fragpagenum.pdf files % - exectutes the mypdpfcrop script to crop these files % - and includes these file (\tmpFragPrefix\the\fragcount-\the\fragpagenum-crop.pdf) using % includegraphics. % \makeatletter \newenvironment{lilyfrag}[2]{ \global\advance\fragcount by 1 \immediate\openout\tmpFileMain=\tmpNameMain \gdef\tmpFile{\tmpFileMain} \immediate\write\tmpFileMain{\escape include "\tmpNameHead"} \immediate\openout\tmpFilePaper=\tmpNamePaper \immediate\write\tmpFilePaper{\hashtag(set! paper-alist (cons '("mySize" . (cons (* #1) (* #2))) paper-alist))} \immediate\closeout\tmpFilePaper address@hidden }{ \immediate\write\tmpFileMain{\escape include "\tmpNameTail"} \immediate\closeout\tmpFileMain \immediate\write18{\lilycommand \tmpNameMain} \openin\fragcountfile=\tmpNameFragCount \read\fragcountfile to \fragpagecount \closein\fragcountfile \fragpagenum=1 \begin{center} \loop \immediate\write18{mv \tmpNamePrefix-\the\fragpagenum.pdf \tmpFragPrefix\the\fragcount-\the\fragpagenum.pdf} \immediate\write18{./mypdfcrop \tmpFragPrefix\the\fragcount-\the\fragpagenum} \leavevmode\raise-30pt\vtop{\includegraphics[width=\textwidth,keepaspectratio=true] {\tmpFragPrefix\the\fragcount-\the\fragpagenum-crop.pdf}}\callback \advance\fragpagenum by 1 \unless\ifnum\fragpagenum>\fragpagecount \repeat \end{center} } \newenvironment{lilyhead}{ \immediate\openout\tmpFileHead=\tmpNameHead \gdef\tmpFile{\tmpFileHead} address@hidden }{ \immediate\closeout\tmpFileHead } \newenvironment{lilytail}{ \immediate\openout\tmpFileTail=\tmpNameTail \gdef\tmpFile{\tmpFileTail} address@hidden }{ \immediate\closeout\tmpFileTail } \makeatother % An example lilyhead definition \begin{lilyhead} \version "2.19.52" \include "deutsch.ly" \pointAndClickOff % \definepaper is special. It includes the paper alist definition for a "mySize" paper % constructed by the lilyfrag enviroment. It must be put on a line without anything else! \definepaper \paper { #(set-paper-size "mySize") left-margin = 0\cm top-margin = 0\cm bottom-margin = 0\cm line-width = \paper-width indent = 0 systems-per-page = #1 ragged-right = ##f ragged-bottom = ##t ragged-last-bottom = ##t annotate-spacing = ##f print-page-number = ##f } \layout{ \context { \Lyrics { \override VerticalAxisGroup.nonstaff-relatedstaff-spacing = #'((basic-distance . 0)) \override VerticalAxisGroup.nonstaff-relatedstaff-spacing = #'((padding . 1.25)) } } } \header { tagline = ##f } #(set-global-staff-size 16) % % These definitions are used for absolute font size definitions in the % lilytail environment ... % allowGrobCallback = #(define-scheme-function (parser location syms) (symbol-list?) (let ((interface (car syms)) (sym (cadr syms))) #{ \with { \consists #(lambda (context) `((acknowledgers . ((,interface . ,(lambda (engraver grob source-engraver) (let ((prop (ly:grob-property grob sym))) (if (procedure? prop) (ly:grob-set-property! grob sym (prop grob))))))))))}#})) absFontSize = #(define-scheme-function (parser location pt)(number?) (lambda (grob) (let* ((layout (ly:grob-layout grob)) (ref-size (ly:output-def-lookup (ly:grob-layout grob) 'text-font-size 12))) (magnification->font-size (/ pt ref-size))))) \score { << \end{lilyhead} % An example lilytail definition \begin{lilytail} >> \layout { \context { \Score \allowGrobCallback font-interface.font-size \omit BarNumber } \override Lyrics.LyricText #'font-name = #"CMU Serif" \override LyricText.font-size = \absFontSize #10 \override StanzaNumber.font-name = #"CMU Serif" \override StanzaNumber.font-size = \absFontSize #10 } } \end{lilytail} \newcount\cmarg\cmarg=1 \def\testmarg{\marginpar{\scriptsize\emph{Marginal note number \the\cmarg}}\global\advance\cmarg1} \newcount\cnum\cnum=1 \def\hymn#1{{\vskip 20pt plus 10pt minus 5pt\bfseries \ifodd\count0\Large #1\hfill\huge\the\cnum \else\huge\the\cnum\hfill\Large#1\fi}\advance\cnum1\nopagebreak\par\nopagebreak} \linespread{1.0} \begin{document} \selectlanguage{german} \pagestyle{plain} \sloppy \linespread{1.05} \parskip=12pt plus 10pt minus 5 pt \thispagestyle{empty} \begin{center} {\bfseries\Huge Hymnals\vfill \Large (Example booklet)} \end{center} \newpage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def\callback{\ifnum\fragpagenum=1\marginpar{\scriptsize\emph{Marginal note number \the\cmarg\ at system \the\fragpagenum}}\global\advance\cmarg1\fi \ifnum\fragpagenum=3\marginpar{\scriptsize\emph{Marginal note number \the\cmarg\ at system \the\fragpagenum}}\global\advance\cmarg1\fi} \hymn{O Heiland, reiß die Himmel auf} \begin{lilyfrag}{9.85 cm}{21 cm} \new Voice = "Melody" \relative d'{ \key c \major \time 3/4 \partial 4 d4 f2 g4 a2 d,4 f e2 d2. \breathe a'4 4 h \break c2 f,4 a g2 f2. \breathe c'4 4 4 2 a4 \break d2 4 c2. \breathe a4 4 g a2 f4 g e2 d \bar"|." } \new Lyrics \lyricsto "Melody" { \set stanza = "1." O Hei -- land, reiß die Him -- mel auf, her -- ab, her -- ab vom Him -- mel lauf, reiß ab vom Him -- mel Tor und Tür, reiß ab, wo Schloß und Rie -- gel für. } \end{lilyfrag} 2. O Erd, schlag aus, schlag aus, o Erd,~/~% daß Berg und Tal grün alles werd.~/~% O Erd, herfür dies Blümlein bring,~/~% o Heiland, aus der Erden spring. 4. Wo bleibst Du, Trost der ganzen Welt,~/~% darauf sie all ihr Hoffnung\testmarg\ stellt?~/~% O komm, ach komm vom höchsten Saal,~/~% komm, tröst uns hier im Jammertal. 6. Hier leiden wir die größte Not,~/~% vor Augen steht der ewig Tod.~/~% Ach komm, führ uns mit starker Hand~/~% vom Elend zu dem Vaterland.\testmarg 7. Da wollen wir\testmarg\ all danken dir,~/~% unserm Erlöser, für und für;~/~% da wollen wir all loben dich~/~% zu aller Zeit und ewiglich. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def\callback{\ifnum\fragpagenum=2\marginpar{\scriptsize\emph{Marginal note number \the\cmarg\ at system \the\fragpagenum}}\global\advance\cmarg1\fi \ifnum\fragpagenum=4\marginpar{\scriptsize\emph{Marginal note number \the\cmarg\ at system \the\fragpagenum}}\global\advance\cmarg1\fi} \hymn{Tochter Zion} \begin{lilyfrag}{9.85 cm}{21 cm} \new Voice = "Melody" \transpose c b { \relative c' { \key f \major c2 a4.( b8) | c2 f,2 | g8( a b c b4) a | g1 | \breathe \break a8( b c d c4) c | f2 c | b4( a g4.) f8 | f1 | \breathe \break a8( g a b a4) a | g2 f | b4( a g) f | e1 | \breathe \break f8( e f g f4) f | d'2 h2 | c4( d8 c h4.) c8 | c1 | \breathe \break c2 a4.( b8) | c2 f, | g8( a b c b4) a | g1 | \breathe \break c8( b c d c4) c | f2 c | b4( a g4.) f8 f1 \bar"|." } } \new Lyrics \lyricsto "Melody" { \set stanza = "1." Toch -- ter __ Zi -- on, freu -- e dich! Jauch -- ze laut, Je -- ru -- sa -- lem! Sieh, __ dein Kö -- nig kommt __ zu dir, ja, __ er kommt, der Frie -- de -- fürst! Toch -- ter __ Zi -- on, freu -- e dich! Jauch -- ze laut, Je -- ru -- sa -- lem! } \end{lilyfrag} 2. Hosianna,\testmarg Davids Sohn,~/~% sei gesegnet deinem Volk!~/~% Gründe nun dein ew'ges Reich,~/~% Hosianna in der Höh'!~/~% Hosianna, Davids Sohn,~/~% sei gesegnet deinem Volk! 3. Hosianna, Davids Sohn,~/~% sei gegrüßet, König mild!~/~% Ewig steht dein Friedensthron,\testmarg~/~% du, des ew'gen Vaters Kind.~/~% Hosianna, Davids Sohn,~/~% sei gegrüßet, König mild! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def\callback{} \hymn{Macht hoch die Tür} \begin{lilyfrag}{9.85 cm}{21 cm} \new Voice = "Melody" \relative g'{ \key es \major \time 6/4 \partial 4 g4 b2 as4 g2 f4 es (f) g f2 \breathe \bar"" \break b4 as2 as4 g2 g4 f (es) f es2 \breathe \bar"" \break g4 f2 f4 g (a) b b (c) a b2 \breathe \bar"" \break f4 g2 f4 g (a) b b (c) a b2 \breathe \bar"" \break b4 c2 b4 c2 b4 c (b) as g2 \breathe \bar"" \break b4 c2 b4 c2 b4 c (b) as g2 \breathe \bar"" \break b4 es,2 es4 as2 g4 f2. ~ f2 \breathe \bar"" \break b4 as2 g4 f (es) f es2. ~ es2 \bar"|." } \new Lyrics \lyricsto "Melody" { \set stanza = "1." Macht hoch die Tür, die Tor macht weit; es kommt der Herr der Herr -- lich -- keit, ein Kö -- nig al -- ler Kö -- nig -- reich, ein Hei -- land al -- ler Welt zu -- gleich, der Heil und Le -- ben mit sich bringt; der -- hal -- ben jauchzt, mit Freu -- den singt: Ge -- lo -- bet sei mein Gott, __ mein Schöp -- fer reich von Rat. __ } \end{lilyfrag} 3. O wohl dem Land, o wohl der Stadt,~/~% so diesen König bei sich hat.~/~% Wohl allen Herzen insgemein,~/~% da dieser König ziehet ein.~/~% Er ist die rechte Freudensonn,~/~% bringt mit sich lauter Freud und Wonn.~/~% Gelobet sei mein Gott,~/~% mein Tröster früh und spat. 5. Komm, o mein Heiland\testmarg\ Jesu Christ,~/~% meins Herzens Tür dir offen ist.~/~% Ach zieh mit deiner Gnade ein;~/~% dein Freundlichkeit auch uns erschein.~/~% Dein Heil'ger Geist uns führ und leit~/~% den Weg zur ewgen Seligkeit.~/~% Dem Namen dein, o Herr,~/~% sei ewig Preis und Ehr. \end{document}