In my use of Lilypond, I often face the same kind of problems: Say I have four scores (3-4 lines each) that fit in two pages but not necessarily in one.
I refuse to have page breaks within scores. If possible, I want all the scores on the same page. When it's not possible however, I would like the page break to occur between the first and second scores. If that is not possible either, between the second and the third. And only if that's really necessary between the third and the fourth. That is, by order of preference, | representing the page break:
1 2 3 4 |
1 | 2 3 4
1 2 | 3 4
1 2 3 | 4
Is there a way to achieve that without trying and adding the page breaks myself? Maybe by having page-break penalties going in increasing order after each score (but remaining smaller than the penalty for adding a new page)?
Thank you by advance for your help.
You should use ly:page-turn-breaking (see Optimal page turning in the documentation). You'll probably have to play also with \pageTurn, \noPageTurn, \allowPageTurn in order to have the best control.
Here's a minimal example:
\version "2.19.82"
\header {
title = "Page turn breaking"
}
\paper {
% The default page breaking will make Score 1 end at beginning of page 2.
% The following option prevents this and keeps Score 1 all in the first page.
page-breaking = #ly:page-turn-breaking
}
\score {
\header { piece = "Score 1" }
\new Staff {
\clef "treble_8"
\repeat unfold 14 { c'1*4 }
}
\layout {
indent = 0
system-count = 14
}
}
\score {
\header { piece = "Score 2" }
\new Staff {
\clef "treble_8"
\repeat unfold 13 { e'2 f }
}
\layout {
indent = 0
system-count = 13
}
}
Related
Resources like complete-guide-to-grid on css-tricks or grid by example are wonderful, yet I cannot figure out how to build a two-axis table layout.
The data for this layout is a simple weekly schedule, where each day has a 0-n categories and each category has 0-n dishes. The data looks something like this (pseudo-code):
DAY: { CATEGORY: [DISH] }
e.g.
monday: { a: [1, 2], b: [6], d: [5] },
tuesday: { b: [25], e: [0] },
...
friday: { a: [10], b: [9] },
The layout should look like this (note the empty top-left corner):
. MO TU WE TH FR
A a1 a10
a2
B b6 b25 b9
D d5
Now, having spent years nesting divs to build layouts, I attempted to design this "layout-in", as is the mantra of css-grid, structuring the html in a way that is decoupled from the target-layout. See this codepen for an example structure.
My first attempt was using grid-areas, like this:
.grid {
grid-template-areas:
". 1 2 3 4 5"
"a a1 a2 a3 a4 a5"
"b b1 b2 b3 b4 b5";
// ...
}
This "works", but now I have to create a class for every single cell in the table, which is silly.
Then I tried to create areas for each axis and one for the center cells:
.grid {
grid-template-areas:
". n n n n n"
"s x x x x x";
}
This does not work. Assigning x to each cell just stacks them on top of each other in the first x column/row, same thing with n up top. Also, the pattern does not repeat, so we end up with only two rows.
Then I thought about nesting grids, adding another grid under n and x. But this defeats the "layout-in" promise, so I decided against it.
I believe I either fundamentally misunderstand areas, or what I am trying to do is not possible without nesting grids. Any input, or an example two-axis layout using css-grid would be greatly appreciated!
Since you're working with tabular data a <table> element might be more appropriate than trying to use css grid.
This may sound like an easy question but I'm a little stumped.
I've tried using Modulus and MultipleOf
https://docs.silverstripe.org/en/3/developer_guides/templates/syntax/
but this is giving me a list which goes horizontal. I want two columns The first column containing the first half of my listed data objects and the second column the second half.
Using CSS doesn't work as it splits the content and ignores the li containers so some of my list items (which are multiple lines each) get divided.
https://www.w3schools.com/Css/css3_multiple_columns.asp
Really I want to just be able to find the middle data object and divide it using html / css. Any suggestions welcome.
Here's an example of my list its shows 4 items, column 1 would contain item 1 & 2 and column 2, 3 & 4 (the actual list could be any length):
1 MAY 11 - 7.30PM - POWERSTOCK
THE HUT, DT6 3TB
BOX OFFICE: 01935 873555 / WEBSITE
TICKETS: £10.00/£8.00
2 OCT 13 - THE PLACE
BEDFORD
BOX OFFICE: 01234 354321 / WEBSITE
3 OCT 14 - PREVIEW: THE PLACE
BEDFORD
BOX OFFICE: 01234 354321 / WEBSITE
4 OCT 18 - CHILWELL ARTS CENTRE
BEESTON
You need a custom iterator property. You have $First, $Last, and $Middle made available to you through the core, but $Middle doesn't do what most people expect. Rather than return true on the median iteration, it's just anything between the first and last one, which isn't often helpful.
class MyIteratorProperties implements TemplateIteratorProvider
{
protected $totalItems;
protected $pos;
public static function get_template_iterator_variables()
{
return ['Median'];
}
public function iteratorProperties($pos, $totalItems)
{
$this->pos = $pos;
$this->totalItems = $totalItems;
}
public function Median()
{
return $this->pos == floor($this->totalItems/2);
}
}
And your template:
<% $loop $SomeItems %>
<% if $Median %></div><div ...><% end_if %>
<% end_loop %>
I am working with Lilypond and can't figure out how to place two dynamic markings under a whole note. I want it to start piano and then become forte but I don't want to use a crescendo. I'd also rather not indicate two tied half notes. Just p then f under a whole note. This is common in older notation which I am typesetting. Thank you.
You can add one single markup that contains multiple elements to a single note:
\version "2.18.2"
{
f'1 _\markup { \dynamic { f p } }
}
There's an example in the Notation Reference, where it says: "Spacer rests are needed to engrave multiple marks on one note."
If you adapt it to your case, you might write:
\version "2.18.2"
{
R1 |
<< f'1\p { s1\f } >> |
}
However, this triggers the following warning:
warning: Two simultaneous absolute-dynamic events, junking this one
and only the first dynamic mark is printed.
So you must place the second dynamic mark on a different musical moment:
\version "2.18.2"
{
R1 |
<< f'1\p { s4. s16\f s s2 } >> |
}
Is there a way in LilyPond to simply list the lyrics corresponding to
additional verses after the end of the music, with one paragraph per verse?
(N.B. This exact question has been asked before, in 2001, but the first answer ("read this book") references a dead URL, while the second (use \context Lyrics) does not work for me, I get LilyPond syntax errors.)
Here's a song under which I want to write the additional verses.
\header{
title = "Hello World"
}
\score {
\relative {
\time 2/4
\clef treble
\key a \major
cis''2 | a4 fis \bar "|."
}
\addlyrics {
He -- | llo world
}
\layout { }
\midi { }
}
\version "2.18.2"
(Sorry about the syntax highlighting, <!-- language: lang-lilypond --> is not yet supported in the Google Code Prettyfier that SO uses.)
I'd like to add verses 2, 3, and 4 underneath, separated from the music, just as words.
I got an answer from Knute Snortum on the LiliyPond mailing list here
After my score block I can add a markup block like this
\markup {
\column {
\line { \null }
\line { 2. Here I go }
}
}
It turns out that this is covered in the LilyPond documentation (printing stanzas at the end) but they use the term 'stanza' and so my searching for 'verse' did not lead me there.
(It is also worth noting this discussion on meta. Posting LilyPond questions here is likely to lead to down-votes since it is not considered programming by many of the SO community. A better Stack Exchange site to post LilyPond questions to is the Music: Practice and Theory Stack Exchange, though, as I found, the LilyPond mailing list is currently the place most likely to elicit full and prompt answers.)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I'm parsing some contact data from a PDF-file converted to csv which has resulted in a different column count per row based on missing entries.
Is there a way to correct this using sed, awk, cut etc by making sure some columns that are easy to pattern match up - fx making sure the email-addresses are in the same columns when available and others like "Lifetime member" or "Guest" when email is not available?
The first column is a person/company's name but the rest is arbitrary. The point is to extract contact information(like email, phone number etc) and put it in the same columns, when available.
My idea would be to check if the email is in the 6th column and if not then add a number of empty columns before it etc
Example data:
Steve Smith;9828;1;+1234 567 2345;Guest;steve#example.org;1;1 12th st;48572 Nowhere
Steve Jobs;+1234 567 2345;noreply#example.org;1;48572 Nowhere
John Smith;9828;1;+1234 567 2345;Lifetime member;1;1 23rd st;48572 Nowhere
Peter Blavounius;2312;peter#blavounius.com
Wanted output:
Steve Smith;9828;1;+1234 567 2345;Guest;steve#example.org;1;1 12th st;48572 Nowhere
Steve Jobs;+1234 567 2345;;;;noreply#example.org;1;;48572 Nowhere
John Smith;9828;1;+1234 567 2345;Lifetime member;1;1 23rd st;48572 Nowhere
Peter Blavounius;2312;;;;peter#blavounius.com
This will get you started but it is not complete, you still need to identify other fields, all I've done so far is identify a couple of the fields to show you the approach:
$ cat tst.awk
BEGIN {
FS=OFS=";"
ARGV[ARGC] = ARGV[ARGC-1]
ARGC++
}
{
name = tel = email = digs4 = ""
for (i=1;i<=NF;i++) {
if (i == 1) {
name=$i; $i=""; nameFld = 1
}
else if ($i ~ /^\+/) {
tel=$i; $i=""; telFld = (i > telFld ? i : telFld)
}
else if ($i ~ /#/) {
email=$i; $i=""; emailFld = (i > emailFld ? i : emailFld)
}
else if ($i ~ /^[0-9]{4}$/) {
digs4=$i; $i=""; digs4Fld = (i > digs4Fld ? i : digs4Fld)
}
}
maxFlds = (NF > maxFlds ? NF : maxFlds)
}
NR>FNR {
for (i=1;i<=maxFlds;i++) {
if (i == nameFld) { $i = name }
else if (i == telFld) { $i = tel }
else if (i == emailFld) { $i = email }
else if (i == digs4Fld) { $i = digs4 }
else { $i = $i } # make sure null fields are present
}
print
}
.
$ awk -f tst.awk file
Steve Smith;9828;1;+1234 567 2345;Guest;steve#example.org;1;1 12th st;48572 Nowhere
Steve Jobs;;;+1234 567 2345;48572 Nowhere;noreply#example.org;;;
John Smith;9828;1;+1234 567 2345;Lifetime member;;1 23rd st;48572 Nowhere;
Peter Blavounius;2312;;;;peter#blavounius.com;;;
It does 2 passes on your input file - the first to identify that largest field number that matches each regexp as that's where you want every field matching that regexp to appear in the output, and the second to identify the fields, clear out their location in the record, and then place every field in the right location.
You could identify what a field means by matching it's context to a regexp like above or by its fixed position in the line (e.g. the persons name is always in field 1) or by it's relative position to something else (e.g. a single digit occurring before vs after the email address or before/after the 3rd field number or....)
Hope it makes sense. Add some printfs and play with it a bit and ask questions if you're confused after that.