# Finding/Removing ligature from Tex

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}
ﬁ
\end{document}

-
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

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}
\newunicodechar{ﬁ}{fi}
\newunicodechar{ﬂ}{fl}
\newunicodechar{ﬃ}{ffi}
\newunicodechar{ﬄ}{ffl}
%% end of common ligatures

\begin{document}
ﬀ ﬁ ﬂ ﬃ ﬄ
\end{document}


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

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

-

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.

-
\usepackage{newunicodechar}\newunicodechar{ﬁ}{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