I installed the latest versions of MikTex and Texmaker(5.0.2) with all the necessary updates. When I run my LaTex file, I get the following error:

(! Package inputenc Error: Invalid UTF-8 byte 147.)

The same LaTex file used to work properly in the past. No idea what is going on now. I have already searched for it but have not been successful yet to fix it.

Here is the list of the packages that I use.

\usepackage [english]{babel}
\addto\captionsenglish{\renewcommand{\figurename}{Fig. }}
\usepackage [autostyle, english = american]{csquotes}
\topmargin-2cm     %I recommend adding these three lines to increase the 
\textwidth16.5cm   %amount of usable space on the page (and save trees)
\usepackage[left=20mm, right=20mm, top=20mm, bottom=20mm]{geometry}
\usepackage[section] {placeins}
\tikzset{boximg/.style={remember picture,red,thick,draw,inner sep=0pt,outer sep=0pt}}

Your help is greatly appreciated!

2 Answers 2


You have byte 147 in your file without declaring an input encoding, previously this would silently fall through and make whatever character happened to be in that position in the font encoding.

From this year latex assumes UTF-8 if no encoding is specified and so this fails,

you can add


at the start of the file, but better would be to declare the encoding that you are using.

See Latex news (issue 28) which accompanies this release.

  • How do I declare encoding? I would like to use win1251 - default in MikTex Jul 14, 2019 at 23:57
  • 2
    @user1700890 add \usepackage[cp1251]{inputenc} but it would be much better to use the default UTF-8 encoding for any new documents. Jul 15, 2019 at 0:06
  • Thank you, but why then TeXlive (comes with MikTex) defaults to Win-1251? Is this simple default that I should change or there are some deep reasons? Jul 15, 2019 at 0:10
  • @user1700890 latex defaults to utf8 your editor may have a different encoding, do you mean texworks, texlive does not come with miktex, it is an alternative to miktex. I don't use miktex so can not give details Jul 15, 2019 at 0:15
  • You are right, MikTex comes with Texworks. I guess I have to remember to change default in Texworks Jul 15, 2019 at 0:56

I had the same problem and guessed that my file was carring on some bad character encoding even though my text editor was telling me that file encoding was utf-8. I opened the file with a normal text editor (notepad++) changed the encoding from utf-8 to ANSI; saved the file; came back to utf-8 again and saved. After this operation I opened again the file with my latex editor and got the problem solved. Some letters with accent went lost, but that was a minor issue easy to fix. Hope this can help.

  • did not work for me Feb 5, 2021 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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