What system configuration is needed for the [Scribble PDF] button in DrRacket for a scribble file, in order to work properly?

Hi friends at Racket Discourse:
I will appreciate very much recommendations about how to configure my computing environment under Windows 10, in order that the [Scribble PDF] button for rendering a scribble/base document under DrRacket, be able to work properly.

As a reference:
I've been using [Scribble-PDF] and [Scribble-HTML] buttons for scribble documents, for a couple of years now, but after I changed to a new desktop computer, I can't generate a PDF using the [Scribble PDF] button, even for the following very simple example:

#lang scribble/base
@title{Discourse}
@author{Racket}
(dialogue)

I get the following error message in the interaction window of DrRacket 8.3:

  • Program Files\Racket\share\pkgs\scribble-lib\scribble\private\run-pdflatex.rkt:16:0: run-pdflatex: got error exit code

Note 1: I get the same error message, when using MiKTeX as well as when using TeX Live.
Note 2. It seems that the problem may be related with the current way Windows do batch processing, but I don't know about how to proceed if that is the case.

Thank you in advance for any help or advice.
Please Keep Safe.
Best regards.
Enrique

1 Like

As an extra information:
The following code, shared in 2019 by rfindler ( in https://github.com/racket/drracket/issues/254 ), generates the expected PDF file:

#lang racket/base
(require scribble/private/run-pdflatex)
(call-with-output-file "tmp.tex"
  (λ (port)
    (fprintf port "\\documentclass{article}\n\\begin{document}\nhi\\end{document}\n"))
  #:exists 'truncate)
(void (run-pdflatex "tmp.tex"))

Is that the complete error message?

Actually, the whole message (mostly Warnings) is the following:

scribble: loading xref
scribble: rendering
This is pdfTeX, Version 3.141592653-2.6-1.40.23 (TeX Live 2021/W32TeX) (preloaded format=pdflatex 2022.1.5)  7 JAN 2022 22:13
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**pdf-testing.tex
(./pdf-testing.tex
LaTeX2e <2021-11-15> patch level 1
L3 programming layer <2021-11-22> (c:/texlive/2021/texmf-dist/tex/latex/base/ar
ticle.cls
Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
(c:/texlive/2021/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2021/10/04 v1.4n Standard LaTeX file (size option)
)
\c@part=\count183
\c@section=\count184
\c@subsection=\count185
\c@subsubsection=\count186
\c@paragraph=\count187
\c@subparagraph=\count188
\c@figure=\count189
\c@table=\count190
\abovecaptionskip=\skip47
\belowcaptionskip=\skip48
\bibindent=\dimen138
) (c:/texlive/2021/texmf-dist/tex/latex/base/inputenc.sty
Package: inputenc 2021/02/14 v1.3d Input encoding file
\inpenc@prehook=\toks16
\inpenc@posthook=\toks17
) (c:/texlive/2021/texmf-dist/tex/latex/base/fontenc.sty
Package: fontenc 2021/04/29 v2.0v Standard LaTeX package
) (c:/texlive/2021/texmf-dist/tex/latex/graphics/graphicx.sty
Package: graphicx 2021/09/16 v1.2d Enhanced LaTeX Graphics (DPC,SPQR)
(c:/texlive/2021/texmf-dist/tex/latex/graphics/keyval.sty
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
\KV@toks@=\toks18
) (c:/texlive/2021/texmf-dist/tex/latex/graphics/graphics.sty
Package: graphics 2021/03/04 v1.4d Standard LaTeX Graphics (DPC,SPQR)
(c:/texlive/2021/texmf-dist/tex/latex/graphics/trig.sty
Package: trig 2021/08/11 v1.11 sin cos tan (DPC)
) (c:/texlive/2021/texmf-dist/tex/latex/graphics-cfg/graphics.cfg
File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
)
Package graphics Info: Driver file: pdftex.def on input line 107.
(c:/texlive/2021/texmf-dist/tex/latex/graphics-def/pdftex.def
File: pdftex.def 2020/10/05 v1.2a Graphics/color driver for pdftex
))
\Gin@req@height=\dimen139
\Gin@req@width=\dimen140
) (c:/texlive/2021/texmf-dist/tex/latex/hyperref/hyperref.sty
Package: hyperref 2021-06-07 v7.00m Hypertext links for LaTeX
(c:/texlive/2021/texmf-dist/tex/generic/ltxcmds/ltxcmds.sty
Package: ltxcmds 2020-05-10 v1.25 LaTeX kernel commands for general use (HO)
) (c:/texlive/2021/texmf-dist/tex/generic/iftex/iftex.sty
Package: iftex 2020/03/06 v1.0d TeX engine tests
) (c:/texlive/2021/texmf-dist/tex/generic/pdftexcmds/pdftexcmds.sty
Package: pdftexcmds 2020-06-27 v0.33 Utility functions of pdfTeX for LuaTeX (HO
)
(c:/texlive/2021/texmf-dist/tex/generic/infwarerr/infwarerr.sty
Package: infwarerr 2019/12/03 v1.5 Providing info/warning/error messages (HO)
)

Package pdftexcmds Info: \pdf@primitive is available.
Package pdftexcmds Info: \pdf@ifprimitive is available.
Package pdftexcmds Info: \pdfdraftmode found.
) (c:/texlive/2021/texmf-dist/tex/generic/kvsetkeys/kvsetkeys.sty
Package: kvsetkeys 2019/12/15 v1.18 Key value parser (HO)
) (c:/texlive/2021/texmf-dist/tex/generic/kvdefinekeys/kvdefinekeys.sty
Package: kvdefinekeys 2019-12-19 v1.6 Define keys (HO)
) (c:/texlive/2021/texmf-dist/tex/generic/pdfescape/pdfescape.sty
Package: pdfescape 2019/12/09 v1.15 Implements pdfTeX's escape features (HO)
) (c:/texlive/2021/texmf-dist/tex/latex/hycolor/hycolor.sty
Package: hycolor 2020-01-27 v1.10 Color options for hyperref/bookmark (HO)
) (c:/texlive/2021/texmf-dist/tex/latex/letltxmacro/letltxmacro.sty
Package: letltxmacro 2019/12/03 v1.6 Let assignment for LaTeX macros (HO)
) (c:/texlive/2021/texmf-dist/tex/latex/auxhook/auxhook.sty
Package: auxhook 2019-12-17 v1.6 Hooks for auxiliary files (HO)
) (c:/texlive/2021/texmf-dist/tex/latex/kvoptions/kvoptions.sty
Package: kvoptions 2020-10-07 v3.14 Key value format for package options (HO)
)
\@linkdim=\dimen141
\Hy@linkcounter=\count191
\Hy@pagecounter=\count192
(c:/texlive/2021/texmf-dist/tex/latex/hyperref/pd1enc.def
File: pd1enc.def 2021-06-07 v7.00m Hyperref: PDFDocEncoding definition (HO)
Now handling font encoding PD1 ...
... no UTF-8 mapping file for font encoding PD1
) (c:/texlive/2021/texmf-dist/tex/latex/hyperref/hyperref-langpatches.def
File: hyperref-langpatches.def 2021-06-07 v7.00m Hyperref: patches for babel la
nguages
) (c:/texlive/2021/texmf-dist/tex/generic/intcalc/intcalc.sty
Package: intcalc 2019/12/15 v1.3 Expandable calculations with integers (HO)
) (c:/texlive/2021/texmf-dist/tex/generic/etexcmds/etexcmds.sty
Package: etexcmds 2019/12/15 v1.7 Avoid name clashes with e-TeX commands (HO)
)
\Hy@SavedSpaceFactor=\count193
(c:/texlive/2021/texmf-dist/tex/latex/hyperref/puenc.def
File: puenc.def 2021-06-07 v7.00m Hyperref: PDF Unicode definition (HO)
Now handling font encoding PU ...
... no UTF-8 mapping file for font encoding PU
)

(some fragments omitted)

amsthm NOT loaded



! LaTeX Error: Command \widebar already defined.
               Or name \end... illegal, see p.192 of the manual.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.3152 ...^{{\wide@bar{#1}{0}}}{\wide@bar{#1}{1}}}
                                                  
Your command was ignored.
Type  I <command> <return>  to replace it with another command,
or  <return>  to continue without it.

(some fragments omitted)

Package rerunfilecheck Warning: File `pdf-testing.out' has changed.
(rerunfilecheck)                Rerun to get outlines right
(rerunfilecheck)                or use package `bookmark'.

Package rerunfilecheck Info: Checksums for `pdf-testing.out':
(rerunfilecheck)             Before: <no file>
(rerunfilecheck)             After:  D41D8CD98F00B204E9800998ECF8427E;0.
 ) 
Here is how much of TeX's memory you used:
 14658 strings out of 478353
 207280 string characters out of 5852096
 478929 words of memory out of 5000000
 32529 multiletter control sequences out of 15000+600000
 429301 words of font info for 74 fonts, out of 8000000 for 9000
 1141 hyphenation exceptions out of 8191
 60i,6n,63p,247b,335s stack positions out of 5000i,500n,10000p,200000b,80000s
{c:/texlive/2021/texmf-dist/fonts/enc/dvips/base/8r.enc}<c:/texlive/2021/texm
f-dist/fonts/type1/urw/times/utmr8a.pfb>
Output written on pdf-testing.pdf (1 page, 13387 bytes).
PDF statistics:
 19 PDF objects out of 1000 (max. 8388607)
 13 compressed objects within 1 object stream
 2 named destinations out of 1000 (max. 500000)
 1 words of extra memory for PDF output out of 10000 (max. 10000000)

. . ..\..\..\Program Files\Racket\share\pkgs\scribble-lib\scribble\private\run-pdflatex.rkt:96:25: run-pdflatex: got error exit code

The first error fragment is:

! LaTeX Error: Command \widebar already defined.
               Or name \end... illegal, see p.192 of the manual.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.3152 ...^{{\wide@bar{#1}{0}}}{\wide@bar{#1}{1}}}

(Some fragments were omitted, because in total the message was 46, 577 chars long).

Thank you in advance for your advice.

I'm not sure what the best path forward is but it looks like the code generated by scribble and the specifics of your latex installation (likely the versions of the various latex packages) don't get a long. I'm using texlive 2021 on my machine and that seems to work okay.

One thing to make sure when you've got both miktex and tex live installed is to make sure that run-pdflatex is actually getting the right one. It may be getting miktex twice, possibly?

Sorry this isn't much to go on.

Thank you @robby for the idea of possible conflicting latex packages.

With my scribble file (pdf-testing.scrbl) I made the following steps and "manually" obtained the PDF w/o errors:

1. scribble --latex pdf-testing.scrbl
2. commented out the line: \packageMathabx (in file pdf-testing.tex)
3. pdflatex pdf-testing.tex

If I use directly the command: scribble --pdf pdf-testing.scrbl, the pdf is not generated due to the errors mentioned previously.

BTW, the commented out line: \packageMathabx, comes right after the line \packageAmsmath in the generated .tex file.

The question now is (may be), how to configure scribble, not to include \packageMathabx, if we use \packageAmsmath. This, in order for the [Scribble PDF] button to work w/o errors.

Thank you again for any pointer or advice concerning this issue.

Maybe you want to use a style file that has something like \renewcommand{\packageMathabx}{\relax}?

Thank you again @robby .
I made the experiment with the following code (in pdf-testing3.scrbl)

#lang scribble/base
@require[
  (only-in scribble/core make-style)
  (only-in scribble/latex-properties make-tex-addition)]
@(define extra-style-files
   (list (make-tex-addition "adhoc-style.tex")))
@(define adhoc-style
   (make-style #f extra-style-files))
@title[#:style adhoc-style]{Discourse}
@author{Racket}
(dialogue)

Where in the file adhoc-style.tex we have the line:
\renewcommand{\packageMathabx}{\relax}

With the above code, I run the following command:
scribble ++latex pdf-testing3.scrbl

The result was that (in the .tex file) the latex code \renewcommand{\packageMathabx}{\relax} was inserted just before the line \begin{document}. And running the command:
pdflatex --pdf pdf-testing3.tex,
results in the same error as before.

On the other hand, if the line: \renewcommand{\packageMathabx}{\relax}, is inserted after the line:
\newcommand{\packageMathabx}{\usepackage{mathabx}}
but before the line \packageMathabx,
then the PDF is generated correctly.

Thank you very much for any further idea or suggestion to solve this problem.

The default "scribble.tex" [1] file contains:

\packageAmsmath
\packageMathabx

The acmart package shows a way of avoiding package conflicts:

Maybe a similar approach could be used?

@encomer As a temporary workaround you could delete the line \packageMathabx
from your "scribble.tex". But maybe it breaks something else?

[1] scribble/scribble.tex at master · racket/scribble · GitHub

Thank you very much @soegaard . With your suggestion, I added the following code (between \packageAmsmath, and \packageMathabx) in my local copy of scribble.tex:

\packageAmsmath

% In order to prevent package conflict the following line is added:
\renewcommand\packageMathabx{\ifx\frac\undefined \usepackage{mathabx} \else \relax \fi}
% The above line is similar to the code used in: acmart/acmart-load.tex
% Both 'mathabx' and 'amsmath' define a '\frac' command (among others).

\packageMathabx

After the above change, the [Scribble PDF] button (in DrRacket, with my .scrbl file) produced the PDF file w/o errors.

As you said, this is a temporal solution, but is sufficient to keep working with this great tool that is Scribble.

@robby and @soegaard , thank you very much for your help and support, and congratulations for all your work.
Best regards.

I think this is the way the APIs are intended to be used in this case. (Note that you do not need to specify any command-line arguments with this approach.)

#lang scribble/base
@(require (only-in scribble/core make-style)
          (only-in scribble/latex-properties latex-defaults))
@(define my-style
   (make-style
    #f
    (list (latex-defaults (list 'collects #"scribble" #"scribble-prefix.tex")
                          #"\\renewcommand{\\packageMathabx}{\\relax}\n"
                          '()))))
@title[#:style my-style]{Discourse}
@author{Racket}
(dialogue)

hth,
Robby

Thank you @robby . I used the code with (latex-defaults ...) as indicated, but I run into the same former problem: May be it's because the line "\renewcommand{\packageMathabx}{\relax}" do not get included before the calling of \packageMathabx.

It would be nice, to omit the local edition of scribble.tex, may be with the help of some optional parameter in @title for a future version, or by using the method of Tools in Preferences for DrRacket, but applied to packages used in Scribble, just to mention a possible idea. But if this issue is not happening to other users, then I can do the "manual" change in my local copy of scribble.tex. The temporal solution works fine to me.

I appreciate very much all your help and support.
Please Keep Safe.
Enrique

Oh, I see what you mean! One of these arguments puts it too late and the other puts it too early. I'll keep poking around but I think the whole setup with the \packageMathabx macro was precisely for the problem you're facing here. I'm sorry that I can't recall how this goes and even sorrier that the docs aren't helping us out here!

Okay, I got a little help from @mflatt and this is probably what you want.

#lang scribble/base
@(require (only-in scribble/core make-style)
          (only-in scribble/latex-properties latex-defaults+replacements))

@(define my-style
   (make-style
    #f
    (list (latex-defaults+replacements
           (list 'collects #"scribble" #"scribble-prefix.tex")
           (list 'collects #"scribble" #"scribble-style.tex")
           '()
           (hash "scribble-load-replace.tex" #"\\renewcommand{\\packageMathabx}{\\relax}\n")))))
@title[#:style my-style]{Discourse}
@author{Racket}
(dialogue)
1 Like

Thank you @robby .
Great. I tested the code that you provided, and it works perfectly well. Now there is no need to modify the scribble.tex, as before. Still, is good to have the alternative scribble.tex modification solution, because it looks more transparent to the editor of scribble documents, that may face regularly this problem with the macro \packageMathabx.

I appreciate very much all your support (as well as @soegaard and @mflatt) in having solved this issue.
Congratulations for all your fine work.
Please Keep Safe.
Enrique