From: MF <massifr@fastwebnet.it>
To: ntg-context@ntg.nl
Subject: Re: page range reference (how to compare references)
Date: Fri, 23 Sep 2016 15:02:03 +0200 [thread overview]
Message-ID: <1474635723.9042.3.camel@fastwebnet.it> (raw)
In-Reply-To: <1474625908.4442.9.camel@fastwebnet.it>
I found a solution, but it's tricky (and there's no check on reference
existence in structures.references.collected).
\directlua{
function userdata.printrange(singular, plural, label)
local coll_ref = structures.references.collected[""]
local pagestart = coll_ref[label .. ":start"].references.realpage
local pagestop = coll_ref[label .. ":stop"].references.realpage
if pagestart == pagestop then
context(singular)
else
context(plural)
end
context("~")
context.ref({"page"}, {label .. ":start"})
if pagestart ~= pagestop then
context("-")
context.ref({"page"}, {label .. ":stop"})
end
end
function userdata.printpagerange(label)
userdata.printrange("page", "pages", label)
end
}
\def\printpagerange#1{\ctxlua{userdata.printpagerange("#1")}}
\starttext
Tufte quote at \printpagerange{tufte}.
% start of quote reference
\pagereference[tufte:start]
\input{tufte}
%\page % comment/uncomment this to toggle from page range to single
page
\input{tufte}
% end of quote reference
\pagereference[tufte:stop]
\stoptext
___________________________________________________________________________________
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 : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
prev parent reply other threads:[~2016-09-23 13:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-23 10:18 MF
2016-09-23 13:02 ` MF [this message]
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=1474635723.9042.3.camel@fastwebnet.it \
--to=massifr@fastwebnet.it \
--cc=ntg-context@ntg.nl \
/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).