ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Max Chernoff via ntg-context <ntg-context@ntg.nl>
To: Joel <uaru99@yahoo.com>, "ntg-context@ntg.nl" <ntg-context@ntg.nl>
Cc: Max Chernoff <mseven@telus.net>
Subject: Re: How to make something appear to the right of every paragraph?
Date: Mon, 10 Oct 2022 16:57:04 -0600	[thread overview]
Message-ID: <c533d4e59bcc56776a529bbc39576e30a7adfd2e.camel@telus.net> (raw)
In-Reply-To: <1021593645.3823045.1665405982067@mail.yahoo.com>

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
___________________________________________________________________________________

  reply	other threads:[~2022-10-10 22:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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-10 12:46     ` Joel via ntg-context
2022-10-10 22:57       ` Max Chernoff via ntg-context [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c533d4e59bcc56776a529bbc39576e30a7adfd2e.camel@telus.net \
    --to=ntg-context@ntg.nl \
    --cc=mseven@telus.net \
    --cc=uaru99@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).