0

I have a latex file that have been written using:

\usepackage[utf8]{inputenc} 

In this file, there are few external files also written using this package. Now I need to put a external file that was written using:

\usepackage[latin1]{inputenc}   

Well, when i use the command:

\input{external-file} 

Shows many errors because of latin1. How can i fix it?

  • 3
    I would recommend to recode external-file. Most editors are able to recode files. Please make a backup of the file before recoding. Without recoding you can try \inputencoding{latin1}\input{external-file}\inputencoding{utf8}. – Schweinebacke Mar 31 '17 at 16:09
  • I've tried to do this, but shows errors at lines that were working well. – Junior Soares Mar 31 '17 at 17:22
  • 3
    JuniorSoares, @Schweinebacke's comment is the correct answer so if you get errors you should show the errors in the question. Note you can not input a complete document, only the body of the other documennt. – David Carlisle Mar 31 '17 at 18:20
5

I would recommend to recode the file. Before you convert the file you should make a backup!

There are several programs to do so, e.g., iconv. Some editors can also be used, e.g., Texmaker:

  • Start Texmaker and select ToolsConvert to unicode Tool selectin

  • Select the file to be converted either by typing in the filename or better by clicking to the select icon in the top right corner and selecting it in the file selection dialog: File selection

  • Click to the Convert to unicode button: Convert button

  • Click to the save icon in the top left corner of the result window: Save button I would suggest to use a new name e.g. test-utf8.tex and then change \input{test.tex} into \input{test-utf8.tex}.

If you really don't want to convert the file, you can try:

\inputencoding{latin1}
\input{external-file}
\inputencoding{utf8}

to input the latin1 file into a utf8 document. But IMHO things are more easy if all files have the same encoding.

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.