Take the 2-minute tour ×
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 got a problem with inputenc[utf8]. My document is in German and uses 'ä, ö, ü' which usually works fine with the following preamble:

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

I am using Texstudio for writing my document if that matters. The external tex files are only xtables produced by R. These are saved as .tex files, and put into my document via the \input{./file.tex} function. This also works well. The problem is, when I add captions in German to the tables (e.g. sthg like 'ääääääää'), the following error results when compiling:

Package inputenc Error: Unicode char \u8:ä not set up for use with LaTeX ...

Is there any way I can circumvent this? I have the feeling the problem is that the above preamble is not part of tables produced by xtable in R. These have the following simple format (not separate preamble, just the following):

% latex table generated in R 3.0.1 by xtable 1.7-1 package
% Sat Nov 28 00:05:12 2013
\begin{table}[htbp]
\caption{ääää}
\begin{tabular}{ l c r }
 1 & 2 & 3 \\
 4 & 5 & 6 
\end{tabular}
\end{table}

But then again these files should be included into the original document via the input-function just fine? I dont get the problem. You can test this hopefully by saving the above table under a separate tex file, then including it at the beginning of the document:

\documentclass[a4paper]{scrreprt}
\usepackage{setspace}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

\begin{document}
\input{./file.tex} % assuming you called it 'file'
\end document

Thanks for any hints. I am using Win 7 x64 and Miktex 2.9.

share|improve this question
    
I believe that the files generated by R are not UTF-8 encoded. –  egreg Nov 30 '13 at 23:39
    
@egreg ok, is there anything I can do about this? –  TomM Nov 30 '13 at 23:40
2  
Try convincing R to output UTF-8 encoded files. –  egreg Nov 30 '13 at 23:42
    
@egreg 'Convincing'? How :) –  TomM Nov 30 '13 at 23:46
1  
If you can not save the files in UTF8 just tell LaTeX what encoding they are in, most likely {\inputencoding{latin1}\input{file.tex}} –  David Carlisle Dec 1 '13 at 0:22

1 Answer 1

up vote 3 down vote accepted

If you can not save the files in UTF8 just tell LaTeX what encoding they are in, most likely latin1 (ISO-8859-1) so:

{\inputencoding{latin1}\input{file.tex}} 
share|improve this answer
    
Ok, one last question: Does that lead to a common encoding[utf8] in my final document? Or in other words, is the input different from the rest of the document? –  TomM Dec 1 '13 at 13:18
1  
Yes it is a local declaration, the purpose of the outer {..} in the code in the answer is to limit the scope of the encoding change so it reverts to utf8 at the } after the input. –  David Carlisle Dec 1 '13 at 14:15

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.