Replace ligature in bookmarks
Replace ligature in bookmarks
I am trying to replace the s:
ligature in the bookmarks by just an s
. This is needed as my document is written using a fraktur font, but the colon appears inside the bookmarks as they are not in fraktur.
s:
s
My current code is the following one:
documentclass[a4paper]scrartcl
usepackageyfonts
addtokomafontdispositionfrakfamilyfraklines
usepackage[hidelinks]hyperref
usepackagexstring
newcommandremoveLigatures[1]%
IfSubStr#1s:%
StrSubstitute#1s:s%
#1
newcommandmySection[1]%
sectiontexorpdfstring#1removeLigatures#1
begindocument
frakfamily
tableofcontents
mySectionJus:t a tes:t
enddocument
There seems to be some issue with my code, as I get a bookmark with the text Jus:t a tes:ts:s:sJus:t a tes:t
. How can I fix this to achieve the desired results?
Jus:t a tes:ts:s:sJus:t a tes:t
1 Answer
1
You must do the replacement before feeding the argument to texorpdfstring. E.g. with expl3:
documentclass[a4paper]scrartcl
usepackageyfonts
usepackage[hidelinks]hyperref
usepackageexpl3
ExplSyntaxOn
newcommandremoveLigatures[1]%
tl_set:Nn l_tmpa_tl#1
regex_replace_all:nnN s: s l_tmpa_tl
newcommandmySection[1]%
removeLigatures#1
sectiontexorpdfstring#1l_tmpa_tl
ExplSyntaxOff
addtokomafontsectioningfrakfamily
begindocument
frakfamily
tableofcontents
mySectionJus:t a tes:t
enddocument
s::
s:
s:
yes, sorry I forgot the s in the regex.
– Ulrike Fischer
Sep 7 '18 at 7:05
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
While this works for the basic case, this eliminates all colons from
s::
, too. Instead this should be translated tos:
as inside the document text itself (where it is represented by thes:
ligature followed by a regular colon). This seems to be just a little regex fix.– epR8GaYuh
Sep 7 '18 at 5:23