public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* \pageref{} does not work for hypertargets; this is a work-around
@ 2019-05-06  0:04 rauschma-Re5JQEeQqe8AvxtiuMwx3w
       [not found] ` <c8121aed-b564-44c3-8289-ede0ee7046bd-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: rauschma-Re5JQEeQqe8AvxtiuMwx3w @ 2019-05-06  0:04 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 1617 bytes --]

Problem: The \pageref{} at the end does not work. IDs for headings work 
just fine. (I’m using \pageref{} internally, via a filter, for the print 
version of my book.)

[Bla bla bla.]{#foo}
···
For more information, consult \pageref{foo}.


Solution:

\multilabel{foo} Bla bla bla.
···
For more information, consult \pageref{foo}.


Lua filter that implements \multilabel{}. Feedback welcome.

-- Problem: \pageref{} does not work with \hypertarget{}
-- Work-around: \phantomsection\label{foo}\hypertarget{foo}{}
-- 
https://tex.stackexchange.com/questions/376805/the-page-number-of-a-hypertarget
function RawInline(el)
if (el.format == "tex") then
local inner = string.match(el.text, "\\multilabel{([^{}]*)}")
if (inner ~= nil) then
if FORMAT == "latex" then
return pandoc.RawInline("tex", "\\phantomsection\\label{" .. inner .. 
"}\\hypertarget{" .. inner .. "}{}")
else
return pandoc.Span(
{pandoc.Str("")}, -- list of inlines
pandoc.Attr(inner)
)
end
end
end
return nil -- no change
end

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/c8121aed-b564-44c3-8289-ede0ee7046bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 4510 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: \pageref{} does not work for hypertargets; this is a work-around
       [not found] ` <c8121aed-b564-44c3-8289-ede0ee7046bd-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2019-05-07  5:48   ` rauschma-Re5JQEeQqe8AvxtiuMwx3w
  0 siblings, 0 replies; 2+ messages in thread
From: rauschma-Re5JQEeQqe8AvxtiuMwx3w @ 2019-05-07  5:48 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 1403 bytes --]

I thought a LaTeX command was convenient, but it turns out that a span is 
better (can be used in more situations). New filter:

-- Problem: \pageref{} does not work with \hypertarget{}
-- Work-around: \phantomsection\label{foo}\hypertarget{foo}{}
-- 
https://tex.stackexchange.com/questions/376805/the-page-number-of-a-hypertarget

function Span(span)
if span.attr.classes:includes("texlabel") then
-- This check is useful even if FORMAT ~= "latex"
if span.attr.identifier == "" then
error("Missing ID (starts with a #hash)")
end
if FORMAT ~= "latex" then
return nil
end
return {
pandoc.RawInline("tex", "\\phantomsection\\label{" .. span.attr.identifier 
.. "}"), -- for \pageref{}
span -- for hyperlinks
}
end
return nil -- no change
end


Used as follows:

[Hoisting]{#hoisting .texlabel} is an important term in this context.

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/e1d94e0b-131f-4cb2-a636-68acf8e824e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 7663 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-05-07  5:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-06  0:04 \pageref{} does not work for hypertargets; this is a work-around rauschma-Re5JQEeQqe8AvxtiuMwx3w
     [not found] ` <c8121aed-b564-44c3-8289-ede0ee7046bd-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-05-07  5:48   ` rauschma-Re5JQEeQqe8AvxtiuMwx3w

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).