Attached are two patch files for the abc2ps.c and buffer.c files in version
2.11.3 of abcm2ps. I am typesetting some choral music and needed more
flexible page number positioning. The patches expand the command line page
numbering argument.
I have defined five different page numbering modes:
0 page numbers off
1 page numbers always at top left
2 page numbers always at top right
3 page numbers at top left on even pages, top right on odd pages
4 page numbers at top right on even pages, top left on odd pages
then I expanded the '-N' command line option to set the mode with a
numerical argument. For instance,
abcm2ps -N 3 ooga.abc -O ooga.ps
I sent this patch to Jean-Fran�ois about two weeks ago and haven't heard
anything whether he might consider it for a future version, so I thought
I'd just post it here for anyone who might need such page numbering in the
short term. Actually I had originally patched version 3.0.17, but found
that the later version lacked some useful decorations, like !mp!, and so
went back to using 2.11.3.
John
--- buffer.org Wed May 01 01:31:00 2002
+++ buffer.c Wed Jul 17 00:46:16 2002
@@ -165,27 +165,17 @@
cfmt.leftmargin, pheight - cfmt.topmargin);
}
swidth = pwidth - cfmt.leftmargin - cfmt.rightmargin;
/* write page number */
- if (pagenumbers) {
+ if (pagenumbers > 0) {
fprintf(fp, "/Times-Roman 12 selectfont ");
-#if 1
- /* page numbers always at right */
- fprintf(fp, "%.1f %.1f M (%d) lshow\n",
- pwidth - cfmt.leftmargin - cfmt.rightmargin,
- cfmt.topmargin - 30.0, pagenum);
-
-#else
- /* page number right/left for odd/even pages */
- if (pagenum % 2 == 0)
- fprintf(fp, "%.1f %.1f M (%d) show\n",
+ if (((pagenumbers - 1) & 1) ^ (pagenum & ((pagenumbers - 1) >> 1)))
+ fprintf(fp, "%.1f %.1f M (%d) lshow\n",
+ swidth,cfmt.topmargin - 30.0, pagenum);
+ else fprintf(fp, "%.1f %.1f M (%d) show\n",
0.0, cfmt.topmargin - 30.0, pagenum);
- else fprintf(fp, "%.1f %.1f M (%d) lshow\n",
- swidth,
- cfmt.topmargin - 30.0, pagenum);
-#endif
}
/* ouput the footer */
if (cfmt.footer != 0) {
char str[128];
--- abc2ps.org Wed Jan 02 01:37:00 2002
+++ abc2ps.c Wed Jul 17 00:54:58 2002
@@ -159,10 +159,11 @@
0); /* don't keep comments */
/* parse the arguments - as soon as a file ends, it is treated */
help_me = 0;
in_fname = 0;
+ pagenumbers = 0;
while (--argc > 0) {
argv++;
p = *argv;
if (*p == '+') { /* switch off flags with '+' */
while (*++p != '\0') {
@@ -174,11 +175,10 @@
case 'G': graceslurs = 1; break;
case 'j':
case 'k': measurenb = -1; break;
case 'l': landscape = 0; break;
case 'M': music_only = 0; break;
- case 'N': pagenumbers = 0; break;
case 'n': write_history = 0; break;
case 'O':
choose_outname = 0;
strcpy(outf, OUTPUTFILE);
break;
@@ -212,11 +212,10 @@
case 'G': graceslurs = 0; break;
case 'H': help_me = 1; break;
case 'h': usage(); break;
case 'l': landscape = 1; break;
case 'M': music_only = 1; break;
- case 'N': pagenumbers = 1; break;
case 'n': write_history = 1; break;
/* case 'b': */
case 'C':
case 'g':
case 'R':
@@ -264,10 +263,11 @@
case 'I':
case 'j':
case 'k':
case 'L':
case 'm':
+ case 'N':
case 'O':
case 's':
case 'v':
case 'w':
aaa = p + 1;
@@ -282,11 +282,11 @@
} else {
while (p[1] != '\0') /* stop */
p++;
}
- if (strchr("BbfjkLsv", c)) { /* check
num args */
+ if (strchr("BbfjkLNsv", c)) { /* check
+num args */
for (j = 0; j < strlen(aaa); j++)
if (!strchr("0123456789.",
aaa[j])) {
if (aaa[j] == 'b'
&& aaa[j+1] == '\0'
@@ -343,10 +343,18 @@
}
break;
case 'm':
lmargin = scan_u(aaa);
break;
+ case 'N':
+ sscanf(aaa, "%d", &pagenumbers);
+ if (pagenumbers < 0 || pagenumbers >
+4) {
+ printf("++++ Bad pagenumbers
+value %s - changed to 0\n",
+ aaa);
+ pagenumbers = 0;
+ }
+ break;
case 'O':
if (!strcmp(aaa, "=")) {
choose_outname = 1;
} else {
getext(aaa, ext);
@@ -712,11 +720,12 @@
" -l landscape mode\n"
" -I xx indent 1st line (cm/in/pt)\n"
" -x include xref numbers in output\n"
" -M don't ouput the lyrics\n"
" -n include notes and history in output\n"
- " -N write page numbers\n"
+ " -N n set page number mode to n\n"
+ " 0=off 1=left 2=right 3=even left,odd right 4=even
+right,odd left\n"
" -1 write one tune per page\n"
" -G no slur in grace notes\n"
" -j n[b] number the measures every n bars (or on the left if
n=0)\n"
" if 'b', display in a box\n"
" -k n[b] same as '-j' (abc2ps compatibility)\n"