5

I'm trying to get siunitx working. For some reason I keep getting this error:

! Missing = inserted for \ifnum.
<to be read again> 
                   -
l.3 \begin
          {document}^^M

I have tried a minimal document to make sure it is not some kind of compatibility issue. And I get that same error in the most minimal document possible.

I'm using pdfLaTeX to compile, and have tried both from TeXWorks and from bash. I'm using TeXLive, if that matters. I have also tried reinstalling siunitx, l3packages, and l3kernel. There was an issue with l3kernel before this, due to an apparently old version. But all three packages are now up to date. I've also reinstalled expl3 while trying to debug the original issue.

My minimal document is:

\documentclass{article}
\usepackage{siunitx}
\begin{document}
\end{document}

The output I get is:

This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
(./untitled-2.tex
LaTeX2e <2016/02/01>
Babel <3.9q> and hyphenation patterns for 81 language(s) loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/home/<name>/texmf/tex/latex/siunitx/siunitx.sty
(/home/<name>/texmf/tex/latex/l3kernel/expl3.sty
(/home/<name>/texmf/tex/latex/l3kernel/expl3-code.tex)
(/home/<name>/texmf/tex/latex/l3kernel/l3pdfmode.def))
(/home/<name>/texmf/tex/latex/l3packages/xparse/xparse.sty)
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/share/texlive/texmf-dist/tex/latex/tools/array.sty)
(/home/<name>/texmf/tex/latex/l3packages/l3keys2e/l3keys2e.sty)
(/usr/share/texlive/texmf-dist/tex/latex/beamer/translator/translator.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texlive/texmf-dist/tex/latex/beamer/translator/translator-language-
mappings.tex)))
! Missing = inserted for \ifnum.
<to be read again> 
                  -
l.3 \begin
         {document}^^M
?

Does anyone have any idea what might be going wrong here?

  • 1
    Can you add \listfiles to your input and 'go past' the errors to get a File list in the .log file? If so, that list would be handy as an edit. If you can't, what happens if you load expl3, amstext and translator? As you say in the question, this looks like a version issue, but it's not one I recognise. – Joseph Wright Mar 22 '18 at 7:06
6

siunitx is going back to the old yyyy/mm/dd for the time being, so it should compile fine even with older LaTeX releases again (of course you still need the required versions of l3kernel etc.).

Since this question seems to have attracted a bit of attention by various people, let me explain what is going on here.

LaTeX packages normally identify themselves with their release date (and name, version number as well as a short description) to TeX. This is done in \ProvidesPackage (or \ProvidesClass for classes or \ProvidesFile for general files, see Is ProvidesFile better than ProvidesPackage or ProvidesClass). The first line of a package could look like this

\ProvidesPackage{csquotes}[2018/04/13 v5.2d context-sensitive quotations (JAW)]

The date given there can LaTeX help figure out if a package is older than a specified cut-off date with \@ifpackagelater, see Require a certain (or later) version of a package?.

Classically, all packages gave their date in the format yyyy/mm/dd. In the April 2017 release of the LaTeX kernel support for the ISO date format yyyy-mm-dd was added. See https://www.latex-project.org/news/latex2e-news/ltnews27.pdf

Only LaTeX releases that identify themselves as LaTeX2e <2017-04-15> or newer can deal with the ISO date format, all older versions can only accept yyyy/mm/dd.

Since this is a relatively recent change not many packages have adopted the new date format, but some actively maintained packages have switched to the new format. Often these packages assume that the user keeps their TeX installation up-to-date anyway. siunitx is one of the packages that now uses the ISO date format.

The .log file in your question shows that you still run LaTeX2e <2016/02/01>, which is too old for the ISO date format.

You will have to update your TeX distribution. See How do I update my TeX distribution? and How should one maintain and update a MiKTeX installation?

The fact that you got the new version of the package, but are stuck with an old version of the kernel means that you either updated or installed certain packages manually (a very bad idea in general), updated your installation only partially (again, a bad idea), or did not remember to update with correct permissions (MikTeX multi-user installations need to be updated as Admin and User, i.e. twice).


If you for some reason can not update your TeX distribution, there is a workaround available.

The LaTeX3 team provide a package called latexrelease that can be used to get features of newer kernel versions with older releases as well. According to https://www.latex-project.org/news/latex2e-news/ltnews27.pdf it should be enough to load the package at all because it always enables ISO dates, but to be on the safe side you can load

\RequirePackage[2017/04/15]{latexrelease}

at the very beginning of your document if you are stuck with an old LaTeX release. That will effectively 'update' your old version of the LaTeX kernel to the 2017-04-15 version.

Of course you still have to obtain latexrelease in a reasonably recent version.


The TeX Live 2015/Debian makes me think you may be stuck with an outdated (stable) version of TeX live shipped with your Linux distribution. In that case you have little control over your TeX installation and you should only install or remove packages via the official package repositories. Manual installations can lead to all sorts of problems.

For more control over your TeX distribution you could install a vanilla TeX live: How to install "vanilla" TeXLive on Debian or Ubuntu?

  • 1
    Indeed: I wonder how this happened. The OP could load latexrelease, but if they have that they probably have a new kernel too ... – Joseph Wright May 17 '18 at 10:40
  • @JosephWright I guess the TeX Live 2015/Debian tells us that the OP is using Debian's own TeX live and has somehow obtained a new version of siunitx (probably downloaded somewhere and installed manually, since the .log shows it lives in /home/<name>/texmf/tex/latex/siunitx/). I'll mention latexrelease in an update, thanks for reminding me of that. – moewe May 17 '18 at 10:45
  • I guess I can switch back to traditional date format, at least for 'a bit': the Debian issue is likely a reasonably significant one – Joseph Wright May 17 '18 at 10:50
  • @JosephWright Mhhh, the switch to ISO might have come too soon for some, but in my opinion people are asking for trouble if they install recent versions of actively developed packages manually on an old system. But then again, I always work on my own machine and am not restricted by school or company policy/sysadmins and so I don't have to resort to these sort of things. – moewe May 17 '18 at 10:59
1

This isn't necessarily an "answer," but I had the exact same problem and was able to resolve it.

I had updated all packages with MiKTeX. I also tried getting rid of the AppData folder C:\Users\Kevin\AppData\Roaming\MiKTeX\2.9. I was still having the problem.

I followed Joseph Wright's suggestion based on your minimal document. I was able to load expl3, amstext, and translator without a problem. I also added \listfiles to the beginning of the input.

\listfiles
\documentclass{article}
\usepackage{siunitx}
\begin{document}
\end{document}

Here are some sections from the log file.

The beginning section:

This is pdfTeX, Version 3.14159265-2.6-1.40.17 (MiKTeX 2.9.6210 64-bit) (preloaded format=pdflatex 2017.2.1)  25 MAR 2018 18:18
entering extended mode
**./troubleshoot_siunitx.tex
(troubleshoot_siunitx.tex
LaTeX2e <2017/01/01> patch level 1
Babel <3.9r> and hyphenation patterns for 75 language(s) loaded.
("C:\Program Files\MiKTeX 2.9\tex\latex\base\article.cls"
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
("C:\Program Files\MiKTeX 2.9\tex\latex\base\size10.clo"
File: size10.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
)
\c@part=\count79
\c@section=\count80
\c@subsection=\count81
\c@subsubsection=\count82
\c@paragraph=\count83
\c@subparagraph=\count84
\c@figure=\count85
\c@table=\count86
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
)
(C:\Users\Kevin\AppData\Roaming\MiKTeX\2.9\tex\latex\siunitx\siunitx.sty
(C:\Users\Kevin\AppData\Roaming\MiKTeX\2.9\tex\latex\l3kernel\expl3.sty
Package: expl3 2018/03/05 L3 programming layer (loader) 

(C:\Users\Kevin\AppData\Roaming\MiKTeX\2.9\tex\latex\l3kernel\expl3-code.tex
Package: expl3 2018/03/05 L3 programming layer (code)

There is much more, and later, after many similar xparse lines,

.................................................
. LaTeX info: "xparse/define-command"
. 
. Defining command \siInBookmark with sig. 'om' on line 7426.
.................................................
\g__file_internal_ior=\read1

(C:\Users\Kevin\AppData\Roaming\MiKTeX\2.9\tex\latex\translator\translator.sty
Package: translator 2018/01/04 v1.12 Easy translation of strings in LaTeX

("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\keyval.sty"
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
\KV@toks@=\toks16
)))
! Missing = inserted for \ifnum.
<to be read again> 
                   -
l.3 \begin
          {document}

I was expecting to see `<', `=', or `>'. Didn't.

(troubleshoot_siunitx.aux)
\openout1 = `troubleshoot_siunitx.aux'.

That's where the error is. Finally, towards the end, we get the file list.

 *File List*
 article.cls    2014/09/29 v1.4h Standard LaTeX document class
  size10.clo    2014/09/29 v1.4h Standard LaTeX file (size option)
 siunitx.sty    2018-03-20 v2.7m A comprehensive (SI) units package
   expl3.sty    2018/03/05 L3 programming layer (loader) 
expl3-code.tex    2018/03/05 L3 programming layer 
l3pdfmode.def    2017/03/18 v L3 Experimental driver: PDF mode
  xparse.sty    2018/02/21 L3 Experimental document command parser
 amstext.sty    2000/06/29 v2.01 AMS text
  amsgen.sty    1999/11/30 v2.0 generic functions
   array.sty    2016/10/06 v2.4d Tabular extension package (FMi)
l3keys2e.sty    2018/02/21 LaTeX2e option processing using LaTeX3 keys
translator.sty    2018/01/04 v1.12 Easy translation of strings in LaTeX
  keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
translator-basic-dictionary-English.dict    
siunitx-abbreviations.cfg    2017/11/26 v2.7k siunitx: Abbreviated units
 ***********

At this point, I was getting desperate, so I uninstalled MiKTeX, downloaded the latest version, and installed it again. This is on Windows 7, and I did not reboot. Now I am able to compile without errors. Having reinstalled MiKTeX, here is what my file list is with the successful process. It's the same. I can't help but notice the date is formatted differently for siunitx.sty.

 *File List*
 article.cls    2014/09/29 v1.4h Standard LaTeX document class
  size10.clo    2014/09/29 v1.4h Standard LaTeX file (size option)
 siunitx.sty    2018-03-20 v2.7m A comprehensive (SI) units package
   expl3.sty    2018/03/05 L3 programming layer (loader) 
expl3-code.tex    2018/03/05 L3 programming layer 
l3pdfmode.def    2017/03/18 v L3 Experimental driver: PDF mode
  xparse.sty    2018/02/21 L3 Experimental document command parser
 amstext.sty    2000/06/29 v2.01 AMS text
  amsgen.sty    1999/11/30 v2.0 generic functions
   array.sty    2016/10/06 v2.4d Tabular extension package (FMi)
l3keys2e.sty    2018/02/21 LaTeX2e option processing using LaTeX3 keys
translator.sty    2018/01/04 v1.12 Easy translation of strings in LaTeX
  keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
translator-basic-dictionary-English.dict    
siunitx-abbreviations.cfg    2017/11/26 v2.7k siunitx: Abbreviated units
 ***********
0

I was able to solve this issue successfully by reverting the siunitx package to the previous version by downloading it in the CTAN mirror page and manually installing it as explained here.

In my case, the solution was not to update the package, but to revert it to a previous version.

0

I saw Kevin's answer and tried something that fixes the error for me. It seems to come from date format.

siunitx.sty    2018-03-20 v2.7m A comprehensive (SI) units package

should be

siunitx.sty    2018/03/20 v2.7m A comprehensive (SI) units package

Here come my first post, and ugliest fix. Just manually modify date format in your texmf dir :

grep -rl "2018-03-20" /path/to/your/texmf/dir | xargs sed -i -e 's/2018-03-20/2018\/03\/20/g'

Fixed those \ifnum errors for me.

  • 4
    The new date format with - instead of / was introduced in the April 2017 update of the kernel. You can find your LaTeX version at the top of the .log file. The question is how you could update siunitx without updating your TeX kernel as well. Never install packages manually. Always update packages via your TeX distribution. – moewe May 17 '18 at 10:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.