Using gridset with tikz in LuaLaTeX (Texlive 2017)

Using gridset with tikz in LuaLaTeX (Texlive 2017)



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.


gridset


tikz



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.


tikz


gridset


gridset


tikz



A minimal example looks like:


documentclassarticle

% Let gridset work with newer versions of LuaLaTeX
usepackageluatex85

% We have to redefine savepos because there's a name clash
% between a LuaLaTeX primitive and a gridset macro
letsavepos=relax
usepackagegridset

usepackagetikz
usepackageeso-pic

% Draw the baseline grid
AddToShipoutPictureAtTextLowerLeft
begintikzpicture[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);%
endtikzpicture%
%

begindocument

vskipnextgrid % start aligned to grid
Foo
parvspace5pt % force us off the grid
vskipnextgrid % force us back onto the grid
Bar

enddocument



This fails to compile with the following errors:


! Missing endcsname inserted.
<to be read again>
edef
l.2 ...edef }14651593678643290177537844659

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 }14651593678643290177537844659

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 }14651593678643290177537844659

You have used the position name `edef ' you are using on page `1'
already on page `pos@ edef @pageendcsname '.
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 }14651593678643290177537844659

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 }14651593678643290177537844659

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 }14651593678643290177537844659

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 }14651593678643290177537844659

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 }14651593678643290177537844659

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 }14651593678643290177537844659

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 }14651593678643290177537844659

If you say, e.g., `defa1...', 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 }14651593678643290177537844659

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 begindocument.

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

l.2 ...edef }14651593678643290177537844659

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 #1endcsname

l.2 ...edef }14651593678643290177537844659

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

! Missing endcsname inserted.
<to be read again>
edef
l.2 ...edef }14651593678643290177537844659

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 }14651593678643290177537844659

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 }14651593678643290177537844659

If you say, e.g., `defa1...', 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 }14651593678643290177537844659

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 #1endcsname

l.2 ...edef }14651593678643290177537844659

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

! Missing endcsname inserted.
<to be read again>
edef
l.2 ...edef }14651593678643290177537844659

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 }14651593678643290177537844659

If you say, e.g., `defa1...', 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 }14651593678643290177537844659

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 }14651593678643290177537844659

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

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

l.2 ...edef }14651593678643290177537844659

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

! Missing endcsname inserted.
<to be read again>
edef
l.2 ...edef }14651593678643290177537844659

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 }14651593678643290177537844659

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 }14651593678643290177537844659

If you say, e.g., `defa1...', 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 }14651593678643290177537844659

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 #1endcsname

l.2 ...edef }14651593678643290177537844659

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

! Missing endcsname inserted.
<to be read again>
edef
l.2 ...edef }14651593678643290177537844659

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 }14651593678643290177537844659

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 }14651593678643290177537844659

If you say, e.g., `defa1...', 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 }14651593678643290177537844659

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 }14651593678643290177537844659

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

! Missing endcsname inserted.
<to be read again>
edef
l.2 ...edef }14651593678643290177537844659

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 }14651593678643290177537844659

If you say, e.g., `defa1...', 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 #1endcsname

l.2 ...edef }14651593678643290177537844659

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

! Missing number, treated as zero.
<to be read again>
)
l.2 ...edef }14651593678643290177537844659

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 }14651593678643290177537844659

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 }14651593678643290177537844659

Please don't say `def cs...', say `defcs...'.
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 }14651593678643290177537844659

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?






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 '18 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 letsavepos=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 '18 at 10:18


tikz


letsavepos=relax


gridset


gridset


savepos




1 Answer
1



You could try this patches.


letstoredsavepossavepos
letsaveposundefined
usepackagegridset
letgridsetsavepossavepos
letsaveposstoredsavepos

usepackagexpatch
xpatchcmdvskipnextgridsaveposgridsetsaveposfail
xpatchcmdvskipnextgridsaveposgridsetsaveposfail



And alternative patch for tikz is


usepackagetikz
usepackagexpatch

makeatletter
xpatchcmdpgfsys@markpositionsaveposprimitivesaveposfail



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 '18 at 10:42



gridset






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 '18 at 10:48



Thanks for contributing an answer to TeX - LaTeX Stack Exchange!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




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.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

How do I collapse sections of code in Visual Studio Code for Windows?

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ