Hi, How do you access the first paragraph of each chapter ? I guess with... \setuphead[chapter][after=\PlayWithFirstParagraph] \def\PlayWithFirstParagraph... How to fill in the dots ? Alan
How do you access the first paragraph of each chapter ?
... to calculate its number of lines ?
If not possible with ConTeXt commands, is this possible with LuaTeX commands?
Alan
On Tue, Mar 3, 2009 at 12:49 PM, Alan Stone
Hi,
How do you access the first paragraph of each chapter ?
I guess with...
\setuphead[chapter][after=\PlayWithFirstParagraph]
\def\PlayWithFirstParagraph...
How to fill in the dots ?
Alan
Alan Stone wrote:
How do you access the first paragraph of each chapter ?
.... to calculate its number of lines ?
If not possible with ConTeXt commands, is this possible with LuaTeX commands?
\the\prevgraf but surely doable in luatex Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Alan Stone wrote:
How do you access the first paragraph of each chapter ?
.... to calculate its number of lines ?
If not possible with ConTeXt commands, is this possible with LuaTeX commands?
there is support for positional info ... depending on the problem that might help (set two positions and calculate the difference); no time now to explain details ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On Wed, Mar 4, 2009 at 5:33 PM, Hans Hagen
Alan Stone wrote:
How do you access the first paragraph of each chapter ?
.... to calculate its number of lines ?
If not possible with ConTeXt commands, is this possible with LuaTeX commands?
there is support for positional info ... depending on the problem
To set \setuplettrine[Lines=1] if "chapter's first paragraph number of lines = 1".
that might help (set two positions and calculate the difference); no time now to explain details
Dnia Wed, Mar 04, 2009 at 05:02:40PM +0100, Alan Stone napisał(a):
How do you access the first paragraph of each chapter ?
... to calculate its number of lines ?
If not possible with ConTeXt commands, is this possible with LuaTeX commands?
Maybe redefine \par to do something like \def\nooflines{\prevgraf}\let\par=\oldpar where previously you hd \let\oldpar=\par Regards -- Marcin Borkowski (http://mbork.pl) Jezus żyje NAPRAWDĘ. A Ty?
Am 04.03.2009 um 23:38 schrieb Marcin Borkowski:
Dnia Wed, Mar 04, 2009 at 05:02:40PM +0100, Alan Stone napisał (a):
How do you access the first paragraph of each chapter ?
... to calculate its number of lines ?
If not possible with ConTeXt commands, is this possible with LuaTeX commands?
Maybe redefine \par to do something like
\def\nooflines{\prevgraf}\let\par=\oldpar
where previously you hd \let\oldpar=\par
I don't think this will work without problems for a complete document. Enclosing each paragraph with \bpar ... \epar allows you to count the paragraph number since the last chapter and you can save \prevgraf at the end with twopass data for the next run. But wouldn't a direct \lettrine at the begin of the first paragraph be easier. Wolfgang
Marcin Borkowski wrote:
Dnia Wed, Mar 04, 2009 at 05:02:40PM +0100, Alan Stone napisał(a):
How do you access the first paragraph of each chapter ? ... to calculate its number of lines ?
If not possible with ConTeXt commands, is this possible with LuaTeX commands?
Maybe redefine \par to do something like
\def\nooflines{\prevgraf}\let\par=\oldpar
where previously you hd \let\oldpar=\par
messing around with \par is dangerous and asking for trouble ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Alan Stone wrote:
How do you invoke a command at the end of a paragraph ?
there is no hook for that (apart from adding a \endofpar command or whatever to every paragraph ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
How do you invoke a command at the end of a paragraph ?
there is no hook for that (apart from adding a \endofpar command or whatever to every paragraph
From "TeX for the Impatient"...
----------------------------------------------- \prevgraf [ <number> parameter ] In horizontal mode, this parameter specifies the number of lines in the paragraph so far; in vertical mode, it specifies the number of lines in the previous paragraph. ----------------------------------------------- After giving it some further thought and with reference to "specifies the number of lines in the paragraph so far", I don't need to know the paragraph's number of lines but whether its "number of lines" = 1 or not. Alan
Am 05.03.2009 um 14:25 schrieb Alan Stone:
After giving it some further thought and with reference to "specifies the number of lines in the paragraph so far", I don't need to know the paragraph's number of lines but whether its "number of lines" = 1 or not.
You can test whether the last paragraph had 1 or more lines and make your decision dependent on the result but this can be done only after the paragraph ist finished. \def\paragraphlines {\blank % Finish the last paragraph \ifnum\prevgraf=1 What I want.\else Too many lines.\fi \blank} \starttext \dorecurse{30}{text }\paragraphlines \dorecurse{10}{text }\paragraphlines \dorecurse{50}{text }\paragraphlines \stoptext Wolfgang
Dnia Thu, Mar 05, 2009 at 02:44:53PM +0100, Wolfgang Schuster napisał(a):
Am 05.03.2009 um 14:25 schrieb Alan Stone:
After giving it some further thought and with reference to "specifies the number of lines in the paragraph so far", I don't need to know the paragraph's number of lines but whether its "number of lines" = 1 or not.
You can test whether the last paragraph had 1 or more lines and make your decision dependent on the result but this can be done only after the paragraph ist finished.
Well, Wolfgang, you'll be surprised: it can be done (even in pure vanilla TeX), at the expense of (possibly) nonuniform spacing. Google for a file "meashor.tex":). (In Poland, we have a saying: "nasi górą!" -- roughly "our people win!" -- I can't resist citing it here, since it was Bogusław Jackowski who wrote that macros:)). Regards -- Marcin Borkowski (http://mbork.pl) Remember that direct plagiarism, including the editing of other people's work, is distinctly uncool. (Mark's Pixel Art Tutorial)
Am 05.03.2009 um 15:05 schrieb Marcin Borkowski:
You can test whether the last paragraph had 1 or more lines and make your decision dependent on the result but this can be done only after the paragraph ist finished.
Well, Wolfgang, you'll be surprised: it can be done (even in pure vanilla TeX), at the expense of (possibly) nonuniform spacing. Google for a file "meashor.tex":). (In Poland, we have a saying: "nasi górą!" -- roughly "our people win!" -- I can't resist citing it here, since it was Bogusław Jackowski who wrote that macros:)).
I found the information about display math in my TeX book (although my TeX skills are not good enough to to write the code) but Alan want to know the number of lines before the text is typeset to insert a lettrine at the begin of the paragraph, can you also deliver code for this? Wolfgang
Dnia Thu, Mar 05, 2009 at 03:14:23PM +0100, Wolfgang Schuster napisał(a):
Am 05.03.2009 um 15:05 schrieb Marcin Borkowski:
You can test whether the last paragraph had 1 or more lines and make your decision dependent on the result but this can be done only after the paragraph ist finished.
Well, Wolfgang, you'll be surprised: it can be done (even in pure vanilla TeX), at the expense of (possibly) nonuniform spacing. Google for a file "meashor.tex":). (In Poland, we have a saying: "nasi górą!" -- roughly "our people win!" -- I can't resist citing it here, since it was Bogusław Jackowski who wrote that macros:)).
I found the information about display math in my TeX book (although my TeX skills are not good enough to to write the code) but Alan want to know the number of lines before the text is typeset to insert a lettrine at the begin of the paragraph, can you also deliver code for this?
Well, obviously not:). But I only wanted to show that it _is_ possible to know in which line we are before we have the whole paragraph typeset (although with limitations). Sorry, it was a bit off-topic, but I couldn't resist the temptation to point out that Wolfgang The Great TeX Haxxor doesn't know something:P.
Wolfgang
regards -- Marcin Borkowski (http://mbork.pl) Szema Izrael: Adonai Elohenu, Adonai Ehad!
Thanks Wolfgang, however I'm looking for a solution without adding
additional commands to the text source.
Requires to switch to the LuaTeX list ?
Alan
On Thu, Mar 5, 2009 at 2:44 PM, Wolfgang Schuster
Am 05.03.2009 um 14:25 schrieb Alan Stone:
After giving it some further thought and with reference to "specifies the number of lines in the paragraph so far", I don't need to know the paragraph's number of lines but whether its "number of lines" = 1 or not.
You can test whether the last paragraph had 1 or more lines and make your decision dependent on the result but this can be done only after the paragraph ist finished.
\def\paragraphlines {\blank % Finish the last paragraph \ifnum\prevgraf=1 What I want.\else Too many lines.\fi \blank}
\starttext
\dorecurse{30}{text }\paragraphlines
\dorecurse{10}{text }\paragraphlines
\dorecurse{50}{text }\paragraphlines
\stoptext
Wolfgang
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
-- Alan
Am 05.03.2009 um 15:08 schrieb Alan Stone:
Thanks Wolfgang, however I'm looking for a solution without adding additional commands to the text source.
Requires to switch to the LuaTeX list ?
You can give it a try but I think Hans or Taco had given you then a solution if this is possible but I could be wrong regarding LuaTeX. Wolfgang
Alan Stone wrote:
Thanks Wolfgang, however I'm looking for a solution without adding additional commands to the text source.
Requires to switch to the LuaTeX list ?
that does not help you as taco and i are on both lists i can imagine that mkiv at some point privides something but it needs way more thinking (we have this end of par problem since ages) if only because what you see as end of par might actually be just before the final skips that ends a par something everyendpar is on our todo list but later in the luatex project Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On Thu, Mar 5, 2009 at 5:09 PM, Hans Hagen
Alan Stone wrote:
Thanks Wolfgang, however I'm looking for a solution without adding additional commands to the text source.
Requires to switch to the LuaTeX list ?
that does not help you as taco and i are on both lists
i can imagine that mkiv at some point privides something but it needs way more thinking (we have this end of par problem since ages) if only because what you see as end of par might actually be just before the final skips that ends a par
something everyendpar is on our todo list but later in the luatex project
Hans
Ok. In the meantime, an idea - for what it's worth... Would it be possible to somehow, in the typesetting process, dummy typeset the first paragraph of each chapter (in memory or in a dummy output file) to determine whether its number of lines = 1 or > 1, or determine its total number of lines, and work from there ? Alan
Alan Stone wrote:
On Thu, Mar 5, 2009 at 5:09 PM, Hans Hagen
wrote: Thanks Wolfgang, however I'm looking for a solution without adding additional commands to the text source.
Requires to switch to the LuaTeX list ?
Alan Stone wrote: that does not help you as taco and i are on both lists
i can imagine that mkiv at some point privides something but it needs way more thinking (we have this end of par problem since ages) if only because what you see as end of par might actually be just before the final skips that ends a par
something everyendpar is on our todo list but later in the luatex project
Hans
Ok.
In the meantime, an idea - for what it's worth...
Would it be possible to somehow, in the typesetting process, dummy typeset the first paragraph of each chapter (in memory or in a dummy output file) to determine whether its number of lines = 1 or > 1, or determine its total number of lines, and work from there ?
a luatex/mkiv solution is actually rather simple but i'm in the middle of math stuff so it has to wait some time Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Another idea... How do you make this line counter work ? \newcount\parnumber \newcount\linenumber \def\myCounters{% \EveryPar{% \advance\parnumber by 1 (P\the\parnumber) \EveryLine{% % (L\the\prevgraf)}} \advance\linenumber by 1 (L\the\linenumber)} \linenumber=0\relax} \parnumber=0\relax} \setuphead[chapter][page=,after={\myCounters}] \starttext \chapter{Chapter 0} Only one line. \dorecurse{2}{\chapter{Chapter #1}\input knuth} \stoptext Alan
Alan Stone wrote:
Another idea...
How do you make this line counter work ?
\newcount\parnumber \newcount\linenumber \def\myCounters{% \EveryPar{% \advance\parnumber by 1 (P\the\parnumber) \EveryLine{% % (L\the\prevgraf)}} \advance\linenumber by 1 (L\the\linenumber)} \linenumber=0\relax} \parnumber=0\relax}
\setuphead[chapter][page=,after={\myCounters}]
\starttext
\chapter{Chapter 0}
Only one line.
\dorecurse{2}{\chapter{Chapter #1}\input knuth}
\stoptext
\startlinenumbering \input tufte \stoplinenumbering ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On Fri, Mar 6, 2009 at 3:05 PM, Hans Hagen
\startlinenumbering
\input tufte
\stoplinenumbering
Ok, my question was a bit ambiguous... I was not looking to number lines, but to count lines using EveryLine within EveryPar, aka the paragraph counter \parnumber in the provided code. Alan
participants (4)
-
Alan Stone
-
Hans Hagen
-
Marcin Borkowski
-
Wolfgang Schuster