I cannot get LaTeX to recognize special danish characters in input files, even though it recognizes them completely fine when I write them in the .tex file. I use the Danish characters 'æ' 'ø' and 'å'.
There is no error if I just remove the \input{mytextwithæøå.txt} from my document, so there is nothing wrong with my preamble. I just don't know what I need to do, to have the characters recognized.
Addendum:
I forgot to mention, that if i just change the special characters in the input file, the problem also goes away. Just to nail it down completely, that the issue is the recognition of special characters in input files (both in text and in file name).
Your problem is broader than LaTeX. LaTeX is not able to encode such special characters within commands like \input or \includegraphics (although the grffile package can sometimes be of help for the latter).
Personally I would just stick to the conventional characters [a-z][A-Z][0-9], - and _ in file names.
Alright, I can easily avoid using those characters in filenames, but what about content? Because it also complains when the text itself contains æ ø å even though it is completely fine with them, if I write them in the .tex document itself.
Provide a self-contained and minimal example that shows the problem clearly. Special characters in other languages than English usually need a package like selinput (from the oberdiek bundle) or inputenc.
If you make a txt file, and copy the three letters æ ø å inside, you'll find that you get an error. But if you remove the \input{text.txt} and just run it, it writes the three letters just fine within the document.
The problem is; How do I get latex to recognize special characters within txt files. Because it clearly knows them within the .tex file itself.
Make sure that the master file and the input file have the same file encoding (UTF-8 here). If that doesn't help, attach both generated files to your next post in order to make the problem comprehensible for others.
I have no clue how to make a .txt file any other encoding than what it is. I don't know what you mean by "both generated files". I have two files I have created: The minimal.tex that contain the following code:
and the text.txt within which I have just written the three characters æ ø å.
I just want latex to recognize those three characters inside the txt file, just as it can recognize them when typed directly into the minimal.tex file.
Faergen wrote:I have no clue how to make a .txt file any other encoding than what it is. […]
Why do you create a *.txt file at all? With \input you can input *.tex files as usual and create them with your LaTeX editor.
Faergen wrote:[…] I don't know what you mean by "both generated files". I have two files I have created: […]
In fact I meant the two files that you attached.
The problem is that your file "input.txt" is encoded with ISO-8859-15, which is wrong here. You can recode it by opening it with your editor, then go to "Save as" and set the encoding to UTF-8 in the dialog window. Remember to save it as a *.tex file. Then you can simply use \input{input} in your master file.
I want to use .txt files, because it is easier for me to have a template in a folder, with my database of citations and just put some .txt files in there That way I can do the bare minimum of coding in the template for the particular assignment, so it's easy to clean up for the next one.
Having more .tex files just means more code, not less. I'm looking for a way only to include text and the little code I need to typeset and cite in each section, in each of the .txt files. Not to rewrite all the packages again.
And there is no dialogue box when I save as. Neither for txt files nor for .tex files. I have put utf-8 to be the standard encoder in the preferences in TexWorks but that is the closest, outside of packages, I come to have any control over it, and it doesn't seem to have any influence whatsoever on the files.
Isn't there a package that helps Latex read input files like it reads it's own text? I mean, it seems very strange, that the Same characters it knows how to read within the program, it can't simply read when it is in a .txt file, even though it should apply the same encoding to that file, as it applies to itself.
EDIT
Oh, and the problem is actually the same. If I make a .tex file, it doesn't recognize the characters either.
Last edited by Faergen on Wed Mar 27, 2013 11:12 pm, edited 2 times in total.