3

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.

8
  • I believe that the files generated by R are not UTF-8 encoded.
    – egreg
    Nov 30, 2013 at 23:39
  • @egreg ok, is there anything I can do about this?
    – TomM
    Nov 30, 2013 at 23:40
  • 2
    Try convincing R to output UTF-8 encoded files.
    – egreg
    Nov 30, 2013 at 23:42
  • @egreg 'Convincing'? How :)
    – TomM
    Nov 30, 2013 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}} Dec 1, 2013 at 0:22

1 Answer 1

4

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}} 
2
  • 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, 2013 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. Dec 1, 2013 at 14:15

You must log in to answer this question.

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