[NTG-context] How to make something appear to the right of every paragraph?
Joel
uaru99 at yahoo.com
Thu Oct 13 13:32:34 CEST 2022
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 at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20221013/c6f9d05f/attachment-0001.htm>
More information about the ntg-context
mailing list