1

This is a strange bug. I'm using the textpos package (which in turn uses the everyshi package) to place text at a certain position on the page. Consider this document:

% !TEX TS-program = lualatex
\documentclass{article}
\usepackage[absolute]{textpos}
\usepackage{fontspec}
\setmainfont[Renderer=HarfBuzz,Script=Devanagari]{Chandas}

\begin{document}

% package textpos uses \paperheight and \paperwidth \paperheight=1561bp \paperwidth=1044bp \TPGrid{1044}{1561} \begin{textblock}{200}(173,213) added later किं बहुना । परस्परं द्वैधम् उत्पन्नम् । added later \end{textblock}

Some text. \newbox\foo \setbox\foo=\vbox{\hbox{boxed किं बहुना । परस्परं द्वैधम् उत्पन्नम् । boxed}}

inline किं बहुना । परस्परं द्वैधम् उत्पन्नम् । and also below \unvbox\foo

\end{document}

(The Chandas font is from here.) The resulting PDF looks like:

result

The Devanagari text is the same in all three places. As in my previous question Getting correct searchable text for Devanagari text, everything works fine (when compiled with lualatex from Tex Live 2020: see on Overleaf) i.e. selecting and copying text from the PDF gives correct results, for the inline text and for the manually unvboxed text,

inline किं बहुना । परस्परं द्वैधम् उत्पन्नम्। and also below

boxed किं बहुना । परस्परं द्वैधम् उत्पन्नम्। boxed

but for the text added later with textpos, I get:

added later ��� बहु�� । परस्पर� ��ध�� उत्पन्न�� । added later

What could be the reason? Is there a fix?

ShreevatsaR
  • 45,428
  • 10
  • 117
  • 149
  • I see a previous question that may be related, but it has no details and it is at -1 and the OP's answer mentions AtEveryPageHook which as far as I can tell doesn't exist and probably cannot be used for this use-case anyway. – ShreevatsaR Sep 13 '20 at 17:12
  • Looks like everyshi is only 32 lines of well-motivated and self-contained code... – ShreevatsaR Sep 13 '20 at 17:20
  • 1
    I see no difference in the copy&paste behaviour. Unrelated: everyshi will be replaced by kernel code in the next latex release. The textpos code is currently not compatible and will break. The maintainer has been informed some weeks ago, but I don't know when he will update. – Ulrike Fischer Sep 13 '20 at 17:36
  • @UlrikeFischer Thanks for taking a look…. Do you get broken results in both cases or are both fine? I've uploaded the resulting PDF (from "This is LuaHBTeX, Version 1.12.0 (TeX Live 2020)" on macOS); are your results different? – ShreevatsaR Sep 13 '20 at 18:01
  • 1
    I see now a difference, but only in adobe reader. But I see also the difference in the pdf code. I need to discuss this with Marcel. – Ulrike Fischer Sep 13 '20 at 18:24
  • @UlrikeFischer Thanks, glad to know it's not just my system. Hopefully the reason can be found/fixed. Meanwhile I found a workaround by specifying the ActualText manually, as in this answer — maybe there's a simpler way now, but that worked for me. – ShreevatsaR Sep 16 '20 at 07:10
  • @UlrikeFischer Just curious, did you discuss / did anything come out of this? Wondering whether there's a bug somewhere and whether there's an easier workaround now… – ShreevatsaR Dec 16 '20 at 18:48
  • @UlrikeFischer Ah I see there was some discussion here… but I'm not sure of the conclusion. Anyway the workaround seems to work for me for now, so it's not a major problem for me. Sorry for the noise. – ShreevatsaR Dec 16 '20 at 19:05
  • yes, we discussed it, and there is also already some code to extend the latex hooks, but we need to add it to the development version.Btw: setting box 255 doesn't work in a current latex. Better use the latex shipout hooks instead of this low-level manipulations. – Ulrike Fischer Dec 16 '20 at 19:10
  • @UlrikeFischer Oh that's good to know, thanks. (Also I wasn't setting box255 manually actually but this MWE was from unwrapping what the textpos package was doing… I guess it too must have been updated now.) – ShreevatsaR Dec 16 '20 at 19:22
  • the pull request (at least some part of discussion) it here https://github.com/latex3/latex2e/pull/396 – Ulrike Fischer Dec 16 '20 at 19:28
  • @UlrikeFischer Looks like the above pull request was merged in January, so maybe this is fixed in TeX Live 2021. Haven't tested it yet though. – ShreevatsaR Apr 06 '21 at 20:43
  • Your example no longer compiles as you can't use box 255, but if I replace 255 by \ShipoutBox all text copies fine (but you should better not use everyshi but the shipout hooks instead). – Ulrike Fischer Apr 06 '21 at 20:56
  • @UlrikeFischer Thanks that's great to know! As I had mentioned earlier, I was using textpos and had replaced it with everyshi for debugging before asking the question, so I edited the question just now to use the original syntax I had been using. I guess textpos has also been updated now and will no longer have the error (all text will copy fine). Thank you! Could you post that as an answer so that I can accept it and get this question off the Unanswered list? – ShreevatsaR Apr 06 '21 at 22:33

0 Answers0