* How to make something appear to the right of every paragraph? [not found] <1936318934.3722841.1665353527397.ref@mail.yahoo.com> @ 2022-10-09 22:12 ` Joel via ntg-context 2022-10-10 6:24 ` Max Chernoff via ntg-context 2022-10-11 17:28 ` Hans Hagen via ntg-context 0 siblings, 2 replies; 9+ messages in thread From: Joel via ntg-context @ 2022-10-09 22:12 UTC (permalink / raw) To: ntg-context; +Cc: Joel [-- Attachment #1.1: Type: text/plain, Size: 1154 bytes --] I'd like to add some area for readers to write in the margins of some text. This would leave three lines, like this to the right of the text. __________________ The passage would take up about the left 60% of the text and the margin note space about 30% of textwidth, so no need to use the margins. Though its easy for me to implement this code using some \thinrules and manually dropping macros in the text, is there some way ConTeXt can be told to just add them to right of every paragraph (at the start of the paragraph)? Sample: This is some text ________ that is written in ________ the passage and ________you can see the th-ree lines to the right.The text in the para-graph continues eventhough there arejust three lines tothe right. Here is another par- ________agraph. ________ ________ Here is yet another ________paragraph. You can ________see it also has the ________three liens. This is just for a segment of the book, not every paragraph in the book. --Joel [-- Attachment #1.2: Type: text/html, Size: 3328 bytes --] [-- Attachment #2: Type: text/plain, Size: 496 bytes --] ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to make something appear to the right of every paragraph? 2022-10-09 22:12 ` How to make something appear to the right of every paragraph? Joel via ntg-context @ 2022-10-10 6:24 ` Max Chernoff via ntg-context 2022-10-10 12:46 ` Joel via ntg-context 2022-10-11 17:28 ` Hans Hagen via ntg-context 1 sibling, 1 reply; 9+ messages in thread From: Max Chernoff via ntg-context @ 2022-10-10 6:24 UTC (permalink / raw) To: ntg-context; +Cc: Max Chernoff Hi Joel, > I'd like to add some area for readers to write in the margins of some > text. This would leave three lines, like this to the right of the > text. Is it okay if there are rules continuously down the right column? If so, this is fairly simple to do with layers/backgrounds + MetaFun. If you want for there to be exactly three rules per paragraph, then that is more complicated. I can think of some bad solutions (\everypar, Lua callbacks), but I'll leave it to someone else to think of a good solution. Thanks, -- Max ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to make something appear to the right of every paragraph? 2022-10-10 6:24 ` Max Chernoff via ntg-context @ 2022-10-10 12:46 ` Joel via ntg-context 2022-10-10 22:57 ` Max Chernoff via ntg-context 0 siblings, 1 reply; 9+ messages in thread From: Joel via ntg-context @ 2022-10-10 12:46 UTC (permalink / raw) To: ntg-context, Max Chernoff; +Cc: Joel [-- Attachment #1.1: Type: text/plain, Size: 882 bytes --] Hello Max, It is preferred if the solution is just three lines per paragraph, rather than some content parallel to the text...I'll be modifying whatever solution to fix a bunch of other situations (e.g. display a box next to each paragraph). --Joel On Monday, October 10, 2022 at 12:24:03 AM MDT, Max Chernoff <mseven@telus.net> wrote: Hi Joel, > I'd like to add some area for readers to write in the margins of some > text. This would leave three lines, like this to the right of the > text. Is it okay if there are rules continuously down the right column? If so, this is fairly simple to do with layers/backgrounds + MetaFun. If you want for there to be exactly three rules per paragraph, then that is more complicated. I can think of some bad solutions (\everypar, Lua callbacks), but I'll leave it to someone else to think of a good solution. Thanks, -- Max [-- Attachment #1.2: Type: text/html, Size: 2107 bytes --] [-- Attachment #2: Type: text/plain, Size: 496 bytes --] ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to make something appear to the right of every paragraph? 2022-10-10 12:46 ` Joel via ntg-context @ 2022-10-10 22:57 ` Max Chernoff via ntg-context 2022-10-11 3:58 ` Wolfgang Schuster via ntg-context 2022-10-13 11:32 ` Joel via ntg-context 0 siblings, 2 replies; 9+ messages in thread From: Max Chernoff via ntg-context @ 2022-10-10 22:57 UTC (permalink / raw) To: Joel, ntg-context; +Cc: Max Chernoff Hi Joel, On Mon, 2022-10-10 at 12:46 +0000, Joel wrote: > Hello Max, > It is preferred if the solution is just three lines per paragraph, > rather than some content parallel to the text A Lua callback solution: \startluacode -- Constants RULE_OFFSET = tex.sp "1em" RULE_THICKNESS = tex.sp "0.4pt" RULE_LENGTH = tex.sp "3cm" -- Callback function userdata.lines(head) if status.output_active or tex.nest.ptr > 1 then return head end local i = 0 for n in node.traverseid(node.id "hlist", head) do i = i + 1 if i > 3 then break end local offset = node.new "glue" offset.width = RULE_OFFSET node.slide(n.list).next = offset local rule = node.new "rule" rule.width = RULE_LENGTH rule.height = RULE_THICKNESS rule.depth = 0 offset.next = rule end return head end nodes.tasks.appendaction( "finalizers", "after", "userdata.lines" ) \stopluacode \parskip=\baselineskip \starttext One line paragraph Two line paragraph \\ Two line paragraph Three line paragraph \\ Three line paragraph \\ Three line paragraph Four line paragraph \\ Four line paragraph \\ Four line paragraph \\ Four line paragraph \samplefile{bryson} \samplefile{knuth} \stoptext An \everypar solution: \appendtoks% \vbox to 0pt{% \dorecurse{3}{% \rlap{% \hskip\dimexpr\hsize+1em% \vrule height 0.4pt width 3cm% \relax% }% }% }% \to\everypar \parskip=\baselineskip \starttext One line paragraph Two line paragraph \\ Two line paragraph Three line paragraph \\ Three line paragraph \\ Three line paragraph Four line paragraph \\ Four line paragraph \\ Four line paragraph \\ Four line paragraph \samplefile{bryson} \samplefile{knuth} \stoptext Neither of these solutions are great though. Both of these solutions are pretty low-level, so there's presumably a more ConTeXt-y way of doing this. Thanks, -- Max ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to make something appear to the right of every paragraph? 2022-10-10 22:57 ` Max Chernoff via ntg-context @ 2022-10-11 3:58 ` Wolfgang Schuster via ntg-context 2022-10-13 11:30 ` Joel via ntg-context 2022-10-13 11:32 ` Joel via ntg-context 1 sibling, 1 reply; 9+ messages in thread From: Wolfgang Schuster via ntg-context @ 2022-10-11 3:58 UTC (permalink / raw) To: mailing list for ConTeXt users, Max Chernoff via ntg-context Cc: Wolfgang Schuster, Max Chernoff Max Chernoff via ntg-context schrieb am 11.10.2022 um 00:57: > Hi Joel, > > On Mon, 2022-10-10 at 12:46 +0000, Joel wrote: >> Hello Max, >> It is preferred if the solution is just three lines per paragraph, >> rather than some content parallel to the text > A Lua callback solution: > > [...] > > An \everypar solution: > > \appendtoks% > \vbox to 0pt{% > \dorecurse{3}{% > \rlap{% > \hskip\dimexpr\hsize+1em% > \vrule height 0.4pt width 3cm% > \relax% > }% > }% > }% > \to\everypar You can use the \EveryPar register but \everypar is off limits. Wolfgang ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to make something appear to the right of every paragraph? 2022-10-11 3:58 ` Wolfgang Schuster via ntg-context @ 2022-10-13 11:30 ` Joel via ntg-context 0 siblings, 0 replies; 9+ messages in thread From: Joel via ntg-context @ 2022-10-13 11:30 UTC (permalink / raw) To: mailing list for ConTeXt users, Wolfgang Schuster; +Cc: Joel, Max Chernoff [-- Attachment #1.1: Type: text/plain, Size: 1285 bytes --] When I use the code given, it compiles and displays fine. But when I try replacing \everypar with \EveryPar, it halts during compiling with this complaint: "A number should have been here; I inserted '0'. (If you can't figure out why I needed to see a number, look up 'weird error' in the index to The TeXbook.) mtx-context | fatal error: return code: 1 " On Monday, October 10, 2022 at 09:58:11 PM MDT, Wolfgang Schuster <wolfgang.schuster.lists@gmail.com> wrote: Max Chernoff via ntg-context schrieb am 11.10.2022 um 00:57: > Hi Joel, > > On Mon, 2022-10-10 at 12:46 +0000, Joel wrote: >> Hello Max, >> It is preferred if the solution is just three lines per paragraph, >> rather than some content parallel to the text > A Lua callback solution: > > [...] > > An \everypar solution: > > \appendtoks% > \vbox to 0pt{% > \dorecurse{3}{% > \rlap{% > \hskip\dimexpr\hsize+1em% > \vrule height 0.4pt width 3cm% > \relax% > }% > }% > }% > \to\everypar You can use the \EveryPar register but \everypar is off limits. Wolfgang [-- Attachment #1.2: Type: text/html, Size: 3053 bytes --] [-- Attachment #2: Type: text/plain, Size: 496 bytes --] ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to make something appear to the right of every paragraph? 2022-10-10 22:57 ` Max Chernoff via ntg-context 2022-10-11 3:58 ` Wolfgang Schuster via ntg-context @ 2022-10-13 11:32 ` Joel via ntg-context 2022-10-14 0:50 ` Max Chernoff via ntg-context 1 sibling, 1 reply; 9+ messages in thread From: Joel via ntg-context @ 2022-10-13 11:32 UTC (permalink / raw) To: ntg-context, Max Chernoff; +Cc: Joel [-- Attachment #1.1: Type: text/plain, Size: 3216 bytes --] These both work great, but do that for the whole document? Is there a way to restrict it to only apply the lines to some parts of the file, not every single paragraph? Thanks! --Joel On Monday, October 10, 2022 at 04:57:07 PM MDT, Max Chernoff <mseven@telus.net> wrote: Hi Joel, On Mon, 2022-10-10 at 12:46 +0000, Joel wrote: > Hello Max, > It is preferred if the solution is just three lines per paragraph, > rather than some content parallel to the text A Lua callback solution: \startluacode -- Constants RULE_OFFSET = tex.sp "1em" RULE_THICKNESS = tex.sp "0.4pt" RULE_LENGTH = tex.sp "3cm" -- Callback function userdata.lines(head) if status.output_active or tex.nest.ptr > 1 then return head end local i = 0 for n in node.traverseid(node.id "hlist", head) do i = i + 1 if i > 3 then break end local offset = node.new "glue" offset.width = RULE_OFFSET node.slide(n.list).next = offset local rule = node.new "rule" rule.width = RULE_LENGTH rule.height = RULE_THICKNESS rule.depth = 0 offset.next = rule end return head end nodes.tasks.appendaction( "finalizers", "after", "userdata.lines" ) \stopluacode \parskip=\baselineskip \starttext One line paragraph Two line paragraph \\ Two line paragraph Three line paragraph \\ Three line paragraph \\ Three line paragraph Four line paragraph \\ Four line paragraph \\ Four line paragraph \\ Four line paragraph \samplefile{bryson} \samplefile{knuth} \stoptext An \everypar solution: \appendtoks% \vbox to 0pt{% \dorecurse{3}{% \rlap{% \hskip\dimexpr\hsize+1em% \vrule height 0.4pt width 3cm% \relax% }% }% }% \to\everypar \parskip=\baselineskip \starttext One line paragraph Two line paragraph \\ Two line paragraph Three line paragraph \\ Three line paragraph \\ Three line paragraph Four line paragraph \\ Four line paragraph \\ Four line paragraph \\ Four line paragraph \samplefile{bryson} \samplefile{knuth} \stoptext Neither of these solutions are great though. Both of these solutions are pretty low-level, so there's presumably a more ConTeXt-y way of doing this. Thanks, -- Max [-- Attachment #1.2: Type: text/html, Size: 8169 bytes --] [-- Attachment #2: Type: text/plain, Size: 496 bytes --] ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to make something appear to the right of every paragraph? 2022-10-13 11:32 ` Joel via ntg-context @ 2022-10-14 0:50 ` Max Chernoff via ntg-context 0 siblings, 0 replies; 9+ messages in thread From: Max Chernoff via ntg-context @ 2022-10-14 0:50 UTC (permalink / raw) To: Joel, ntg-context; +Cc: Max Chernoff Hi Joel, > When I use the code given, it compiles and displays fine. But when I > try replacing \everypar with \EveryPar, it halts during compiling It looks like \EveryPar is a macro and not a token list. > These both work great, but do that for the whole document? Is there a > way to restrict it to only apply the lines to some parts of the file, > not every single paragraph? Option 1: \newif\ifprintlines \EveryPar{% \ifprintlines% \vbox to 0pt{% \dorecurse{3}{% \rlap{% \hskip\dimexpr\hsize+1em% \vrule height 0.4pt width 3cm% \relax% }% }% }% \fi% } \parskip=\baselineskip \starttext \printlinestrue One line paragraph Two line paragraph \\ Two line paragraph Three line paragraph \\ Three line paragraph \\ Three line paragraph \printlinesfalse Four line paragraph \\ Four line paragraph \\ Four line paragraph \\ Four line paragraph \samplefile{bryson} \printlinestrue \samplefile{knuth} \stoptext Option 2: \startluacode -- Constants local RULE_OFFSET = tex.sp "1em" local RULE_THICKNESS = tex.sp "0.4pt" local RULE_LENGTH = tex.sp "3cm" local show_lines = true -- Callback function userdata.lines(head) if status.output_active or tex.nest.ptr > 1 or not show_lines then return head end local i = 0 for n in node.traverseid(node.id "hlist", head) do i = i + 1 if i > 3 then break end local offset = node.new "glue" offset.width = RULE_OFFSET node.slide(n.list).next = offset local rule = node.new "rule" rule.width = RULE_LENGTH rule.height = RULE_THICKNESS rule.depth = 0 offset.next = rule end return head end nodes.tasks.appendaction( "finalizers", "after", "userdata.lines" ) interfaces.implement { name = "showlines", public = true, arguments = { "boolean" }, actions = function(x) show_lines = x end, } \stopluacode \parskip=\baselineskip \starttext \showlines true One line paragraph Two line paragraph \\ Two line paragraph Three line paragraph \\ Three line paragraph \\ Three line paragraph \showlines false Four line paragraph \\ Four line paragraph \\ Four line paragraph \\ Four line paragraph \samplefile{bryson} \showlines true \samplefile{knuth} \stoptext These are both kind of hacky though. I'd recommend that you use Hans's solution instead: \starttext \def\StartHack {\margintext [location=right,style=] {\thinrules[n=3]}} \def\StopHack {\par \ifnum\prevgraf<3 \blank[\the\numexpr4-\prevgraf\relax*line] \fi} \StartHack \input tufte \StopHack \StartHack test test \StopHack \StartHack test test \StopHack \stoptext Thanks, -- Max ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to make something appear to the right of every paragraph? 2022-10-09 22:12 ` How to make something appear to the right of every paragraph? Joel via ntg-context 2022-10-10 6:24 ` Max Chernoff via ntg-context @ 2022-10-11 17:28 ` Hans Hagen via ntg-context 1 sibling, 0 replies; 9+ messages in thread From: Hans Hagen via ntg-context @ 2022-10-11 17:28 UTC (permalink / raw) To: Joel via ntg-context; +Cc: Hans Hagen On 10/10/2022 12:12 AM, Joel via ntg-context wrote: > I'd like to add some area for readers to write in the margins of some > text. This would leave three lines, like this to the right of the text. > > ______ > ______ > ______ > > The passage would take up about the left 60% of the text and the margin > note space about 30% of textwidth, so no need to use the margins. > > Though its easy for me to implement this code using some \thinrules and > manually dropping macros in the text, is there some way ConTeXt can be > told to just add them to right of every paragraph (at the start of the > paragraph)? > > Sample: > > This is some text ________ > that is written in ________ > the passage and ________ > you can see the th- > ree lines to the right. > The text in the para- > graph continues even > though there are > just three lines to > the right. > > Here is another par- ________ > agraph. ________ > ________ > > Here is yet another ________ > paragraph. You can ________ > see it also has the ________ > three liens. > > This is just for a segment of the book, not every paragraph in the book. \starttext \def\StartHack {\margintext [location=right,style=] {\thinrules[n=3]}} \def\StopHack {\par \ifnum\prevgraf<3 \blank[\the\numexpr4-\prevgraf\relax*line] \fi} \StartHack \input tufte \StopHack \StartHack test test \StopHack \StartHack test test \StopHack \stoptext -- ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl ----------------------------------------------------------------- ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-10-14 0:50 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <1936318934.3722841.1665353527397.ref@mail.yahoo.com> 2022-10-09 22:12 ` How to make something appear to the right of every paragraph? Joel via ntg-context 2022-10-10 6:24 ` Max Chernoff via ntg-context 2022-10-10 12:46 ` Joel via ntg-context 2022-10-10 22:57 ` Max Chernoff via ntg-context 2022-10-11 3:58 ` Wolfgang Schuster via ntg-context 2022-10-13 11:30 ` Joel via ntg-context 2022-10-13 11:32 ` Joel via ntg-context 2022-10-14 0:50 ` Max Chernoff via ntg-context 2022-10-11 17:28 ` Hans Hagen via ntg-context
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).