Forum How do I...?

How do I number lines of a paragraph?

thomas
Hello,

I try to achieve what the lineno LaTeX package does.

(1) Is it possible to number lines (which are not pre-wrapped, of course)?

1    Lorem ipsum dolor sit amet,          <p>Lorem ipsum...</p>
     consectetuer adipiscing elit. Etiam
     eros. Donec gravida pede a mauris.
     Etiam sem eros, tempus a, accumsan
5    pharetra, lacinia aliquam, nibh.
     Conubia nostra, per inceptos
     hymenaeos.

     A SECTION                            <h2>A SECTION</h2>

     Phasellus bibendum nonummy           <p>Phasellus bibendum...</p>
10   lorem. Fusce nibh. Mauris lacinia
     et pellentesque elementum, pede
     augue ut libero. Aenean consequat
     arcu. Etiam non nulla eget diam
     tempus fermentum. Cras vel velit.
15   blandit pulvinar lectus


(2) If yes, is it possible to reference a line? For instance: The author uses the word Etiam (see line 13), which is quite surprising here, etc.

IMO it is not possible to achieve this with Prince & HTML/CSS. There is a "::first-line" pseudo element in CSS 2.1 (not supported yet by Prince), but we would need a "::line(nth)" selector and a line counter. But maybe you know some trick to number lines? Any suggestion is welcome.

Thomas
mikeday
There is no method to do this at present unless you manually break lines. Sorry! :(
thomas
OK, thanks for the answer. It's amazing how HTML/CSS can be at the same time very powerful (i.e. counters, positioning of elements, floats, etc.) and lacking simple features (even MS Word can do line numbering).

Anyway, I am happy to see soon the release of Prince 7.1!

++
Thomas
yet
thomas wrote:
OK, thanks for the answer. It's amazing how HTML/CSS can be at the same time very powerful (i.e. counters, positioning of elements, floats, etc.) and lacking simple features (even MS Word can do line numbering).

Anyway, I am happy to see soon the release of Prince 7.1!

++
Thomas


Well HTML/CSS + Prince is not a word-processing solution. We usually solve such problems by pre-processing the input HTML and transforming it if necessary before feeding it into Prince.
thomas
yet wrote:
Well HTML/CSS + Prince is not a word-processing solution. We usually solve such problems by pre-processing the input HTML and transforming it if necessary before feeding it into Prince.


I do this too! I parse the HTML files with a home-made python program to modify the document. (For instance, I add the style "hyphens:none" to the last word of a paragraph, I disable ligatures in some german words where they should not occur, I generate a TOC, etc.). But there are still some things I cannot do, for instance:

1. If there is not enough space at the end of a page for a footnote, splitting it so that the footnote begins on the page and continues on the next page (this is really a must-have feature!),
2. Having named cross-references such as "the figure on the next page", "the paragraph on the facing page",
3. Numbering lines and referencing lines,
4. Having multiple footnote areas (see the beauty of this).

I do not think any piece code will bring theses features, but if I am wrong, let me know which code you use to pre-process the file ;)

Though, I share your feeling that it is not necessary that Prince supports things that could be done easily with an other program (for example, the Instant Preview feature, IMO, could really be handled by another program). Generally, Prince is excellent at avoiding software bloat. I am happy that it is both powerful and slim.

Regards,
Thomas
jim_albright
Multiple footnote areas. I agree.

Jim Albright
Wycliffe Bible Translators

ollieman
The following may be a bit cumbersome, but it works. "overflow:hidden" is your friend.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
		<title>Hello World</title>
		<style type="text/css">
		div {
			position:relative;
			overflow:hidden;
		}
		p {
			width:200px;
			margin:0 0 0 40px;
		}
		p#numbers {
			margin-top:0;
			position:absolute;
			top:0;
			left:-40px;
			width:30px;
			text-align:right;
			color:red;
		}
		</style>
	</head>
	<body>
		<div>
		<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
		<p id="numbers">1<br/><br/><br/><br/>5<br/><br/><br/><br/><br/>10<br/><br/><br/><br/><br/>15</p>
		</div>
	</body>
</html>
mikeday
Wow, that's clever! :D
thomas
Yes, it is clever, thanks ollieman! This will work for a paragraph which does not span over two pages.

But this is not the perfect solution: if the paragraph spans over two pages, if you do not want to reset numbering between paragraphs separated by a <h1> or a page break... you need something else :(

Thomas