Automatic line numbering

Is it possible to include text line numbering in Pressbooks, or has a theme been developed that has this feature? Think of line numbering for legal documents, which some word processors can do automatically.

We have a professor using both the online (self-hosted Pressbooks) version of a textbook and the print version of the same book in a class. The prof would like to see line numbering that he can use to guide discussion of pinpointed text for analysis, which would appear in both the online version and PDF exports.

Has this been done by anyone yet?

1 Like

The use case you’re describing might not be well served by this, as line lengths can’t be assumed to be the same in webbook and PDF versions of the book. (Also, there’s no pure CSS way to add line numbers to a block element that I’m aware of… maybe others can correct me on this point.) A (certainly) easier solution would be to use a CSS counter to number paragraphs (and this could be added to any theme with some fiddling using our Custom Styles feature:

If anyone knows a method to add line numbering, I’d be interested in hearing it.

Hi Billy–I don’t think there’s a good way to do it with lines as they exist inside of fluid paragraphs, as Ned noted. It could be done with <pre> blocks, though, I believe. See https://www.sylvaindurand.org/using-css-to-add-line-numbering/ for one example. You could do paragraph numbering though. See https://bl.ocks.org/trauber/5163440, or https://dev.opera.com/articles/automatic-numbering-with-css-counters/ and http://philarcher.org/diary/2013/headingnumbers/ for some other examples. One of my favorite online poetry magazines, Jacket, used to have numbered paragraph blocks which I loved when citing articles I read there: http://jacketmagazine.com/36/oppen-heller.shtml. I think they used div’s and extra elements, though. I’m sure I’ve seen a recent project that not only created numbered paragraphs automatically, but also created anchor links for paragraphs, but it’s slipping my mind. NYT was playing around with a very cool idea called “emphasis” a few years back that I think would be very interesting for Open Textbooks: https://open.blogs.nytimes.com/2011/01/11/emphasis-update-and-source/

2 Likes

Thanks @ned and @SteelWagstaff, that makes sense in terms of the line breaks, screen size, exports etc.

I think the paragraph numbering might be the best bet at this point, will give it a shot.

as gutenberg is the new text editor, that is an issue for the future. and I think much simple would be.

Some really interesting work ongoing here: https://www.pagedmedia.org/what-is-the-paged-media-initiative/. Anyone else the community following (or getting involved) with this?

2 Likes

@hughmcguire and I attended the initial conference in Cambridge in January. We’re following their work with interest and contributing where we can.

2 Likes