# How to \input{} files with Unicode names?

I work in Linux with the latest TeX Live. The system encoding is UTF-8. It is also the default editor encoding in my TeXstudio 2.12.8.

I have figures in files like σ_1_μ_02_per_5.tikz, and I included them using \input{}.

Now, the most interesting part: it had worked fine (even without inputenc etc), then it just stopped. I have not change a single line in my files. Now I get

Package inputenc Error:
Unicode character σ (U+3C3)(inputenc) not set up for use with LaTeX.
...σ_1_μ_02_per_5.tikz


I have tried:

• using babel
• inputenc with utf8, utf8x, latin1
• fontenc with different parameters
• opening and saving in UTF-8 in other editors

And in this case I get:

Undefined control sequence. ...μ_02_per_5.tikz}
Missing \$ inserted. ...μ_02_per_5.tikz}
Double subscript. ...μ_02_per_5.tikz}
Undefined control sequence. ...μ_02_per_5.tikz}


How to fix this?

Minimal not working example:

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\begin{document}
\input{1.tex}
\input{σ.tex}
\end{document}

• try compiling with xelatex. as a rule of thumb, it's ill advised to use such characters in file names, as they might end up on other systems which can not deal with them. – naphaneal Jun 25 '18 at 17:06
• The simplest way is use a UTF-8 native engine such as lualatex or xelatex. As @naphaneal notes, such characters can cause problems. It's also advisable to not use spaces or underscores in filenames. As a workaround for pdflatex you can use \input{\detokenize{σ.tex}} – Alan Munn Jun 25 '18 at 17:06
• btw, the .tex extension is not required for \input. – Alan Munn Jun 25 '18 at 17:13
• It is not only Greek letters, try with \input{é} (or the equivalent \input{é.tex}.) This was already case with TL2017 and earlier and \usepackage[utf8]{inputenc} or even \usepackage[latin1]{inputenc}. And the \detokenize workaround was applied already then in those old times. – user4686 Jun 25 '18 at 17:14
• @homocomputeris use the \detokenize workaround and don't modify your set-up. – user4686 Jun 25 '18 at 17:19

Such file names have never worked if you are using inputenc to allow the use of the characters in input to typeset text. It would previously have worked if you were using the old default raw 8-bit default input as the bytes just passed through and were then interpreted as UTF-8 by the filesystem

With the current LaTeX release inputenc UTF-8 handling is assumed by default.

As Alan commented above you can use

\input{\detokenize{σ.tex}}


to allow the filenames even after UTF-8 inputenc processing has been loaded.

Hopefully in a future release the \detokenize won't be necessary, but it will always work.

• Although I don't completely understand the 'byte passing' part, this is the answer, as are the comments above. Is it possible to renew the input command to work with detokenize? – homocomputeris Jun 25 '18 at 17:26
• @homocomputeris sure but I wouldn't as while I can be fairly sure the above form will work in future if you redefine it to apply detokenize automatically it may not, and several other packages will break because \input{\myfile} will try to input \myfile.tex not whatever name the comand \myfile expands to. You can however safely do \newcommand\myinput[1]{\input{\detokenize{#1}} then \myinputσ.tex} – David Carlisle Jun 25 '18 at 17:59