Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % http://tex.stackexchange.com/q/342509/5764
- \documentclass{report}
- \usepackage{luacode,hyperref}
- \usepackage{lipsum}
- \begin{luacode}
- function inserthref ( s )
- if string.find ( s , '\\chapter' ) == nil then
- s = string.gsub ( s , 'My unique chapter name',
- '\\hyperref[ch:my-unique-chapter-name]{My unique chapter name}' )
- s = string.gsub ( s , 'Introduction',
- '\\hyperref[ch:introduction]{Introduction}' )
- end
- return ( s )
- end
- \end{luacode}
- \AtBeginDocument{\directlua{luatexbase.add_to_callback (
- "process_input_buffer", inserthref, "inserthref" ) }}
- \begin{document}
- \chapter{Introduction}
- \label{ch:introduction}
- \chapter{My unique chapter name}
- \label{ch:my-unique-chapter-name}
- \lipsum[1-10]
- See My unique chapter name as well as introduction, Introduction.
- \end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement