latex3 / latex2e

The LaTeX2e kernel
https://www.latex-project.org/
LaTeX Project Public License v1.3c
1.87k stars 262 forks source link

Latex3 error message \g__tag_in_mc_bool has not been declared #609

Closed kellijohnson-NOAA closed 3 years ago

kellijohnson-NOAA commented 3 years ago

Brief outline of the bug

I maintain an Rmarkdown template for writing documents related to fisheries management within the US Federal government. A colleague alerted me that her document was no longer building and she was getting the following error.

! LaTeX3 Error: The variable \g__tag_in_mc_bool has not been declared on line
(LaTeX3)        291.

So, I built the basic template on my machine and I did not receive any errors. Then I went to github where I store the R package and checked github actions. The last build was from 14 days ago. It was successful and it hadn't been built since because it only checks upon a recent push. I then pushed a trivial commit that I needed anyway to see if it would fail. It did indeed with the same error message that my colleague got just a different line reference. The github action uses Ubuntu and my colleague and I are both on Windows.

I tried, removing the lua filters, not depending on pdfmanagement-testphase, reverting back to pandoc 2.11.4 because that is what I have locally. None of that worked. I then asked an acquaintance with much more LaTeX experience if he had any suggestions, which led me to here. Something changed in the last 14 days that is leading to this difference in the resulting .tex file.

I would greatly appreciate any help you can provide because we have a deadline on Tuesday and must have a successful build by then. I apologize in advance for any gross negligence regarding standards that are not followed in my LaTeX code, just like many others, I am still learning. Nevertheless, my google searches have not been successful and I am at a loss with respect to what to do. Kind regards, Kelli

Minimal example showing the bug

I am sorry that I do not have a minimal reproducible example because I do not get the error on my machine and I do not know where there error is coming from on the remote machine. Instead, I must refer you to the files on github and what follows, which is the difference in the .tex files between my machine and my colleague's where we are both using R and the bookdown package to render multiple .Rmd files into a single tex file that is passed to pandoc, which calls lualatex along with a lua filter.

The file that compiles looks like this when you get to the reference section

\hypertarget{refs}{}
\begin{CSLReferences}{1}{0}
\leavevmode\hypertarget{ref-bradburn_2003_2011}{}%
Bradburn, M. J., A. A Keller, and B. H. Horness. 2011. {``The 2003 to 2008 {US} {West} {Coast} Bottom Trawl Surveys of Groundfish Resources Off {Washington}, {Oregon}, and {California}: Estimates of Distribution, Abundance, Length, and Age Composition.''} US Department of Commerce, National Oceanic; Atmospheric Administration, National Marine Fisheries Service.

\leavevmode\hypertarget{ref-Starr2015}{}%
Starr, R. M., D. E. Wendt, C. L. Barnes, C. I. Marks, D. Malone, G. Waltz, K. T. Schmidt, et al. 2015. {``Variation in Responses of Fishes Across Multiple Reserves Within a Network of Marine Protected Areas in Temperate Waters.''} \emph{PLoS One2} 10 (3): p.e0118502.

\leavevmode\hypertarget{ref-weinberg_2001_2002}{}%
Weinberg, K. L., M. E. Wilkins, F. R. Shaw, and M. Zimmermann. 2002. {``The 2001 {Pacific} {West} {Coast} Bottom Trawl Survey of Groundfish Resources: Estimates of Distribution, Abundance and Length and Age Composition.''} \{NOAA\} \{Technical\} \{Memorandum\} NMFS-AFSC-128. U.S. Department of Commerce.

\leavevmode\hypertarget{ref-Wendt2009}{}%
Wendt, D. E., and R. M. Starr. 2009. {``Collaborative Research: An Effective Way to Collect Data for Stock Assessments and Evaluate Marine Protected Areas in {C}alifornia.''} \emph{Marine and Coastal Fisheries: Dynamics, Management, and Ecosystem Science.} 1: 315--24.

\end{CSLReferences}

and the new file looks like this

\hypertarget{refs}{}
\begin{CSLReferences}{1}{0}
\leavevmode\vadjust pre{\hypertarget{ref-bradburn_2003_2011}{}}%
Bradburn, M. J., A. A Keller, and B. H. Horness. 2011. {``The 2003 to 2008 {US} {West} {Coast} Bottom Trawl Surveys of Groundfish Resources Off {Washington}, {Oregon}, and {California}: Estimates of Distribution, Abundance, Length, and Age Composition.''} US Department of Commerce, National Oceanic; Atmospheric Administration, National Marine Fisheries Service.

\leavevmode\vadjust pre{\hypertarget{ref-Starr2015}{}}%
Starr, R. M., D. E. Wendt, C. L. Barnes, C. I. Marks, D. Malone, G. Waltz, K. T. Schmidt, et al. 2015. {``Variation in Responses of Fishes Across Multiple Reserves Within a Network of Marine Protected Areas in Temperate Waters.''} \emph{PLoS One2} 10 (3): p.e0118502.

\leavevmode\vadjust pre{\hypertarget{ref-weinberg_2001_2002}{}}%
Weinberg, K. L., M. E. Wilkins, F. R. Shaw, and M. Zimmermann. 2002. {``The 2001 {Pacific} {West} {Coast} Bottom Trawl Survey of Groundfish Resources: Estimates of Distribution, Abundance and Length and Age Composition.''} \{NOAA\} \{Technical\} \{Memorandum\} NMFS-AFSC-128. U.S. Department of Commerce.

\leavevmode\vadjust pre{\hypertarget{ref-Wendt2009}{}}%
Wendt, D. E., and R. M. Starr. 2009. {``Collaborative Research: An Effective Way to Collect Data for Stock Assessments and Evaluate Marine Protected Areas in {C}alifornia.''} \emph{Marine and Coastal Fisheries: Dynamics, Management, and Ecosystem Science.} 1: 315--24.

\end{CSLReferences}

Log file (required) and possibly PDF file

Attached are the log and pdf files from the successful build on my local machine. _main.log _main.pdf Sorry, but I was not able to save the log file from the unsuccessful github actions run.

u-fischer commented 3 years ago

That is an error from the tagpdf package. Please report it at https://github.com/u-fischer/tagpdf/issues. And please attach a log from the failing run, a log from a run that works is useless.

And please be aware, and tell it also your collegues: tagpdf is an experimental package to investigate how tagged pdf can be done with latex. It can change at every time in incompatible ways. If you use it, then use it in a way that you that you understand and controll, so that you can produce minimal example when something fails.

u-fischer commented 3 years ago

Your code enables the debugging options of expl3 (it uses something like \RequirePackage[check-declarations,enable-debug]{expl3} and errors because one variable has not been correctly declared before its use.

The best to avoid the error for now would be not to use the debugging options. They are useful when developping code, but a lot of packages have small expl3 coding errors---I found two only while investigating your issue---and so normal documents can easily error.

If you can't disable it, declare the variable before loading tagpdf.

\ExplSyntaxOn \bool_new:N\g__tag_in_mc_bool  \ExplSyntaxOff

You will have to remove this after the next update of tagpdf, or you will get another error.

Side remark: you didn't provide a log, but I suspect that you are now using tagpdf 0.9. So be aware that it contains a number of breaking changes which can affect the actual tagging. Check the list of change in the documentation and check the tagging carefully, most importantly headers and footers.

jfine2358 commented 3 years ago

Thank you for this @u-fischer. I'm sure Kelli will also be grateful when she sees your comment.

Here's some more information. The log file Kelli attached for the run that works on her machine contains the lines

c:/Users/kelli/AppData/Roaming/TinyTeX/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-lua.sty
Package: tagpdf-mc-code-lua 2021-06-14 v0.82 tagpdf - mc code only for the luamode 

Looking at https://github.com/nwfsc-assess/sa4ss/runs/2968140404?check_suite_focus=true#step:13:181, we see a link to https://ctan.math.illinois.edu/systems/texlive/tlnet.

Looking at https://ctan.math.illinois.edu/systems/texlive/tlnet/archive/ we see

tagpdf.doc.r59769.tar.xz                           01-Jul-2021 00:03             1713988
tagpdf.doc.tar.xz                                  01-Jul-2021 00:03             1713988
tagpdf.r59769.tar.xz                               01-Jul-2021 00:03               24008
tagpdf.source.r59769.tar.xz                        01-Jul-2021 00:03               41572
tagpdf.source.tar.xz                               01-Jul-2021 00:03               41572
tagpdf.tar.xz                                      01-Jul-2021 00:03               24008

Opening one of these files I find

local ProvidesLuaModule = {
    name          = "tagpdf",
    version       = "0.9",       --TAGVERSION
    date          = "2021-06-29", --TAGDATE
    description   = "tagpdf lua code",
    license       = "The LATEX Project Public License 1.3c"
}

This seems to confirm your expert diagnois, @u-fischer, that the error is coming from use of version 0.9. Thank you. Further your diagnosis is completely consistent with and explains Kelli's opening paragraph:

So, I built the basic template on my machine and I did not receive any errors. Then I went to github where I store the R package and checked github actions. The last build was from 14 days ago. It was successful and it hadn't been built since because it only checks upon a recent push. I then pushed a trivial commit that I needed anyway to see if it would fail. It did indeed with the same error message that my colleague got just a different line reference. The github action uses Ubuntu and my colleague and I are both on Windows.

I think we're now much better placed to solve Kelli's problem:

I would greatly appreciate any help you can provide because we have a deadline on Tuesday and must have a successful build by then.

I have to go now, but will be back in about 4 hours time.

u-fischer commented 3 years ago

I think we're now much better placed to solve Kelli's problem:

@jfine2358

Please don't speak to me and Kelli as if we were children that need your assistance and encouragement to solve this. Kelli is imho quite able to check a package version if needed, and I – unlike you – know and understand the tagpdf code and what the error message means.

kellijohnson-NOAA commented 3 years ago

Thank you @u-fischer for taking the time to explain what is going wrong in my code and I apologize for not providing a failed log file. I am going to experiment now with what you suggested. One quick question, your first response suggested I should report the error to the tagpdf issue page. Would you still like me to do that once I obtain a failed log file?

u-fischer commented 3 years ago

@kellijohnson-NOAA I don't need the log to correct the error, I already did it in the source. But if you still have problems, open an issue at tagpdf, here is not the right place.

kellijohnson-NOAA commented 3 years ago

Will do and thanks again.

u-fischer commented 3 years ago

@kellijohnson-NOAA btw this here is wrong

\ExplSyntaxOn
\pdfmanagement_add:nnn{Catalog}{Lang}{(enUS)}
\ExplSyntaxOff

at first it is unneeded anyway, as this language is set by default. The value is wrong, it should be (en-US), and beside this there is an user interface \DeclareDocumentMetadata{lang=en-US}

kellijohnson-NOAA commented 3 years ago

Great, I will change that. I see here that there are some other items that can be declared in DeclareDocumentMetadata that I should probably think about as well. I know that the automated tagging is new and constantly developing, but is there a link that you can share where I can view a current .tex file with best practices?

jfine2358 commented 3 years ago

Some good news. The action on my fork of sa4ss has successfully run to completion: https://github.com/jfine2358/sa4ss/actions/runs/996459007

This would give @kellijohnson-NOAA a route to meeting her deadline of Tuesday. Except, perhaps, a new problem has arisen. Here's what I'm thinking. Earlier today @u-fischer has both corrected the bug and tagged it for ctan upload. These are respectively commits https://github.com/u-fischer/tagpdf/commit/23acfba3d5e50289d6f045acb2f2dea2d1223d5f and https://github.com/u-fischer/tagpdf/commit/deb4aa8762899805fdba12af04d3786157627fec.

It is seems to me that my fix that allowed the fork to succeed will break when today's fix from @u-fischer becomes part of TeX Live. And there's a similar statement regarding MikTeX.

Please @u-fischer would you correct me if I'm wrong. And if I'm right perhaps you could ask the TeX Live team to postpone the packaging of your tagpdf package.

u-fischer commented 3 years ago

@jfine2358 You don't need to worry. Kelli made a commit with a correction at her github too, and unlike you she did the right one which will not break with the new tagpdf version.

u-fischer commented 3 years ago

@kellijohnson-NOAA metadata as you can set in \DeclareDocumentMetadata are unrelated to tagging. If you have questions here better open an issue at https://github.com/latex3/pdfresources, or sent me a mail. The latex2e tracker is not the right place for this discussion.