9

"Never ever use non-ASCII characters and spaces in your filenames. Never!"

That's what I'm telling my students for years. But if for any reasons there is an urgent need to include an image file with umlauts in its filename, the grffile package could be used.

Unfortunately, I was not able to get the following example compiled:

\documentclass{article}

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

\usepackage{graphicx}
\usepackage[extendedchars]{grffile}

\begin{document}

\includegraphics{Bäckerstraße}

\end{document}

I'm using MiKTeX (recently updated) upon Windows 7. My MWE is saved in Cp1252 Windows encoding. The same is valid for the existing file Bäckerstraße.png on my file system.

I compiled with pdflatex. The compilation produces no PDF output with no error message in the log file. The compilations stops with an error message in the command shell:

pdflatex: Windows API error 1113: F��r das Unicode-Zeichen ist kein zugeordnetes Zeichen in der Mehrbytecodepage vorhanden.

I googled for this problem and found some forum discussion from 2011 and 2012 indicating that this could be a general pdflatex problem using MiKTeX.

I'm asking, if there is just a dumb error of mine inside the MWE code or if there is just no chance to run this with MiKTeX.

If there is an error in the MWE, please, let me know how to correct it. But if this cannot run at all, please, stop me wasting time trying.

  • Well, under Linux it works without problems... –  Nov 23 '14 at 10:36
  • @ChristianHupfer I think this could be MiKTeX-specific. http://www.mrunix.de/forums/showthread.php?71899-graphicx-Umlaut-im-dateinamen-Miktex-Versionsproblem contains some discussion in this direction (dating from 2011). – Thomas F. Sturm Nov 23 '14 at 10:41
  • Unfortunately I can't test your issue more specifically... I neither use MikTeX nor Windows (;-)) –  Nov 23 '14 at 10:42
  • No, miktex doesn't like non-ascii-chars (imho the problem did disappear sometime ago and then reappeared again). I wouldn't waste time on it. – Ulrike Fischer Nov 23 '14 at 10:42
  • @UlrikeFischer Thank you for the information. I thought I could try some nice LaTeX image examples before sunday lunch, but this obviously was a bad idea. If you provide your comment as an answer, I will accept it. – Thomas F. Sturm Nov 23 '14 at 10:55
  • What happens if you recode to UTF-8? – Heiko Oberdiek Nov 23 '14 at 11:15
  • @HeikoOberdiek Recoding the MWE in UTF-8 seems to work! – Thomas F. Sturm Nov 23 '14 at 11:42
  • @HeikoOberdiek I found the solution for latin1. I have to use \usepackage[encoding,filenameencoding=utf-8]{grffile}. I thought that UTF-8 filename encoding would be wrong for Windows, but this option setting works. – Thomas F. Sturm Nov 23 '14 at 11:52

1 Answers1

7

Since the file name encoding seems to be UTF-8, the file name needs to be reencoded from Latin-1 to UTF-8. This is also supported by package grffile:

\documentclass{article}

\usepackage[latin1]{inputenc}
\usepackage{graphicx}
\usepackage[encoding,filenameencoding=utf8]{grffile}

\begin{document}
\includegraphics{Bäckerstraße}
\end{document}

Alternatively the TeX source could be encoded in UTF-8 entirely.

BTW, the full range of code page for CP 1252 is provided by options ansinew or x-cp1252 for package inputenc (the latter option comes from package inputenx and can be used as cp1252 there).

Heiko Oberdiek
  • 271,626