5
\documentclass{article}
\usepackage[T1,OT4]{fontenc}
\begin{document}
Text with \_.
\end{document}

In PDF there is a correct output: Text with _.
But when I select and copy it I get: Text with .

It happens on Adobe Reader, Foxit Reader and on Sumatra PDF so I think it is not a reader issue.

How can it be fixed?

5
  • WHy do you need the two encodings (OT4 and T1)? Aug 27, 2012 at 12:19
  • I really don't know :P. I have always had T1 and OT4 in my docs...
    – Ichibann
    Aug 27, 2012 at 12:23
  • I've added a remark to my answer. Aug 27, 2012 at 12:25
  • 1
    @Ichibann The T1 encoding has complete coverage for Polish diacritics. There is no need for OT4 for typesetting Polish.
    – egreg
    Aug 27, 2012 at 14:08
  • It's 2012. Go Unicode and use XeLaTeX or LuaLaTeX and forget about encodings. Aug 27, 2012 at 21:01

2 Answers 2

3

Change to

\usepackage[OT4,T1]{fontenc}

As far as I can see it, you don't really need the OT4 encoding; according to this remark from the fontenc documentation referring to OT4:

While Knuth included the means of typesetting the ‘lost L’ (Ł) in his OT1 encoding, he omitted the ogonek, a diacritic mark that is also needed in Polish text; hence the appearance, well before the T1 encoding, of fonts using this encoding.

So you can simply say

\usepackage[T1]{fontenc}
3
  • I have \usepackage[T1,OT4]{fontenc} in my real document. I think I need OT4.
    – Ichibann
    Aug 27, 2012 at 12:12
  • @Ichibann use \usepackage[OT4,T1]{fontenc}; by the way, you should have mentioned this in the question. Aug 27, 2012 at 12:14
  • Gonzalo, I didn't know it was causing the problem. I tried to make a real MWE. So I removed everything that didn't change the output. This included \usepackage[T1,OT4]{fontenc}.
    – Ichibann
    Aug 27, 2012 at 12:16
6

"Old" fontencodings like OT1 or OT4 don't have a glyph for \_ (\textunderscore), they use the default defined in the kernel which is a small rule. But you can change this default so that the glyph from the T1-encoding is used instead:

\documentclass{article}
\usepackage[T1,OT4]{fontenc}
\DeclareTextSymbolDefault{\textunderscore}{T1}
\begin{document}
Text with \_.
\end{document}

You must log in to answer this question.

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