Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm typesetting a long poem using memoir and the verse environment. I would like to provide running heads showing the numbers of the first and last lines appearing on that page (like "lines 36--81").

I've looked at lineno and the other poetry-related packages (I'm not committed to memoir), but none of them seems to have hooks for this. I've started taking apart the memoir internals to create my own marks, but I'm in over my head.

Thanks for any leads!

mwe:

\documentclass[]{memoir}

\makepagestyle{myps}
\makeevenfoot{myps}{\thepage}{}{}
\makeoddfoot{myps}{}{}{\thepage}
\makepsmarks{myps}{%
% use this machinery?
% \createmark{chapter}{both}{nonumber}{}{. \ }
}

\makeevenhead{myps}{}{\leftmark}{\thepoemline}  % fixme
\makeoddhead{myps}{\thepoemline}{\rightmark}{}  % fixme


\begin{document}

\aliaspagestyle{chapter}{myps}
\pagestyle{myps}

\chapter*{Foo\markboth{want [first]--[last] line numbers on this page here $\rightarrow$}{$\leftarrow$want [first]--[last] line numbers on this page here}}

\verselinenumbersleft
\linenumberfrequency{5}

\begin{verse}
Of Mans First Disobedience, and the Fruit\\
Of that Forbidden Tree, whose mortal tast\\
Brought Death into the World, and all our woe,\\
With loss of Eden, till one greater Man\\
Restore us, and regain the blissful Seat,\\
Sing Heav'nly Muse, that on the secret top\\
Of Oreb, or of Sinai, didst inspire\\
That Shepherd, who first taught the chosen Seed,\\
In the Beginning how the Heav'ns and Earth\\
Rose out of Chaos: Or if Sion Hill\\
Delight thee more, and Siloa's Brook that flow'd\\
Fast by the Oracle of God; I thence\\
Invoke thy aid to my adventrous Song,\\
That with no middle flight intends to soar\\
Above th' Aonian Mount, while it pursues\\
Things unattempted yet in Prose or Rhime.\\
And chiefly Thou O Spirit, that dost prefer\\
Before all Temples th' upright heart and pure,\\
Instruct me, for Thou know'st; Thou from the first\\
Wast present, and with mighty wings outspread\\
Dove-like satst brooding on the vast Abyss\\
And mad'st it pregnant: What in me is dark\\
Illumin, what is low raise and support;\\
That to the highth of this great Argument\\
I may assert Eternal Providence,\\
And justifie the wayes of God to men.\\

\vin Say first, for Heav'n hides nothing from thy view\\
Nor the deep Tract of Hell, say first what cause\\
Mov'd our Grand Parents in that happy State,\\
Favour'd of Heav'n so highly, to fall off\\
From thir Creator, and transgress his Will\\
For one restraint, Lords of the World besides?\\
Who first seduc'd them to that foul revolt?\\
Th' infernal Serpent; he it was, whose guile\\
Stird up with Envy and Revenge, deceiv'd\\
The Mother of Mankind, what time his Pride\\
Had cast him out from Heav'n, with all his Host\\
Of Rebel Angels, by whose aid aspiring\\
To set himself in Glory above his Peers,\\
He trusted to have equal'd the most High,\\
If he oppos'd; and with ambitious aim\\
Against the Throne and Monarchy of God\\
Rais'd impious War in Heav'n and Battel proud\\
With vain attempt. Him the Almighty Power\\
Hurld headlong flaming from th' Ethereal Skie\\
With hideous ruine and combustion down\\
To bottomless perdition, there to dwell\\
In Adamantine Chains and penal Fire,\\
Who durst defie th' Omnipotent to Arms.\\
Nine times the Space that measures Day and Night\\
To mortal men, he with his horrid crew\\
Lay vanquisht, rowling in the fiery Gulfe\\
Confounded though immortal: But his doom\\
Reserv'd him to more wrath; for now the thought\\
Both of lost happiness and lasting pain\\
Torments him; round he throws his baleful eyes\\
That witness'd huge affliction and dismay\\
Mixt with obdurate pride and stedfast hate:\\
At once as far as Angels kenn he views\\
The dismal Situation waste and wilde,\\
A Dungeon horrible, on all sides round\\
As one great Furnace flam'd, yet from those flames\\
No light, but rather darkness visible\\
Serv'd onely to discover sights of woe,\\
Regions of sorrow, doleful shades, where peace\\
And rest can never dwell, hope never comes\\
That comes to all; but torture without end\\
Still urges, and a fiery Deluge, fed\\
With ever-burning Sulphur unconsum'd:\\
Such place Eternal Justice had prepar'd\\
For those rebellious, here thir Prison ordain'd\\
In utter darkness, and thir portion set\\
As far remov'd from God and light of Heav'n\\
As from the Center thrice to th' utmost Pole.\\
O how unlike the place from whence they fell!\\
There the companions of his fall, o'rewhelm'd\\
With Floods and Whirlwinds of tempestuous fire,\\
He soon discerns, and weltring by his side\\
One next himself in power, and next in crime,\\
Long after known in Palestine, and nam'd\\
Beelzebub. To whom th' Arch-Enemy,\\
And thence in Heav'n call'd Satan, with bold words\\
Breaking the horrid silence thus began.\\

\vin If thou beest he; But O how fall'n! how chang'd\\
From him, who in the happy Realms of Light\\
Cloth'd with transcendent brightness didst out-shine\\
Myriads though bright: If he Whom mutual league,\\
United thoughts and counsels, equal hope\\
And hazard in the Glorious Enterprize,\\
Joynd with me once, now misery hath joynd\\
In equal ruin: into what Pit thou seest\\
From what highth fall'n, so much the stronger prov'd\\
He with his Thunder: and till then who knew\\
The force of those dire Arms? yet not for those,\\
Nor what the Potent Victor in his rage\\
Can else inflict, do I repent or change,\\
Though chang'd in outward lustre; that fixt mind\\
And high disdain, from sence of injur'd merit,\\
That with the mightiest rais'd me to contend,\\
And to the fierce contention brought along\\
\end{verse}
\end{document}
share|improve this question
1  
Welcome to TeX.SE! –  Vivi Dec 19 '12 at 21:15

1 Answer 1

up vote 5 down vote accepted

I used etex marks here (first time for everything:-)

enter image description here

\documentclass[]{memoir}

\makepagestyle{myps}
\makeevenfoot{myps}{\thepage}{}{}
\makeoddfoot{myps}{}{}{\thepage}
\makepsmarks{myps}{%
% use this machinery?
% \createmark{chapter}{both}{nonumber}{}{. \ }
}

\makeevenhead{myps}{}{\leftmark}{[[[\firstmarks1--\botmarks1]]]}  % fixme
\makeoddhead{myps}{[[[\firstmarks1--\botmarks1]]]}{\rightmark} % fixme

\makeatletter

\renewcommand{\incr@vsline}{%
  \marks1{\the\numexpr\c@poemline}%
  \refstepcounter{poemline}%
  \stepcounter{vslineno}}

\makeatletter
\begin{document}

\aliaspagestyle{chapter}{myps}
\pagestyle{myps}

%\chapter*{Foo\markboth{want [first]--[last] line numbers on this page here $\rightarrow$}{$\leftarrow$want [first]--[last] line numbers on this page here}}

\verselinenumbersleft
\linenumberfrequency{5}

\begin{verse}
Of Mans First Disobedience, and the Fruit\\
Of that Forbidden Tree, whose mortal tast\\
Brought Death into the World, and all our woe,\\
With loss of Eden, till one greater Man\\
Restore us, and regain the blissful Seat,\\
Sing Heav'nly Muse, that on the secret top\\
Of Oreb, or of Sinai, didst inspire\\
That Shepherd, who first taught the chosen Seed,\\
In the Beginning how the Heav'ns and Earth\\
Rose out of Chaos: Or if Sion Hill\\
Delight thee more, and Siloa's Brook that flow'd\\
Fast by the Oracle of God; I thence\\
Invoke thy aid to my adventrous Song,\\
That with no middle flight intends to soar\\
Above th' Aonian Mount, while it pursues\\
Things unattempted yet in Prose or Rhime.\\
And chiefly Thou O Spirit, that dost prefer\\
Before all Temples th' upright heart and pure,\\
Instruct me, for Thou know'st; Thou from the first\\
Wast present, and with mighty wings outspread\\
Dove-like satst brooding on the vast Abyss\\
And mad'st it pregnant: What in me is dark\\
Illumin, what is low raise and support;\\
That to the highth of this great Argument\\
I may assert Eternal Providence,\\
And justifie the wayes of God to men.\\

\vin Say first, for Heav'n hides nothing from thy view\\
Nor the deep Tract of Hell, say first what cause\\
Mov'd our Grand Parents in that happy State,\\
Favour'd of Heav'n so highly, to fall off\\
From thir Creator, and transgress his Will\\
For one restraint, Lords of the World besides?\\
Who first seduc'd them to that foul revolt?\\
Th' infernal Serpent; he it was, whose guile\\
Stird up with Envy and Revenge, deceiv'd\\
The Mother of Mankind, what time his Pride\\
Had cast him out from Heav'n, with all his Host\\
Of Rebel Angels, by whose aid aspiring\\
To set himself in Glory above his Peers,\\
He trusted to have equal'd the most High,\\
If he oppos'd; and with ambitious aim\\
Against the Throne and Monarchy of God\\
Rais'd impious War in Heav'n and Battel proud\\
With vain attempt. Him the Almighty Power\\
Hurld headlong flaming from th' Ethereal Skie\\
With hideous ruine and combustion down\\
To bottomless perdition, there to dwell\\
In Adamantine Chains and penal Fire,\\
Who durst defie th' Omnipotent to Arms.\\
Nine times the Space that measures Day and Night\\
To mortal men, he with his horrid crew\\
Lay vanquisht, rowling in the fiery Gulfe\\
Confounded though immortal: But his doom\\
Reserv'd him to more wrath; for now the thought\\
Both of lost happiness and lasting pain\\
Torments him; round he throws his baleful eyes\\
That witness'd huge affliction and dismay\\
Mixt with obdurate pride and stedfast hate:\\
At once as far as Angels kenn he views\\
The dismal Situation waste and wilde,\\
A Dungeon horrible, on all sides round\\
As one great Furnace flam'd, yet from those flames\\
No light, but rather darkness visible\\
Serv'd onely to discover sights of woe,\\
Regions of sorrow, doleful shades, where peace\\
And rest can never dwell, hope never comes\\
That comes to all; but torture without end\\
Still urges, and a fiery Deluge, fed\\
With ever-burning Sulphur unconsum'd:\\
Such place Eternal Justice had prepar'd\\
For those rebellious, here thir Prison ordain'd\\
In utter darkness, and thir portion set\\
As far remov'd from God and light of Heav'n\\
As from the Center thrice to th' utmost Pole.\\
O how unlike the place from whence they fell!\\
There the companions of his fall, o'rewhelm'd\\
With Floods and Whirlwinds of tempestuous fire,\\
He soon discerns, and weltring by his side\\
One next himself in power, and next in crime,\\
Long after known in Palestine, and nam'd\\
Beelzebub. To whom th' Arch-Enemy,\\
And thence in Heav'n call'd Satan, with bold words\\
Breaking the horrid silence thus began.\\

\vin If thou beest he; But O how fall'n! how chang'd\\
From him, who in the happy Realms of Light\\
Cloth'd with transcendent brightness didst out-shine\\
Myriads though bright: If he Whom mutual league,\\
United thoughts and counsels, equal hope\\
And hazard in the Glorious Enterprize,\\
Joynd with me once, now misery hath joynd\\
In equal ruin: into what Pit thou seest\\
From what highth fall'n, so much the stronger prov'd\\
He with his Thunder: and till then who knew\\
The force of those dire Arms? yet not for those,\\
Nor what the Potent Victor in his rage\\
Can else inflict, do I repent or change,\\
Though chang'd in outward lustre; that fixt mind\\
And high disdain, from sence of injur'd merit,\\
That with the mightiest rais'd me to contend,\\
And to the fierce contention brought along\\
\end{verse}
\end{document}
share|improve this answer
    
Good stuff. The marks are off by one, though, except for the very first and last (so it can't be fixed with arithmetic). This seems to work: \renewcommand{\incr@vsline}{% \marks1{\the\numexpr\c@poemline}% \refstepcounter{poemline}% \stepcounter{vslineno}} ... do you see any bad side effects from doing the marking in incr rather than start? –  Ibn Opcit Dec 20 '12 at 3:31
    
Ooops of course sorry. I spotted just at the end that I had hooked the mark in to the wrong place and added the -1 without really thinking. Your fix looks fine better to add the mark in the right place than in the wrong place and correct it later, especially when the correction is wrong:-) –  David Carlisle Dec 20 '12 at 9:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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