haroldthimbleby / improving-science

Paper, supplementary material and all data for a paper "Improving science that uses code"
2 stars 0 forks source link

LaTeX compilation failures #6

Closed khinsen closed 1 year ago

khinsen commented 1 year ago

The make pdf step fails for several reason.

First, there are duplicated backslashes in several of the generated files. I patched two files (see below), which seems to fix all these issues. But then I get another error message that I don't see how to fix:

! Undefined control sequence.
\f@nch@orf ...t \ \thepage /\SupplementalLastPage 
                                                  \strut 

Patches

In programs/data.js:

@@ -1088,9 +1088,9 @@ for (var i = 0; i < data.length; i++) {
     }
 }
 s += "( echo \"% date generated by running generated/allGitRepos.sh downloading Git repos\";\n" +
-    "echo \\\\\\\\def\\\\\\\\clonedate {\\\\\\\\ignorespaces `date \"+%e %B %Y\"`}\n" +
-    "echo \\\\\\\\\def\\\\\\\\cloneyear {`date \"+%Y\"`}\n" +
-    "echo \\\\\\\\def\\\\\\\\clonemonth {`date \"+%m\"`}\n" +
+    "echo \\\\def\\\\clonedate {\\\\ignorespaces `date \"+%e %B %Y\"`}\n" +
+    "echo \\\\\def\\\\cloneyear {`date \"+%Y\"`}\n" +
+    "echo \\\\def\\\\clonemonth {`date \"+%m\"`}\n" +
     ") > ../generated/clone-date.tex\n";

 saveFile("generated/allGitRepos.sh", s, "Shell script to download all available " + n + " GitHub repositories \n       generated/clone-date.tex - Running the download script also saves the download dates of GitHub clones")

In programs/make-metadata.sh:

@@ -1,11 +1,11 @@
 echo % shell script "(make-metadata.sh)" generated LaTeX variable values counting errors detected by data.js > generated/metadata.tex

 # how many errors can data.js find?
-echo \\\\newcount \\\\JSONerrorCount >> generated/metadata.tex
-echo \\\\JSONerrorCount = `grep "error(" programs/data.js|wc -l` >> generated/metadata.tex
+echo \\newcount \\JSONerrorCount >> generated/metadata.tex
+echo \\JSONerrorCount = `grep "error(" programs/data.js|wc -l` >> generated/metadata.tex

 # put count of variables (number registers plus macro definitions) to \JSONvariableCount
-echo \\\\newcount \\\\dataVariableCount >> generated/metadata.tex
-echo \\\\dataVariableCount = `egrep "(newcount)|(\\\\\\\\def)" generated/*|wc -l` >> generated/metadata.tex
+echo \\newcount \\dataVariableCount >> generated/metadata.tex
+echo \\dataVariableCount = `egrep "(newcount)|(\\\\def)" generated/*|wc -l` >> generated/metadata.tex
haroldthimbleby commented 1 year ago

Ah - the macro \SupplementalLastPage is defined at the end of a run, on the last page. Next time the page footer gives the page number and the total number of pages. If there is no .aux file, that failed.

Now changed so that the footer is conditional: if \SupplementalLastPage is not defined, there is a warning rather than a failure; if \SupplementalLastPage is defined, its value is used. The alternative would be to interactively type r to TeX to ignore the error - but of course that also ignores any other errors and therefore isn't as safe as this solution.

haroldthimbleby commented 1 year ago

thanks for all your work.

This problem happened [past tense:-] because the macro \SupplementalLastPage was defined at the end of a run, on the last page. Next time the page footer then gives the page number and the total number of pages.

However, if there is no .aux file - or if there has been any early termination of the Latex run so \SupplementalLastPage never gets to typeset the last page - the idea failed.

Now fixed so that the footer is conditional, so if \SupplementalLastPage is not defined, there is a warning rather than a failure; or if \SupplementalLastPage is defined, its value is used.

The alternative - which I'd been using without thinking - was to interactively type r to TeX to ignore the error, so that the run completes and \SupplementalLastPage gets defined - but of course that also ignores any other errors and therefore isn't as robust as this new solution.

best,

Harold

Prof. Harold Thimbleby PhD FLSW FRCPE HonFRSA HonFRCP See Change Fellow in Digital Health Fix IT - see https://tinyurl.com/3hkrazdp Web site - http://harold.thimbleby.net

On Thu, 23 Feb 2023 at 16:29, Konrad Hinsen @.***> wrote:

The make pdf step fails for several reason.

First, there are duplicated backslashes in several of the generated files. I patched two files (see below), which seems to fix all these issues. But then I get another error message that I don't see how to fix:

! Undefined control sequence. @.***@orf ...t \ \thepage /\SupplementalLastPage \strut

Patches

In programs/data.js:

@@ -1088,9 +1088,9 @@ for (var i = 0; i < data.length; i++) { } } s += "( echo \"% date generated by running generated/allGitRepos.sh downloading Git repos\";\n" +

  • "echo \\\\def\\\\clonedate {\\\\ignorespaces date \"+%e %B %Y\"}\n" +
  • "echo \\\\\def\\\\cloneyear {date \"+%Y\"}\n" +
  • "echo \\\\def\\\\clonemonth {date \"+%m\"}\n" +
  • "echo \\def\\clonedate {\\ignorespaces date \"+%e %B %Y\"}\n" +
  • "echo \\\def\\cloneyear {date \"+%Y\"}\n" +
  • "echo \\def\\clonemonth {date \"+%m\"}\n" + ") > ../generated/clone-date.tex\n";

    saveFile("generated/allGitRepos.sh", s, "Shell script to download all available " + n + " GitHub repositories \n generated/clone-date.tex - Running the download script also saves the download dates of GitHub clones")

In programs/make-metadata.sh:

@@ -1,11 +1,11 @@ echo % shell script "(make-metadata.sh)" generated LaTeX variable values counting errors detected by data.js > generated/metadata.tex

how many errors can data.js find?

-echo \\newcount \\JSONerrorCount >> generated/metadata.tex -echo \\JSONerrorCount = grep "error(" programs/data.js|wc -l >> generated/metadata.tex +echo \newcount \JSONerrorCount >> generated/metadata.tex +echo \JSONerrorCount = grep "error(" programs/data.js|wc -l >> generated/metadata.tex

put count of variables (number registers plus macro definitions) to \JSONvariableCount

-echo \\newcount \\dataVariableCount >> generated/metadata.tex -echo \\dataVariableCount = egrep "(newcount)|(\\\\\\\\def)" generated/*|wc -l >> generated/metadata.tex +echo \newcount \dataVariableCount >> generated/metadata.tex +echo \dataVariableCount = egrep "(newcount)|(\\\\def)" generated/*|wc -l >> generated/metadata.tex

— Reply to this email directly, view it on GitHub https://github.com/haroldthimbleby/Software-Enginering-Boards/issues/6, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEMNBTEDQ2NITLCLQMZ6A6DWY6F6XANCNFSM6AAAAAAVF3IBCQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>