15

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{cite}
\usepackage{mathptmx}
\usepackage{times}
\usepackage{fancyhdr}
\usepackage{amsmath}
\usepackage[toc,page]{appendix}
\usepackage{color}
\usepackage{captcont}
\usepackage{graphicx}
\usepackage{hvfloat}
\usepackage{subcaption}
\usepackage{siunitx}
\usepackage{xparse}
\usepackage{caption}
\usepackage{rotating}
\usepackage{tcolorbox}
\usepackage{adjustbox}
\usepackage{blindtext}
\usepackage{booktabs}
\usepackage{float}
\usepackage{lscape}
\usepackage{gensymb}
\usepackage{ragged2e}
\usepackage[center]{titlesec}
\usepackage{sectsty}
\usepackage{lipsum}
\usepackage{afterpage}
\usepackage{parskip}
\usepackage{nomencl}
\makenomenclature
\usepackage{siunitx}
\usepackage{forest}
\renewcommand{\figurename}{Fig.}
\usepackage{indentfirst}
\setlength{\parindent}{1cm}
\usepackage [english]{babel}
\addto\captionsenglish{\renewcommand{\figurename}{Fig. }}
\usepackage [autostyle, english = american]{csquotes}
\usepackage{nameref}
\MakeOuterQuote{"}
\oddsidemargin0cm
\topmargin-2cm     %I recommend adding these three lines to increase the 
\textwidth16.5cm   %amount of usable space on the page (and save trees)
\textheight23.5cm 
\usepackage[english]{babel}
\usepackage{setspace}
\usepackage[margin=20mm,labelfont=bf]{caption}
\usepackage[left=20mm, right=20mm, top=20mm, bottom=20mm]{geometry}
\usepackage{amssymb}
\usepackage[section] {placeins}
\usepackage{verbatim}
\usepackage{wrapfig}
\usepackage{mwe,tikz,pgfplots}
\tikzset{boximg/.style={remember picture,red,thick,draw,inner sep=0pt,outer sep=0pt}}
\usetikzlibrary{shapes}
\usetikzlibrary{spy}
\usetikzlibrary{automata,positioning}
\usetikzlibrary{arrows,calc,shapes.geometric}

You help is greatly appreciated!

25

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

\UseRawInputEncoding

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.

| improve this answer | |
  • How do I declare encoding? I would like to use win1251 - default in MikTex – user1700890 Jul 14 '19 at 23:57
  • 1
    @user1700890 add \usepackage[cp1251]{inputenc} but it would be much better to use the default UTF-8 encoding for any new documents. – David Carlisle Jul 15 '19 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? – user1700890 Jul 15 '19 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 – David Carlisle Jul 15 '19 at 0:15
  • You are right, MikTex comes with Texworks. I guess I have to remember to change default in Texworks – user1700890 Jul 15 '19 at 0:56
1

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.

| improve this answer | |

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.