0

I have a big table that containing the Unicode character "±". If I put this table on my main tex file, there is no problem. But when I put it in another tex file and try to \input{} it, then I got the error:

Package inputenc Error: Invalid UTF-8 byte "B1. Soybean & 0.393\newline{}�

Hope someone can help to solve this problem.

Thank you

3
  • 1
    Welcome to TeX.SE! Without seeing document example with your code is difficult to say, what is going wrong in your document. Please show us a small, but compilable document with your table directly in it. For table is sufficient that contain only a row with simbol, which cause your problem, How you compile your document?
    – Zarko
    Feb 21, 2021 at 7:50
  • Are you in a position to switch from pdfLaTeX to either XeLaTeX or LuaLaTeX?
    – Mico
    Feb 21, 2021 at 8:03
  • @Zarko actually it isn't easy to post an example of this error as you can not post a file with invalid UTF-8 on the site. Feb 21, 2021 at 9:48

1 Answer 1

2

Almost certainly the file you are inputting is saved in the encoding iso-859-1 (latin-1) not the Unicode UTF-8 encoding. In latin-1, ± is the single byte B1 and pdflatex will give the error you state if you try to decode the file as utf-8 (where ± is the two bytes C2 B1)

This will not be related to \input, the file where it works will either be an old latex version (which did nt assume UTF-8 by default) or will have \usepackage[latin1]{inputenc} to tell LaTeX to use Latin 1.

So either use your editor to save the file as UTF-8 or tell LaTeX to use latin-1 by loading inputenc as above.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .