We have some LaTeX designed for Texlive 2013, but we're going to bump to Texlive 2017 (because of Ubuntu 14 EOL).

We use the gridset package to help us align our text to a grid, and (when debugging) we use tikz to draw the grid on the page to check grid alignment.

This works fine in Texlive 2013 & 2015, but breaks in Texlive 2017. Removing tikz compiles with gridset fine. And removing gridset compiles with tikz fine, but using them together causes compilation to fail.

A minimal example looks like:

\documentclass{article}

% Let gridset work with newer versions of LuaLaTeX
\usepackage{luatex85}

% We have to redefine \savepos because there's a name clash
% between a LuaLaTeX primitive and a gridset macro
\let\savepos=\relax
\usepackage{gridset}

\usepackage{tikz}
\usepackage{eso-pic}

% Draw the baseline grid
\AddToShipoutPicture{\AtTextLowerLeft{
\begin{tikzpicture}[overlay,remember picture]%
  \draw[
    red!50!white,
    very thin, 
    ystep=\baselineskip, 
    xstep=\textwidth,
    yshift=2pt, % manual adjustment to match baseline
  ]%
  (0, 0) grid (\textwidth, \textheight);%
\end{tikzpicture}%
}}%

\begin{document}

\vskipnextgrid % start aligned to grid
Foo
\par\vspace{5pt} % force us off the grid
\vskipnextgrid % force us back onto the grid
Bar

\end{document}

This fails to compile with the following errors:

! Missing \endcsname inserted.
<to be read again> 
\edef 
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

The control sequence marked <to be read again> should
not appear between \csname and \endcsname.


! Missing \endcsname inserted.
<to be read again> 
\edef 
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

The control sequence marked <to be read again> should
not appear between \csname and \endcsname.

! Package gridset Error: position `\edef ' is not unique.

See the gridset package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

You have used the position name `\edef ' you are using on page `1'
already on page `\pos@ \edef @page\endcsname '.
You should stop processing, remove the aux-files and correct the names.
If you'd continue, this will result in grid position failures,
that won't be reported!

! Missing \endcsname inserted.
<to be read again> 
\edef 
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

The control sequence marked <to be read again> should
not appear between \csname and \endcsname.

! Missing \endcsname inserted.
<to be read again> 
\edef 
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

The control sequence marked <to be read again> should
not appear between \csname and \endcsname.

! Missing \endcsname inserted.
<to be read again> 
\edef 
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

The control sequence marked <to be read again> should
not appear between \csname and \endcsname.

! Missing \endcsname inserted.
<to be read again> 
\edef 
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

The control sequence marked <to be read again> should
not appear between \csname and \endcsname.

! Missing \endcsname inserted.
<to be read again> 
\edef 
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

The control sequence marked <to be read again> should
not appear between \csname and \endcsname.

! Missing \endcsname inserted.
<to be read again> 
\edef 
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

The control sequence marked <to be read again> should
not appear between \csname and \endcsname.

! Use of \pos@ doesn't match its definition.
<argument> pos@\edef @b
            ase
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

If you say, e.g., `\def\a1{...}', then you must always
put `1' after `\a', since control sequence names are
made up of letters only. The macro here has not been
followed by the required stuff, so I'm ignoring it.

! Missing number, treated as zero.
<to be read again> 
a
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)


! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

You're in trouble here.  Try typing  <return>  to proceed.
If that doesn't work, type  X <return>  to quit.

! Extra \endcsname.
\@nameuse #1->\csname #1\endcsname 

l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

I'm ignoring this, since I wasn't doing a \csname.

! Missing \endcsname inserted.
<to be read again> 
\edef 
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

The control sequence marked <to be read again> should
not appear between \csname and \endcsname.

! Missing \endcsname inserted.
<to be read again> 
\edef 
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

The control sequence marked <to be read again> should
not appear between \csname and \endcsname.

! Use of \pos@ doesn't match its definition.
<argument> pos@\edef @i
            nterval
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

If you say, e.g., `\def\a1{...}', then you must always
put `1' after `\a', since control sequence names are
made up of letters only. The macro here has not been
followed by the required stuff, so I'm ignoring it.

! Missing number, treated as zero.
<to be read again> 
n
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

! Extra \endcsname.
\@nameuse #1->\csname #1\endcsname 

l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

I'm ignoring this, since I wasn't doing a \csname.

! Missing \endcsname inserted.
<to be read again> 
\edef 
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

The control sequence marked <to be read again> should
not appear between \csname and \endcsname.

! Use of \pos@ doesn't match its definition.
<argument> pos@\edef @i
            nterval
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

If you say, e.g., `\def\a1{...}', then you must always
put `1' after `\a', since control sequence names are
made up of letters only. The macro here has not been
followed by the required stuff, so I'm ignoring it.

! Missing number, treated as zero.
<to be read again> 
n
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

! Arithmetic overflow.
<to be read again> 
n
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

I can't carry out that multiplication or division,
since the result is out of range.

! Extra \endcsname.
\@nameuse #1->\csname #1\endcsname 

l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

I'm ignoring this, since I wasn't doing a \csname.

! Missing \endcsname inserted.
<to be read again> 
\edef 
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

The control sequence marked <to be read again> should
not appear between \csname and \endcsname.

! Missing \endcsname inserted.
<to be read again> 
\edef 
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

The control sequence marked <to be read again> should
not appear between \csname and \endcsname.

! Use of \pos@ doesn't match its definition.
<argument> pos@\edef @i
            nterval
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

If you say, e.g., `\def\a1{...}', then you must always
put `1' after `\a', since control sequence names are
made up of letters only. The macro here has not been
followed by the required stuff, so I'm ignoring it.

! Missing number, treated as zero.
<to be read again> 
n
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

! Extra \endcsname.
\@nameuse #1->\csname #1\endcsname 

l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

I'm ignoring this, since I wasn't doing a \csname.

! Missing \endcsname inserted.
<to be read again> 
\edef 
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

The control sequence marked <to be read again> should
not appear between \csname and \endcsname.

! Missing \endcsname inserted.
<to be read again> 
\edef 
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

The control sequence marked <to be read again> should
not appear between \csname and \endcsname.

! Use of \pos@ doesn't match its definition.
<argument> pos@\edef @y

l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

If you say, e.g., `\def\a1{...}', then you must always
put `1' after `\a', since control sequence names are
made up of letters only. The macro here has not been
followed by the required stuff, so I'm ignoring it.

! Missing number, treated as zero.
<to be read again> 
\endcsname 
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

! Extra \endcsname.
<recently read> \endcsname 

l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

I'm ignoring this, since I wasn't doing a \csname.

! Missing \endcsname inserted.
<to be read again> 
\edef 
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

The control sequence marked <to be read again> should
not appear between \csname and \endcsname.

! Use of \pos@ doesn't match its definition.
<argument> pos@\edef @b
            ase
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

If you say, e.g., `\def\a1{...}', then you must always
put `1' after `\a', since control sequence names are
made up of letters only. The macro here has not been
followed by the required stuff, so I'm ignoring it.

! Extra \endcsname.
\@nameuse #1->\csname #1\endcsname 

l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

I'm ignoring this, since I wasn't doing a \csname.

! Missing number, treated as zero.
<to be read again> 
)
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

! Missing \endcsname inserted.
<to be read again> 
\edef 
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

The control sequence marked <to be read again> should
not appear between \csname and \endcsname.

! Missing control sequence inserted.
<inserted text> 
\inaccessible 
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

Please don't say `\def cs{...}', say `\def\cs{...}'.
I've inserted an inaccessible control sequence so that your
definition will be completed without mixing me up too badly.
You can recover graciously from this error, if you're
careful; see exercise 27.2 in The TeXbook.

! Missing \endcsname inserted.
<to be read again> 
\edef 
l.2 ...edef }{1}{46515936}{786432}{9017753}{7844659}

The control sequence marked <to be read again> should
not appear between \csname and \endcsname.


Does anyone have any ideas on how to fix this?
  • 2
    tikz now uses the luatex primitive \savepos. The primitive has no argument but the redefinition of gridset has one, and this clashes. gridset would need an update to work again with luatex - or tikz should internally use safe copies of the primitive. – Ulrike Fischer Sep 14 at 10:15
  • @UlrikeFischer aha that makes sense - I was wondering if it was to do with this (for example, I also tried running it just with tikz and \let\savepos=\relax, but no gridset and it seemed to work). I'm pretty new to LaTeX hackery; is there any workaround? Or would I have to eg copy-paste the gridset package and just rename savepos myself to something else to avoid clashing? – Alec Sep 14 at 10:18
up vote 9 down vote accepted

You could try this patches.

\let\storedsavepos\savepos
\let\savepos\undefined
\usepackage{gridset}
\let\gridsetsavepos\savepos
\let\savepos\storedsavepos

\usepackage{xpatch}
\xpatchcmd\vskipnextgrid{\savepos}{\gridsetsavepos}{}{\fail}
\xpatchcmd\vskipnextgrid{\savepos}{\gridsetsavepos}{}{\fail}

And alternative patch for tikz is

\usepackage{tikz}
\usepackage{xpatch}

\makeatletter
\xpatchcmd\pgfsys@markposition{\savepos}{\primitive\savepos}{}{\fail}

On the whole I prefer the second as it doesn't affect a documented user command.

  • You're a genius! Thank you. It may be worth adding an answer to this other question that I came across in my travels: tex.stackexchange.com/questions/427533/… I believe your first patch is a more robust solution to that question of using gridset with newer versions of LuaLaTeX, since it avoids clashing with a primitive. – Alec Sep 14 at 10:42
  • gridset was written in 2012, at that time \savepos wasn't a primitive. luatex has a certain tendency to add commands without really caring if they are in use. Imho one shouldn't ask packages to rename their commands only because luatex grapped the name. – Ulrike Fischer Sep 14 at 10:48

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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