Path: ...!newsreader4.netcologne.de!news.netcologne.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Ulrike Fischer Newsgroups: fr.comp.text.tex Subject: Re: =?utf-8?Q?=C3=89crire_un_document_avec_plusieur_codage_=E2=80=A6?= Date: Tue, 25 Jan 2022 23:58:34 +0100 Lines: 64 Message-ID: <18ycx59f6johh.dlg@nililand.de> References: Reply-To: news3@nililand.de Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Trace: individual.net 44jYs6r4QphHAmEX6vTEagOeK9FrcsMGjETyKVxtJ0RCH9s0Ys Cancel-Lock: sha1:lLvdl2d0+O8jkwCTWisbReG8bc8= User-Agent: 40tude_Dialog/2.0.15.41de Bytes: 2362 Am Tue, 25 Jan 2022 19:56:56 +0100 schrieb Vincent Belaïche: > J'essaie d'écrire un document qui pour le plus gros est en latin-9, mais > quand lequel j'insère un fichier qui est en utf-8 et qui comprend > plusieurs rubriques. > > Je fais un truc du genre : > > --------8<-----------8<-----------8<-----------8<-----------8<------- > % !TEX encoding = IsoLatin9 > \documentclass{article} > \usepackage[utf8,latin9]{inputenc} > \begin{document} > \tableofcontents > > \section{En français} > trâlâlâ > > \inputencoding{utf8}\addtocontents{toc}{\protect\inputencoding{utf8}} > \input le-vilain-doc-en-utf8 > \inputencoding{latin9}\addtocontents{toc}{\protect\inputencoding{latin9}} > > \section{Encore en français} > trâlâlâ > > \end{document} > > Mais ça ne fonctionne pas … j'ai un truc du genre : > > --------8<-----------8<-----------8<-----------8<-----------8<------- > ERROR: Package inputenc Error: Invalid UTF-8 byte sequence. > --------8<-----------8<-----------8<-----------8<-----------8<------- utf8 contains global definitions, while latin9 has local definitions. As the table of contents builds a group some of the utf8 definitions survive. Something like this should work \documentclass{article} \usepackage[latin9]{inputenc} \begin{document} \tableofcontents \inputencoding{utf8} \inputencoding{latin9} \section{En français} trâlâlâ .... (both \inputencoding are needed to force a real switch) -- Ulrike Fischer https://www.troubleshooting-tex.de/