[XeTeX] color name in headline bleeds into pdf bookmarks

2022-01-12 Thread Niemann, Hartmut
Hello!

I observed a strange thing when experimenting with colored text.

---8<
\documentclass{article}
\usepackage{xcolor}
\usepackage{bookmark}
\begin{document}
\tableofcontents
\newpage
\section{One}
\section{\color{red}Two}
\section{Three}
\end{document}
--8<--
I ran this through xelatex (texlive 2018 on windows 10-64) three times to get 
the toc right.

There is a pdf bookmark for each section, but the second one is "redTwo" 
instead of "Two".

Is there a way to avoid that?


Regards

Hartmut

--
Siemens Mobility GmbH
SMO RS LMC EN LM CCI2 CCU DIAG
Siemenspromenade 5
91058 Erlangen, Germany
Phone: +49 (9131) 17-50518
Mobile: +49 (173) 5342327
mailto:hartmut.niem...@siemens.com
www.siemens.com
[Logo]
Siemens Mobility GmbH; Chairman of the Supervisory Board: Roland Busch; 
Management Board: Karl Blaim, Michael Peter; Registered office: Munich, 
Germany; Commercial registry Munich, HRB 237219; WEEE-Reg.-No. DE 92917817




Re: [XeTeX] color name in headline bleeds into pdf bookmarks

2022-01-12 Thread Herbert Schulz



> On Jan 12, 2022, at 9:41 AM, Niemann, Hartmut  
> wrote:
> 
> Hello!
>  
> I observed a strange thing when experimenting with colored text.
>  
> ---8<
> \documentclass{article}
> \usepackage{xcolor}
> \usepackage{bookmark}
> \begin{document}
> \tableofcontents
> \newpage
> \section{One}
> \section{\color{red}Two}
> \section{Three}
> \end{document}
> --8<--
> I ran this through xelatex (texlive 2018 on windows 10-64) three times to get 
> the toc right.
>  
> There is a pdf bookmark for each section, but the second one is “redTwo” 
> instead of “Two”.
>  
> Is there a way to avoid that?
>  
>  
> Regards
>  
> Hartmut

Howdy,

I don't reproduce this in TeX Live 2021.

You might use \protect\color and see if that helps.

Good Luck,

Herb Schulz
he...@wideopenwest.com





Re: [XeTeX] color name in headline bleeds into pdf bookmarks

2022-01-12 Thread Ulrike Fischer
Am Wed, 12 Jan 2022 15:41:54 + schrieb Niemann, Hartmut:

> I observed a strange thing when experimenting with colored text.
> 
> ---8<
> \documentclass{article}
> \usepackage{xcolor}
> \usepackage{bookmark}
> \begin{document}
> \tableofcontents
> \newpage
> \section{One}
> \section{\color{red}Two}
> \section{Three}
> \end{document}
> --8<--
> I ran this through xelatex (texlive 2018 on windows 10-64) three times to get 
> the toc right.
> 
> There is a pdf bookmark for each section, but the second one is "redTwo" 
> instead of "Two".
> 
> Is there a way to avoid that?

The standard way to avoid that something affects the bookmarks is to
to use \texorpdfstring:

\section{\texorpdfstring{\color{red}}{}Two}
 
-- 
Ulrike Fischer 
https://www.troubleshooting-tex.de/