encoding of tex file

Bug #944134 reported by Matthis Thorade
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Excel2LaTeX
Won't Fix
Medium
Unassigned

Bug Description

The encoding of the tex files created by excel2latex is ANSI, but if my Excel sheet contains umlauts like äöüß, compilation of my main tex file (which includes the tex files created by excel2latex) fails.
Now I use Notepad++ to convert the encoding from ANSI to UTF8 without BOM manually. Is there a way to automate this or just export to UTF8 right away?

Tags: utf8
Revision history for this message
Kirill Müller (krlmlr) wrote :

Please see the documentation for the inputenc package. You can change the input encoding in the middle of the document using something along

\inputencoding{latin1}

Of course it would be nice if Excel2LaTeX added the \inputencoding command into the generated file. However, I am not sure how to switch back to the encoding used before. Perhaps the following will work:

{
\inputencoding{latin1}
...generated TeX file
}

Could you please check if this works? After the closing brace, the input encoding should be switched back to whatever it was before. If it does, I can add this to the generation routine.

Revision history for this message
Matthis Thorade (matthis-thorade) wrote :

Yes, that works! I did not know that about the inputenc package. Thank you!
If you add it to the generation routine, excel2latex will depend upon the inputenc package.
It also works if I write something like the following:

\begin{table}[!htb]
 \centering
 \caption{Berechnungsvorschrift für Zustandsgrößen}
 \label{tab:Basic_Properties}
 {\inputencoding{latin1}
 \input{./tables/Basic_Properties}
 }
\end{table}

Is there a reason to use latin1? Is this a limitation by Excel?
Alternatively, it would be nice to just export to UTF8 or maybe to specify the encoding via some variable in the VBA source code and then export to that encoding. But I think apart from TexnicCenter, all editors use UTF8, so maybe that is a sensible default setting!?

Revision history for this message
Kirill Müller (krlmlr) wrote :

All articles that I found that describe how to write UTF-8 from Excel VBA refer to ADODB.Stream. I'm not sure if that's available on the Mac. Besides, there is a "native VBA" way to write UTF-16 files, can inputenc handle these?

Revision history for this message
Matthis Thorade (matthis-thorade) wrote :

Looks like adob.stream is NOT supported on Mac
http://talesoftech.blogspot.com/2011/05/excel-on-mac-goodbye-vba-hello.html
http://stackoverflow.com/questions/4722716/how-to-save-worksheets-as-csv-files-in-utf-8-format-with-excel-for-mac-2011
http://stackoverflow.com/questions/2524703/save-text-file-utf-8-encoded-with-vba

I could not find out whether or not inputenc supports utf16, but also I am not sure whether that would help, because the file encoding must be the same as the input encoding specified in \usepackage[]{inputenc} and many or most editors just use utf8 as default for file encoding (correct me if I'm wrong here).

Revision history for this message
Kirill Müller (krlmlr) wrote :

Thanks for looking at ADODB.Stream on Mac.

Isn't file encoding = input encoding? That's what you set in the package parameter of inputenc, and also in the \inputencoding command.

Perhaps it works if the

{\inputencoding{utf16}

part is in ASCII, and everything after this is in UTF-16. However, given that the workaround is so easy, I'm not too enthusiastic about changing the current behavior. (Another workaround would be using those old commands like "o instead of ö.) If you like, you can implement it and send me your version of Excel2LaTeX.xla (or use the "development environment" in the Bazaar branch; see the routines in Dev.bas).

Revision history for this message
Matthis Thorade (matthis-thorade) wrote :

well, just using
\usepackage[utf16]{inputenc} doesn't work, it gives me
! LaTeX Error: File `utf16.def' not found.

I agree that using one of the workarounds is the easiest solution for now.

Revision history for this message
Matthis Thorade (matthis-thorade) wrote :

PS: I use excel2latex with Excel 2010 and it works very well, apart from my little encoding problem

And, looking at the VBA code, I wasn't able to even find the place where the .tex file is created/saved. Could you point me to the Module/Function where saving is done?

Revision history for this message
Kirill Müller (krlmlr) wrote :

Thanks for sharing your experience with Excel 2010.

I'm not sure which module it is. You should be able to find it with a search for "Open#", "Open #" or "Print" in the VBA project.

Revision history for this message
Kirill Müller (krlmlr) wrote :

I'm closing this because no generic fix seems to be possible and a neat workaround exists.

Changed in excel2latex:
status: New → Won't Fix
importance: Undecided → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.