Tell me more ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'll try to explain my problem here. I know that there are many posts dealing with this but I'm still confused.

We have many files from different machines with different systems. The important is:

  1. the tex file will be compiled on a Linux machine with utf-8.
  2. the tex files comes from many Windows machines with iso.

Without converting, is there some good preamble to solve my problem?

For example, on Windows Vista, using Winedt to produce a tex file encoded in iso, is there some package which allows me to run pdflatex on a Linux machine with Kile and utf-8?

This will be a big project with a lot of people sending many tex files to me and I'd like to create a good template with necessary packages to avoid confusions.

share|improve this question
It doesn't matter what machine a file comes from; if it's Latin-1 encoded, just having \usepackage[latin1]{inputenc} in it is sufficient. – egreg Jan 8 at 13:40
@egreg, suppose that I receive 2 files from Windows machine produced with iso and with inputenc loaded, as you wrote. Can I copy some parts and paste to my file and edit and compile on my Linux? Or your comments only works to compile each file separately? – Sigur Jan 8 at 13:44
1  
I believe that Kile is able to detect the encoding of a file. If you open the Windows file, check that the characters are correct, select all, copy and paste in the window where the UTF-8 file is opened. The machine should do the conversion. Or just decide for one encoding. I believe that recent versions of WinEdt are able to cope with UTF-8, so this would be the best choice. – egreg Jan 8 at 13:48
1  
@egreg can we have multiple encodings,say \include{iso-latin1.tex} and \include{utf-8.tex} in a single project.tex like this ? – texenthusiast Jan 8 at 13:55
3  
Yes, just use \inputencoding{latin1}\input{fileinlatin1}\inputencoding{utf8}. But working with multiple encodings is better avoided. – egreg Jan 8 at 13:57
show 2 more comments

1 Answer

In collaborative projects with source files being edited on a variety of platforms, editors, and locales, encoding issues can become a real PITA.

In such setting, it is best to define one "right", mandatory encoding (UTF-8), communicate this clearly and stick to it. However, in many cases the collaborators, especially if they stem from the Windows or Mac world, do not even know what an encoding is. What, however, works reasonably well in practice, is the following.

  1. Prepare templates that already are in the right encoding, including (if appropriate) the \usepackage[utf8]{inputenc} line. The template also should (at least in some comment), contain some UTF-8 characters: Many modern editors have reasonably good heuristics to detect the encoding "automagically" if non-ASCII characters are present.

  2. Provide editor modelines for as many editors as possible. Many editors, including WinEdt and TeXShop, provide a modeline syntax that can also be used to specify the encoding explicitly. Many other support either the vim or emacs modeline syntax, so those should always be present. But of course, there are more.

The following document header includes some UTF-8 characters and modeline commands to set the file type (for syntax coloring) to TeX/LaTeX and the encoding to UTF-8 for: vim, WinEdt, TexShop, Emacs, and Kate:

% vim: set fenc=utf-8 ft=latex
% !Mode:: "TeX::UTF-8"
% !TEX encoding = UTF-8 Unicode 
% -*- mode: latex; coding: UTF-8; -*-
% kate: encoding utf-8;
%
% IMPORTANT Note: This file is UTF-8 encoded! 
%                 You should see some umlauts here: ÄÖÜäöü 

The Kate modeline might also work for Texmaker, as both are based on the generic Qt editor component, but I have not checked this. For most editors, modelines have to appear in the first 10 lines of a document, some (Vim, Emacs) also support them at the end of the document (within the last 10 lines).

share|improve this answer
If anybody knows the respective modelines of other editors than the mentioned: Please tell (or edit it into the answer :-) – Daniel Jan 23 at 20:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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