Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there anyway to find and remove ligatures from tex file? Sometimes when I copy/paste a text to Winedt, it shows perfect, but when I compile it to Pdf, some issues appear, e.g. finding becomes nding.

I am wondering if there is any way to search and find these characters?

Here is an example file (needs utf8 encoding).

\documentclass{article}
\begin{document}
fi
\end{document}
share|improve this question
    
To be clear, are you saying that you copy 'finding' from a pdf into winedt and it displays ok, but problems occur when you compile the resulting code? If so, do you get any warnings in the log file? –  Ian Thompson Jun 2 at 12:38
    
I don't think that is a winedt problem, but your used font and its ability to use ligatures. Try to paste the characters in a plaintext-editor (like notepad) instead winedt, I bet there are no ligatures. –  musicman Jun 2 at 13:23
    
No, when I copy finding from word to latex, it won't appear correctly when it is compiled. I have to delete fi and type it again to fix it. I realise when this happens, fi is as one character and not two! So I'd like to know if there is anyway to search and find these characters in Winedt? (of course, nothing wrong with Win edt) –  M0HS3N Jun 2 at 13:32
    
i assume you're talking about copying from a tex-sourced pdf, rather than a "tex file" (such as .tex or .dvi). if i'm right, i guess you need the cmap or mmap packages. [note, i'm not clear about the difference between those two, and would welcome enlightenment.] –  wasteofspace Jun 2 at 13:45
    
so no way to just find and remove them from tex file? –  M0HS3N Jun 2 at 14:10

2 Answers 2

up vote 7 down vote accepted

This is commonly due to bad font information, but is solvable. The ligatures that can give problems are , if a modern font is used.

You can solve at once your problem with

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

%% use this in your preamble
\usepackage{newunicodechar}
\newunicodechar{ff}{ff}
\newunicodechar{fi}{fi}
\newunicodechar{fl}{fl}
\newunicodechar{ffi}{ffi}
\newunicodechar{ffl}{ffl}
%% end of common ligatures

\begin{document}
ff fi fl ffi ffl
\end{document}

The relevant code is between the two %% prefixed lines. Just keep it at hand and paste it when needed.

enter image description here

A “search and replace” can be better, for the production version of the document.

share|improve this answer

If you add \usepackage[utf8]{inputenc} to your preamble, the ligatures in the code will generate errors. There may be a lot, but there are (I think) only a few distinct cases. With inputenc in your preamble, run pdflatex. It will stop on the first ligature, and entering 'e' should take you to it. Copy the ligature and do a global find and replace, e.g. changing to fi. Repeat for the other ligatures and the problem is solved. Not entirely automatic, but it shouldn't take too long.

share|improve this answer
1  
\usepackage{newunicodechar}\newunicodechar{fi}{fi} –  egreg Jun 2 at 16:30
    
@egreg --- Nice. I didn't know that one. –  Ian Thompson Jun 2 at 16:33
    
I am supposed to know about the package. ;-) –  egreg Jun 2 at 16:40
    
great thank you! –  M0HS3N Jun 2 at 21:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.