xelatex, revtex4-2 vs article, CID mapping destroyed after gs-based concatenation
Norbert Preining <[email protected]> Mon, 12 Jan 2026 18:49:10 +0100
| Newsgroups | gmane.comp.tex.texhax |
|---|---|
| Message-ID | <aWU0FrPBQnCMl-xo@burischnitzel> |
Hi all,
I have posted this already on SX
https://tex.stackexchange.com/questions/758136/xelatex-and-ghostscript-based-concatenation-drops-cid-mapping-with-revtex-4-2
but here now, too:
The following test file:
```
\documentclass{revtex4-2}
\begin{document}
efficient
\end{document}
```
when compiled with `xelatex` and combined with itself (or any other PDF file) using ghostscript as in
```
gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -sOutputFile=foo.pdf file1.pdf file1.pdf
```
produces a broken text mapping, as seen when running txt2pdf.py (from pdfminer-six) or copy-pasting the word
```
$ pdf2txt.py foo.pdf
e(cid:123)cient
1
e(cid:123)cient
1
```
Now, when I use `article` documentclass, everything works and pdf2txt.py returns:
```
efficient
1
efficient
1
```
(mind the unicode ff ligature)
Has anyone an idea where to search for what `revtex4-2.cls` is doing wrongly?
Thanks
[2026-01-12] Additional finding: Decompressing the pdf files, I see the following differences:
* between the original (pre-concatenation) PDF (left = revtex4-2, right=article) the text representation/generation has changed:
```
stream
- q 1 0 0 1 72 769.89 cm 0 G 0 g BT /F1 9.9626 Tf 485.113 35.866 Td[<0052>]TJ -493.15 -25.903 Td[<0032007b002b00420032004d>28<0069>]TJ ET Q
+ q 1 0 0 1 72 769.89 cm 0 G 0 g BT /F1 9.9626 Tf 76.712 -62.765 Td[<0032007b002b00420032004d>27<0069>]TJ 154.421 -567.87 Td[<0052>]TJ ET Q
endstream
```
Looking at the uncompressed PDFs **after** concatenation, I clearly see that the CID map has changed:
```
@@ -192,13 +192,14 @@
1 begincodespacerange
<0000><ffff>
endcodespacerange
-6 beginbfrange
+7 beginbfrange
<002b><002b><0063>
<0032><0032><0065>
<0042><0042><0069>
<004d><004d><006e>
<0052><0052><0031>
<0069><0069><0074>
+<007b><007b><fb000069>
endbfrange
endcmap
CMapName currentdict /CMap defineresource pop
```
So it seems some settings in revtex4-2 does change how text ends up in the PDF.
Note that both pdfs contain the same fonts in the same encodings (only the random font prefix has changed).
Thanks for any insight!
Best regards
Norbert
--
DI Dr Norbert Preining https://www.preining.info
arXiv / Cornell University + IFMGA Guide + TU Wien + TeX Live
GPG: 0x860CDC13 fp: F7D8 A928 26E3 16A1 9FA0 ACF0 6CAC A448 860C DC13