* page range reference (how to compare references)
@ 2016-09-23 10:18 MF
2016-09-23 13:02 ` MF
0 siblings, 1 reply; 2+ messages in thread
From: MF @ 2016-09-23 10:18 UTC (permalink / raw)
To: mailing list for ConTeXt users
Hello list,
I'm trying to reference a page range (think of a long quote spanning on
2 pages).
I need to discriminate ranges collapsing to one page from "real" ranges
(2 or more pages): "1-1" should become "1", while "1-2" should stay
like that.
Here's a not working snippet:
\starttext
Tufte quote at p.
\at[tufte:start]\doifelse{\ref[realpage][tufte:start]}{\ref[realpage][t
ufte:stop]}
{}
{-\at[tufte:stop]}
% start of quote reference
\pagereference[tufte:start]
\input{tufte}
%\page % comment/uncomment this to toggle from range to single page
\input{tufte}
% end of quote reference
\pagereference[tufte:stop]
\stoptext
The \doifelse is always false, I think because \ref[realpage][...] is
not a string.
Thanks in advance.
BTW, best wishes for next week's meeting (hoping to join next year).
Best regards,
Massi
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: page range reference (how to compare references)
2016-09-23 10:18 page range reference (how to compare references) MF
@ 2016-09-23 13:02 ` MF
0 siblings, 0 replies; 2+ messages in thread
From: MF @ 2016-09-23 13:02 UTC (permalink / raw)
To: ntg-context
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-09-23 13:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-23 10:18 page range reference (how to compare references) MF
2016-09-23 13:02 ` MF
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).