function Link(link) local target = link.target if string.sub(target, 1, 1) == '#' then local label = string.sub(target, 2) link.content=pandoc.RawInline('latex', 'p.~\\pageref{' .. label .. '}') end return link end function Span(span) local id = span.identifier if span.identifier then return { pandoc.RawInline('latex', '\\label{' .. id .. '}'), span } end end