Fonts & Character SetsCharacters bugged in PDF document

Information and discussion about fonts and character sets (e.g. how to use language specific characters)
Post Reply
crispy_chunks
Posts: 11
Joined: Wed Oct 27, 2010 2:59 pm

Characters bugged in PDF document

Post by crispy_chunks »

Hello,

For some reason copying a line from a PDF document generated by pdflatex in kile yields some corrupted text. Everything looks right in the pdf document, but when copying and pasting from it (using evince or okular pdf readers) text like this comes outlike this: en initi—l —ttempt using simil—r

In the pdf document it reads like this: An initial attempt using similar

Here is the preamble:

Code: Select all

\documentclass[a4paper,11pt]{report}
\usepackage[T1]{fontenc}
\usepackage{achemso}
\usepackage{wrapfig}
\usepackage{graphicx}
\usepackage[runs=2]{auto-pst-pdf}
\usepackage{chemstyle}
\usepackage{bpchem}
\usepackage[utf8x]{inputenc}
\usepackage{setspace}
\usepackage{caption}
\usepackage{floatrow}
\newcommand{\picscale}{0.85}
\newcommand{\tinypicscale}{2.125} % These images are scaled to 40% in ChemDraw from ACS standard and saved as 300 dpi eps.
\usepackage[referable]{threeparttablex}
\usepackage{longtable,booktabs}
\usepackage{subfig}
\usepackage{pdfpages}
\renewcommand{\thefootnote}{\fnsymbol{footnote}}
\usepackage{array}
\usepackage{multirow}
\setTableNoteFont{\footnotesize}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Characters bugged in PDF document

Post by frabjous »

Please provide a minimal working example rather than a preamble. I tested your preamble adding only:

Code: Select all

\begin{document}
an initial attempt using similar
\end{document}
And it worked just fine when I copied and pasted from evince.

In addition to a minimal working example (and do make it minimal--remove unnecessary packages, etc.) you might also try uploading the resulting PDF here to see if the problem might be on the other end of things.
crispy_chunks
Posts: 11
Joined: Wed Oct 27, 2010 2:59 pm

Re: Characters bugged in PDF document

Post by crispy_chunks »

Its very hard to provide a minimal working example to reproduce a bug that I don't know how to reproduce.

Anyways, all the text I had was in 3 chapters which I imported. I commented out the imports and wrote a line or two and ran pdflatex. After commenting in and out different sections of my chapters I copied something from the PDF file again. This time only double f's (ff) were bugged. Now I restored the original document and all text (except for ff's) look fine when I copy.

Oh, actually f's are gone also. ff's leave a blank square (kind of)
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Characters bugged in PDF document

Post by frabjous »

crispy_chunks wrote:Its very hard to provide a minimal working example to reproduce a bug that I don't know how to reproduce.
Then consider how hard it would be for someone else to try to diagnose and solve such a thing!
kaiserkarl13
Posts: 707
Joined: Tue Mar 25, 2008 5:02 pm

Characters bugged in PDF document

Post by kaiserkarl13 »

The ff, fl, and fi problems are due to TeX substituting ligatures for those letters. Look very closely at the PDF; the word "file" will have the f and the i joined together, and the word "riffing" will have the two f's AND the i joined together. This is normal behavior in a PDF, but Evince and other PDF interpreters may not realize what's going on and try to insert the special "fi" or "ff" characters into your document.

You can see what I mean in the following example:

Code: Select all

\documentclass{article}
\begin{document}
\noindent
Here are the words as usual:  influence, file, affable, affianced, affluent.
\\ \\
Here are the same words without ligatures:  inf{}luence, f{}ile, af{}fable, af{}f{}ianced, af{}f{}luent.
\end{document}
crispy_chunks
Posts: 11
Joined: Wed Oct 27, 2010 2:59 pm

Characters bugged in PDF document

Post by crispy_chunks »

frabjous wrote:
crispy_chunks wrote:Its very hard to provide a minimal working example to reproduce a bug that I don't know how to reproduce.
Then consider how hard it would be for someone else to try to diagnose and solve such a thing!
I did. But the minimal working example I have is 50 pages long then. Another thing to consider is that it was actually not my latex code that seemed to be the problem as compiling an empty document and adding the parts again did not (completely) reproduce the problem.
crispy_chunks
Posts: 11
Joined: Wed Oct 27, 2010 2:59 pm

Characters bugged in PDF document

Post by crispy_chunks »

kaiserkarl13 wrote:The ff, fl, and fi problems are due to TeX substituting ligatures for those letters. Look very closely at the PDF; the word "file" will have the f and the i joined together, and the word "riffing" will have the two f's AND the i joined together. This is normal behavior in a PDF, but Evince and other PDF interpreters may not realize what's going on and try to insert the special "fi" or "ff" characters into your document.

You can see what I mean in the following example:

Code: Select all

\documentclass{article}
\begin{document}
\noindent
Here are the words as usual:  influence, file, affable, affianced, affluent.
\\ \\
Here are the same words without ligatures:  inf{}luence, f{}ile, af{}fable, af{}f{}ianced, af{}f{}luent.
\end{document}
I understand. But that still doesnt explain why the initial sentence I posted had it's a's missing, but after compiling an (almost) empty document and adding the section again, the text was normal.
crispy_chunks
Posts: 11
Joined: Wed Oct 27, 2010 2:59 pm

Re: Characters bugged in PDF document

Post by crispy_chunks »

I have also discovered that removing the \usepackage[T1]{fontenc} in the preamble made all text good (except > and < shows up as upside down ? and ! in the pdf).

Problem is I added that because I need to write a bold L in smallcaps (some chemistry formatting rules :p), and the standard font that is used instead does not have bold smallcaps.
Last edited by crispy_chunks on Tue May 31, 2011 10:00 pm, edited 1 time in total.
Post Reply