acmart icon indicating copy to clipboard operation
acmart copied to clipboard

acmart class is incompatible with delayed figures of tikzexternalize and lualatex under some unclear conditions?

Open JasonGross opened this issue 4 years ago • 4 comments

I'm very confused by this error, and in particular how sensitive it is to things like the number of characters in section titles, and whether or not I stick any space between \begin{abstract} and \end{abstract}.

Consider the following document in test.tex:

\RequirePackage{luatex85}
\documentclass{acmart}
\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{external}
\tikzexternalize
\begin{document}
\title{}
\begin{abstract} \end{abstract}
\maketitle
\section{XXXXXXXXX}\subsection{X XXXXXXXXXX XXXXXXX}\subsection{XXXXXXXX XX XXXXXXXXXXXXXXXXX XXXX}\subsection{XXX XXXXXXXX}
\section{XXXXXX XXXXXXXXXX XXX XXXXXXXXX}\subsection{XXX XXXXXXXX XX XXXX XXXXX}
\section{XXX XXXXXXXXX XX X XXXXXXXX}\subsection{XXXXXXXXXXXXXXXX XXXXXXXXXXX XXX XXXXXXXXXX}
\subsection{XXXXXX XXXXXXXXXXXX XXXXXXXX}
\section{XXXXXXX XXXXXXXXXX}\subsection{XXXXXXXX XXXXXXXXXXXX XXXX XX XXXXX}\subsection{XXXXXXX XXXXXXX XX XXXXXXX}
\subsection{XXXXX XXXX XXXX XXXXXXXXXX}\subsection{XXXX XXXXXXXXXX XXXX XXXXXXXX XXXXXXXXXXXXXX}
\subsection{XXXXXXXXXXX XXX XXXXXXXXXXXXX}
\section{XXXXXXXXXX}\subsection{XXXXXXXXXXXXXXX}
\begin{tikzpicture}
    \begin{axis}
        \addplot [color=black,solid,line width=1.0pt,domain=0:1,samples=11]{x+x^2};
        \addlegendentry{Eq. \ref{eq:equation}};
    \end{axis}
\end{tikzpicture}
\subsubsection{XXXXXXXXX XXXXX XXXXXXX}\subsubsection{XXXXXXXXXXX XXXXXXXXXXX XX XXXXXXXXXXXXXXX XXXXXXXXX}
\subsubsection{XXXXXXX XXX XXXXXXXXX XXXXXXXXX}\subsubsection{XXXX XXXXXXXXX}\subsection{XXXXXXXXXXXXXXX XXXX XXXXXXXXXXXX}
\section{XXXXXXX XXXX}
\section{XXXXXX XXXX}
\end{document}

Running rm -f test-* test.a* test.b* test.p* test.s* test.o* test.l*; lualatex -shell-escape test.tex gives a log that ends with

LaTeX Warning: Reference `TotPages' on page 1 undefined on input line 10.

(/usr/share/texlive/texmf-dist/tex/latex/microtype/mt-msa.cfg)
(/usr/share/texlive/texmf-dist/tex/latex/microtype/mt-msb.cfg)
===== 'mode=convert with system call': Invoking 'lualatex -shell-escape -halt-o
n-error -interaction=batchmode -jobname "test-figure0" "\def\tikzexternalrealjo
b{test}\input{test}"' ========
This is LuaTeX, Version 1.10.0 (TeX Live 2019/Debian)
 system commands enabled.
LaTeX Warning: External picture `test-figure0' contains undefined references on
 input line 24.

===== The previous system call resulted in undefined references inside of the o
utput file. Rescheduling it for \end{document}. ========

Underfull \vbox (badness 10000) has occurred while \output is active

LaTeX Warning: Reference `LastPage' on page 1 undefined on input line 24.

[1.1{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] [2.2<./test-figure0.pd
f>] [3.3] (./test.aux

Package atenddvi Warning: Rerun LaTeX, last page not yet found.

)
===== tikzexternal: \end{document} reached. Working on rescheduled images to re
solve references... ========
===== 'mode=convert with system call': Invoking 'lualatex -shell-escape -halt-o
n-error -interaction=batchmode -jobname "test-figure0" "\def\tikzexternalrealjo
b{test}\input{test}"' ========
This is LuaTeX, Version 1.10.0 (TeX Live 2019/Debian)
 system commands enabled.

! Package tikz Error: Sorry, the system call 'lualatex -shell-escape -halt-on-e
rror -interaction=batchmode -jobname "test-figure0" "\def\tikzexternalrealjob{t
est}\input{test}"' did NOT result in a usable output file 'test-figure0' (expec
ted one of .pdf:.jpg:.jpeg:.png:). Please verify that you have enabled system c
alls. For pdflatex, this is 'pdflatex -shell-escape'. Sometimes it is also name
d 'write 18' or something like that. Or maybe the command simply failed? Error
messages can be found in 'test-figure0.log'. If you continue now, I'll try to t
ypeset the picture.

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

l.28 \end{document}

?

The proximate cause of this error is that, at this point, the contents of test.out ends with

\BOOKMARK [1][-]{section.6}{\376\377\0006\000\040\000X\000X\000X\000X\000X\000X\000X\000\040\000X\000X\000X\000X}{}% 20
\BOOKMARK [1][-]{section.7}{\376\377\0007\000\040\000X\000X\000X\000X\000X\000X\000\040\000X\000X\000X\000X}{

Yes, it ends in the middle of a \BOOKMARK, as suggested by the error in test-figure0.log:

(./test.out)
Runaway argument?
{
! File ended while scanning use of \@@BOOKMARK.
<inserted text>
\par
l.7 \begin{document}

I have no idea why this happens (and I'd like to understand), but what's even stranger is the small changes that result in the code passing fine. A non-exhaustive list:

  • I think that replacing any instance of X X with either XX in the document (removing a single space in any of the section titles) makes the error go away. (I'm not patient enough to test this, but I tried three different instances and all three made the error go away.)
  • I think that removing any X (shortening the length of any title by one) results in the code passing fine. (Again, I'm not patient enough to test this, but I tried three different instances and all three made the error go away.)
  • In some instances, replacing X X with XXX (replacing a single space with an X in the section titles) results in the error going away (in other places it does not).
  • Removing the space between \begin{abstract} and \end{abstract} makes the error go away.

Somewhat more importantly:

  • Using pdflatex rather than lualatex makes the error go away (but I cannot use pdflatex in my real example because some of my plots are too big)
  • Using article rather than acmart makes the error go away.

The complete log is available at https://github.com/JasonGross/test-latex-errors/runs/2797632506?check_suite_focus=true, and, in case that ever goes away, I've attached it as acmart-test.log.

(It's possible that this is in fact a bug in some other package, given how sensitive it is to changes.)

JasonGross avatar Jun 10 '21 21:06 JasonGross

Hello Jason,

On 11 Jun 2021, at 7:20 am, Jason Gross @.@.>> wrote:

Somewhat more importantly:

  • Using pdflatex rather than lualatex makes the error go away (but I cannot use pdflatex in my real example because some of my plots are too big)

You can increase the extra_mem_top and extra_mem_bot parameters in …/texmf-dist/web2c/texmf.cnf to increase the amount of memory available to pdftex “on-the-fly”. (i.e., you do not need to remake format files; very convenient.)

On a Mac, the full location of the config file is:

/usr/local/texlive/2021/texmf-dist/web2c/texmf.cnf

Or maybe a different year, if you are not fully up-to-date. My own settings are:

main_memory = 5000000 % words of inimemory available; also applies to inimf&mp extra_mem_top = 5000000 % extra high memory for chars, tokens, etc. extra_mem_bot = 5000000 % extra low memory for boxes, glue, breakpoints, etc.

  • Using article rather than acmart makes the error go away.

The complete log is available at https://github.com/JasonGross/test-latex-errors/runs/2797632506?check_suite_focus=true, and, in case that ever goes away, I've attached it as acmart-test.loghttps://github.com/borisveytsman/acmart/files/6634491/acmart-test.log.

(It's possible that this is in fact a bug in some other package, given how sensitive it is to changes.)

Hope this helps.

Ross

Dr Ross Moore Department of Mathematics and Statistics 12 Wally’s Walk, Level 7, Room 734 Macquarie University, NSW 2109, Australia T: +61 2 9850 8955 | F: +61 2 9850 8114 M:+61 407 288 255 | E: @.@.> http://www.maths.mq.edu.au @.***D030BE.D37A46F0] CRICOS Provider Number 00002J. Think before you print. Please consider the environment before printing this email.

This message is intended for the addressee named and may contain confidential information. If you are not the intended recipient, please delete it and notify the sender. Views expressed in this message are those of the individual sender, and are not necessarily the views of Macquarie University. http://mq.edu.au/ http://mq.edu.au/

ozross avatar Jun 10 '21 22:06 ozross

In production tikz fragments are not very suitable anyway. You may want to create tikzplots separately and save as pdfs.

borisveytsman avatar Jun 11 '21 19:06 borisveytsman

I wanted to chime in that it's most likely an interaction between hyperref (loaded by acmart and tikzexternalize).

As a current workaround, providing \PassOptionsToPackage{bookmarks=false}{hyperref} before loading \documentclass{acmart} fixes the problem.

If you don't require bookmarks by hyperref, you might also consider not loading the bookmarks functionality in your docmentclass definition.

ORippler avatar Jan 14 '22 10:01 ORippler

There are a couple more details on my tex.se question, but not very many.

JasonGross avatar Jan 14 '22 14:01 JasonGross