Math & Sciencesiunitx | Errors with ISO-8859-1 (latin1) Encoding

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
XeMattress
Posts: 7
Joined: Wed Nov 09, 2011 9:03 pm

siunitx | Errors with ISO-8859-1 (latin1) Encoding

Post by XeMattress »

%%%%%%%%%%%%%%%%%%%% Added on 14 Dec 2011 %%%%%%%%%%%%%%%%%%%%
Summary: The package siunitx (version < 2.4e) was found giving errors ("Invalid code 84XX") on unit declarations when using a particular input encoding (latin-1), while still compiling the tex code properly. The problem was encountered with version 2.4d and version 2.4c of siunitx with a latin1 encoded source file, declaring the encoding by a \usepackage[latin1]{inputenc} command.
The problem could be solved by updating siunitx to version 2.4e or higher (thanks to the package maintainer Joseph Wright).
Two other useful workarounds are:
*) Changing the file encoding to supported utf-8 (e.g., by a 'Save As...' command in a visual editor, specifying the new encoding; or with a 'iconv --from-code OLD_ENCODING --to-code NEW_ENCODING source.tex > source.newencoding.tex' on a linux box), and replacing the latin1 parameter in the inputenc command with utf8.
*) Use of the selinput package, as shown in the example by localghost:
localghost wrote: For a European language like Italian you can try a semiautomatic input encoding by the selinput package from the oberdiek bundle instead of a fixed one. It will select the right input encoding according to the file encoding by several glyphs. Replace the above line with the following.

Code: Select all

\usepackage{selinput}
\SelectInputMappings{%
  agrave={à},
  eacute={é},
  Euro={€}
}
The needed glyphs can be found in the Adobe Glyph List.
Thank goes to localghost for both workarounds.

I'll mark this thread as solved.
%%%%%%%%%%%%%%%%%%%% Original post from 10 Dec 2011 %%%%%%%%%%%%%%%%%%%%

Hello altogether,

first of all I want to express my gratitude to the people who run this forum and those who contribute. I cleared many problems just by searching (sometimes a bit more intensely :D ) through the posts.

Here's my actual problem. I've not found anyone else referring to it, so it could be related to my own system.

A working example which reproduces the error on my system is the following:

Code: Select all

\documentclass{minimal}
\usepackage[latin1]{inputenc}
\usepackage{siunitx}

\begin{document}
 trial text to check \emph{siunitx}'s behavior: \si{m} \\
 \si{\metre} \\
 \num{e5} \\
 \SI{5}{s} \\
 \SI{5}{\second}\par
 accented letters I need in Italian: À È Ì Ò Ù É à è ì ò ù é
 and in German: Ä Ö Ü ä ö ü ß
\end{document}
The file is encoded in ISO-8859-1 (latin1), as I write my source in Italian containing accented letters.
(I didn't insert the

Code: Select all

\usepackage[T1]{fontenc}
command as the error is reproducible without it.)

The typical error I get when compiling is something like this:

Code: Select all

! Invalid code (8451), should be in the range 0..255.
<recently read> \int_eval_end: 
                               
l.8  \SI{5}{s}
                \\
The error appears just on the literal unit declarations. When I ignore the error, a second one follows, with '8486' instead of '8451'. Ignoring both errors compiles the document right, but since I usually compile the code from the command line, I have to give a double ignore on every \SI-like command I inserted in the code. Changing encoding to utf8 eliminates the error, but since I'm writing in Italian, I lose my accented letters too.

I am running a complete TeX Live distribution, updated weekly or so (last update: 10 Dec 2011), on a Kubuntu 11.04 box. Usually I write my source code with Kate (actually 3.6.5); writing it with Vim didn't change anything.
The error appeared first about two weeks ago, upgrading siunitx; then it appeared on all unit declarations (literal and macros). Since the last upgrade it happens just on literal declarations.

I tried to do compiling in nonstopmode, but I found myself overlooking important errors more than once, so I'm looking for another solution.

Has anybody an idea about something I did do wrong, or some setting to be checked/changed on my box?

With best regards,
Xem
Last edited by XeMattress on Wed Dec 14, 2011 4:34 pm, edited 1 time in total.
I hope my English is not too bad to be understood :)

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

siunitx | Errors with ISO-8859-1 (latin1) Encoding

Post by localghost »

Are you really sure the file encoding is ISO-8859-1? On Linux systems file encoding is usually UTF-8. What happens if you change the input encoding to »utf8«?

Code: Select all

\usepackage[utf8]{inputenc}
For a European language like Italian you can try a semiautomatic input encoding by the selinput package from the oberdiek bundle instead of a fixed one. It will select the right input encoding according to the file encoding by several glyphs. Replace the above line with the following.

Code: Select all

\usepackage{selinput}
\SelectInputMappings{%
  agrave={à},
  eacute={é},
  Euro={€}
}
The needed glyphs can be found in the Adobe Glyph List.


Thorsten
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Re: siunitx | Errors with ISO-8859-1 (latin1) Encoding

Post by josephwright »

I can see what is up here. Expect an update of siunitx to CTAN later today.
Joseph Wright
XeMattress
Posts: 7
Joined: Wed Nov 09, 2011 9:03 pm

siunitx | Errors with ISO-8859-1 (latin1) Encoding

Post by XeMattress »

localghost wrote:Are you really sure the file encoding is ISO-8859-1?
I'm quite sure about the encoding. The output of a file-mime-request on the .tex file is something like that:

Code: Select all

me@home:~/TEST2$ file -ib test3.tex
text/x-tex; charset=iso-8859-1
localghost wrote:On Linux systems file encoding is usually UTF-8. What happens if you change the input encoding to »utf8«?

Code: Select all

\usepackage[utf8]{inputenc}
Switching encoding to 'utf8' and changing inputenc's setting did in fact do solve my problem. Admittedly, I thought utf8 wouldn't properly encode accented letters in the input. As it seems, I was wrong on this point :)

Thank you both for your prompt replies!

(Should I mark this topic as solved? And if, how do I do that?)
I hope my English is not too bad to be understood :)
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

siunitx | Errors with ISO-8859-1 (latin1) Encoding

Post by localghost »

Your information is in fact a bit contradictory. You determined the file encoding as ISO-8859-1, changed input encoding to UTF-8 and it works. I wonder how this can be.
XeMattress wrote:(Should I mark this topic as solved? And if, how do I do that?)
If you consider your problem as solved, you can mark the topic accordingly. How to do that is described in Section 3 of the Board Rules.

On the other hand you can hang on the announced update for the siunitx package and try with your original settings.
XeMattress
Posts: 7
Joined: Wed Nov 09, 2011 9:03 pm

siunitx | Errors with ISO-8859-1 (latin1) Encoding

Post by XeMattress »

I am sorry to have not listed all the combinations I tried. They are:

1) The original example, with iso-8859-1 encoding and \usepackage[latin1]{inputenc} reported the error while still generating a document as I expected;
2) Switching the encoding or the inputenc parameter to utf8 did not produce a useful document.
3) Changing both the encoding and the inputenc parameter to utf8 compiled the source as expected without errors.

The error depends not on compilation with 'pdflatex' or 'latex'.

The 'utf8' setting both on encoding and inputenc makes the errors disappear; however, I will wait for the update, try it out and see if it fixes my original problem.
I hope my English is not too bad to be understood :)
warpino
Posts: 5
Joined: Sat Dec 11, 2010 10:19 pm

siunitx | Errors with ISO-8859-1 (latin1) Encoding

Post by warpino »

Hi there,

I have exactly the same problem using siunitx package with texlive 2011 distribution. Following this thread I updated to the latest version today using tlmgr
(siunitx 2011/12/04 v2.4a) though the problem did not disappear!
I also tried to make sure all files are saved using utf-8 encoding and used either

Code: Select all

\usepackage[latin1]{inputenc}
or

Code: Select all

\usepackage[utf8]{inputenc}

but get the same errors: "Invalid code (8451) ... " "Invalid code (8486) ...".

Do you have any suggestions?
XeMattress
Posts: 7
Joined: Wed Nov 09, 2011 9:03 pm

siunitx | Errors with ISO-8859-1 (latin1) Encoding

Post by XeMattress »

Hello warpino,
If you have not updated to a more recent version of siunitx yet, I suggest you to keep up with these errors, as they behave just as some of lesser bug and still do compile the document properly.
If you don't want these errors to appear, be sure you do switch your file encoding to utf-8 (usually, when writing with your favourite editor, you can set the encoding when performing a 'Save As...' command; probably you will have to fix your special characters afterwards. On a linux box, the iconv command could be useful; I'll try it out soon), include \usepackage[utf8]{inputenc} in your preamble, and optionally upgrade to version 2.4d of siunitx (but not further!).
Upgrading to version 2.4d (revision 24810) did reduce the amount of errors on my box to just the literal declarations with latin-1 encoding (e.g. \si{\metre} doesn't give me errors anymore, while \si{m} still does) and doesn't show any errors with utf8 encoding. As I need some literal declarations in my actual latin-1 source (I didn't convert it at the moment), I managed to reduce the global error amount by changing literal units to pre-defined macros, where this was possible.

This morning I did a whole update of my texlive, upgrading siunitx to version 2.4e (revision 24835). Now the package doesn't work properly anymore; a WE as simple as

Code: Select all

 \documentclass{minimal}
\usepackage{siunitx}
\begin{document}
test string
\end{document}
gives me a 100 errors, with latex suggesting me to 'try again' (in this case the source file was coded 'us-ascii', for simplicity). Looking on the log file, they begin when loading the .sty files. After having loaded the minimal class (I tried the changing to article class, with same result), the siunitx.sty and >35 other .sty files, when loading l3keys2e.sty the error series begins, from line 6916 upwards. The first error is the following:

Code: Select all

l.6916 \NewDocumentCommand
                           \DeclareBinaryPrefix { m m m } { 
A little research showed me that this .sty file is part of the 'l3packages'. Currently I've installed revision 24821 of l3packages.

If I restore siunitx to revision 24810, I still can work with it.

If anyone else with the same (or a similar) configuration as mine doesn't experience these problems, please let me know; probably my system could have some minor file broken and I just need a fresh install. As I don't want to lose the 2.4d siunitx package, for the moment I'll simply keep up with it.
I hope my English is not too bad to be understood :)
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Re: siunitx | Errors with ISO-8859-1 (latin1) Encoding

Post by josephwright »

Please post your log file. I suspect that you have a bad update on some support material: I have no issues with the release version updated today.
Joseph Wright
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

siunitx | Errors with ISO-8859-1 (latin1) Encoding

Post by josephwright »

For reference, \listfiles gives

Code: Select all

 *File List*
 minimal.cls    2001/05/25 Standard LaTeX minimal class
 siunitx.sty    2011/12/11 v2.4e A comprehensive (SI) units package
   expl3.sty    2011/12/07 v3036 L3 Experimental code bundle wrapper
 l3names.sty    2011/11/11 v2944 L3 Experimental namespace for primitives
l3bootstrap.sty    2011/11/25 v3006 L3 Experimental bootstrap code
    etex.sty    1998/03/26 v2.0 eTeX basic definition package (PEB)
    calc.sty    2007/08/22 v4.3 Infix arithmetic (KKT,FJ)
   color.sty    2005/11/14 v1.0j Standard LaTeX Color (DPC)
   color.cfg    2007/01/18 v1.5 color configuration of teTeX/TeXLive
  pdftex.def    2011/05/27 v0.06d Graphics/color for pdfTeX
infwarerr.sty    2010/04/08 v1.3 Providing info/warning/message (HO)
 ltxcmds.sty    2011/04/18 v1.20 LaTeX kernel commands for general use (HO)
graphics.sty    2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg    2010/04/23 v1.9 graphics configuration of TeX Live
l3basics.sty    2011/12/04 v3023 L3 Experimental basic definitions
 l3expan.sty    2011/12/07 v3031 L3 Experimental argument expansion
    l3tl.sty    2011/12/07 v3034 L3 Experimental token lists
   l3seq.sty    2011/12/07 v3033 L3 Experimental sequences and stacks
   l3int.sty    2011/12/06 v3029 L3 Experimental integers
 l3quark.sty    2011/11/27 v3014 L3 Experimental quarks
   l3prg.sty    2011/11/27 v3014 L3 Experimental control structures
 l3clist.sty    2011/12/06 v3029 L3 Experimental comma separated lists
 l3token.sty    2011/10/22 v2931 L3 Experimental token manipulation
  l3prop.sty    2011/12/06 v3029 L3 Experimental property lists
   l3msg.sty    2011/12/06 v3029 L3 Experimental messages
    l3io.sty    2011/11/25 v3005 L3 Experimental input-output operations
  l3file.sty    2011/10/09 v2896 L3 Experimental file operations
  l3skip.sty    2011/12/06 v3029 L3 Experimental dimensions and skips
  l3keys.sty    2011/09/10 v2800 L3 Experimental key-value interfaces
    l3fp.sty    2011/12/06 v3029 L3 Experimental floating-point operations
   l3box.sty    2011/12/06 v3029 L3 Experimental boxes
l3coffins.sty    2011/11/15 v2963 L3 Experimental coffin code layer
 l3color.sty    2011/09/07 v2776 L3 Experimental colour support
l3luatex.sty    2011/11/23 v2995 L3 Experimental LuaTeX-specific functions
 amstext.sty    2000/06/29 v2.01
  amsgen.sty    1999/11/30 v2.0
   array.sty    2008/09/09 v2.4c Tabular extension package (FMi)
l3keys2e.sty    2011/12/07 v3036 LaTeX2e option processing using LaTeX3 keys
  xparse.sty    2011/12/07 v3036 L3 Experimental document command parser
translator.sty    2010/06/12 ver 1.10
  keyval.sty    1999/03/16 v1.13 key=value parser (DPC)
translator-language-mappings.tex
supp-pdf.mkii
pdftexcmds.sty    2011/04/22 v0.16 Utilities of pdfTeX for LuaTeX (HO)
ifluatex.sty    2010/03/01 v1.3 Provides the ifluatex switch (HO)
   ifpdf.sty    2011/01/30 v2.3 Provides the ifpdf switch (HO)
epstopdf-base.sty    2010/02/09 v2.5 Base part for package epstopdf
  grfext.sty    2010/08/19 v1.1 Managing graphics extensions (HO)
kvdefinekeys.sty    2011/04/07 v1.3 Defining keys (HO)
kvoptions.sty    2010/12/23 v3.10 Keyval support for LaTeX options (HO)
kvsetkeys.sty    2011/04/07 v1.13 Key value parser (HO)
etexcmds.sty    2011/02/16 v1.5 Prefix for e-TeX command names (HO)
epstopdf-sys.cfg    2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
translator-basic-dictionary-English.dict    
siunitx-abbreviations.cfg    2011/12/11 v2.4e siunitx: Abbreviated units
siunitx-binary.cfg    2011/12/11 v2.4e siunitx: Binary units
 ***********
Joseph Wright
Post Reply