3

From an external file I get a list with keywords separated by ;. Since hyperref only works with keywords separated by , I need to replace the semicola.

Following MWE works for text but not for pdfkeywords from hyperref

% !TEX TS-program = lualatex
\documentclass[12pt]{scrartcl}
\usepackage{xstring}
\usepackage{hyperref}
\def\fmkeywords{Keyword1; Keyword2; Keyword3}
\hypersetup{                    
  unicode,                      
  pdftitle={My title},
  pdfencoding=auto,             
  pdfkeywords={\StrSubstitute{\fmkeywords}{;}{,}},   
}
\begin{document}
wrong: \fmkeywords

correct: \StrSubstitute{\fmkeywords}{;}{,}
\end{document}

In the PDF-info it won't display the keywords:

Keywords are not listed

But all is fine in the text:

Keywords in text work fine

1 Answer 1

2

Expand the substitution and store it in the same variable (\fmkeywords):

enter image description here

\documentclass{article}

\usepackage{xstring}
\usepackage{hyperref}

\def\fmkeywords{Keyword1; Keyword2; Keyword3}

\StrSubstitute{\fmkeywords}{;}{,}[\fmkeywords]
\hypersetup{
  unicode,
  pdftitle={My title},
  pdfencoding=auto,
  pdfkeywords={\fmkeywords}
}
\begin{document}

correct: \fmkeywords

correct: \StrSubstitute{\fmkeywords}{;}{,}

\end{document}
8
  • this does not work properly as far as I see: In the Dublin Core it is still considered as one keyword: dc:subject (bag container) -- [1]: Keyword1, Keyword2, Keyword3 Commented Aug 1, 2017 at 9:32
  • @LukasCB: Try this paste. It expands the keywords before calling \hypersetup.
    – Werner
    Commented Aug 1, 2017 at 10:11
  • Still as if one keyword. No separation internally. Commented Aug 1, 2017 at 10:18
  • 1
    @LukasCB: And how does that compare to pdfkeywords={one,two,three}? Three keywords?
    – Werner
    Commented Aug 1, 2017 at 10:19
  • Yes, then they listed in the dublin core as [1]: one [2]: two [3]: three --> three keywords. Commented Aug 1, 2017 at 10:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .