I apologize in advance as I am yet to accept some answers to my previous questions; but I'll dare ask this one, as it is somewhat of a showstopper - consider this example:



\newcommand{\myauthors}{Author 1 \\ Author 2 \\ {\color{lightgray}Author 3}}

\hypersetup{pdftitle=My Title, pdfauthor=\myauthors, pdfsubject=My Subject, pdfkeywords=} 




Here I get the \myauthors typeset exactly as I want them (the "Author 3" is lightgray) - however, in the PDF properties, the Author metadata shows: "Author 1 Author 2 lightgrayAuthor 3" - that is, the "lightgray" in \color{lightgray} of \myauthors ends up as text for the pdfauthor attribute.

I was wandering - is there some sort of a macro, that would "extract" the typeset "plain text" (that is, only those characters that are typeset) - so I could write, say:

\hypersetup{... pdfauthor=\getPlainText{\myauthors}, pdfsubject=...}

... and get "Author 1 Author 2 Author 3" as PDF author metadata?

Alternatively, I was thinking something along the approach in Macro to convert 'multi-line' text to 'single-line' (remove line breaks?) - that is, use macros like:

\newcommand{\myauthors}{Author 1 \\ Author 2 \\ \pastauth{Author 3}}

... and then somehow define a \getPlainText, where the \pastauth would be temporarily \let to \npastauth (thus avoiding \color{lightgray} altogether) - but I cannot get anything with this... I also tried redefining \color with \@gobbleone, but that doesn't work either

  • 1
    I removed some parts of your code that weren't relevant to the question. Please try to do so yourself before posting a question, keep everything simple (which sometimes isn't so simple itself :)).
    – doncherry
    Commented Apr 6, 2012 at 9:56
  • Thanks for that, @doncherry - it's just that sometimes I use these snippets to start new examples, and so I like to have some arguments I usually forget standing around :) Cheers!
    – sdaau
    Commented Apr 6, 2012 at 10:19

1 Answer 1


You need to use the

\texorpdfstring{<TeX string>}{<PDF string>}

macro to define a separate TeX and/or PDF string:

\newcommand{\myauthors}{Author 1 \\ Author 2 \\ \texorpdfstring{\color{lightgray}Author 3}{Author 3}}

The following is a view of the Document Properties using Adobe Acrobat:

PDF meta data

So, your <TeX string> defines the colour, while your <PDF string> uses a "plain text" version (void of \color).

This is supported by hyperref and is also usually associated with math contents in sectional headings, which end up in the PDF bookmarks (which is text-based). For more on this "replacement macro", see the hyperref documentation (HTML version).

  • Fantastic @Werner - many thanks for this answer! Cheers!
    – sdaau
    Commented Feb 3, 2012 at 7:01

You must log in to answer this question.

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