Scribble to PDF pain

I'm struggling to get my scribble setup working to produce pdfs.

System: Mac M1
Racket: 8.3 CS
LaTex: MacTex 2022

With the mouse example from the docs

#lang scribble/base

@title{On the Cookie-Eating Habits of Mice}

If you give a mouse a cookie, he's going to ask for a
glass of milk.

I get errors similar to What system configuration is needed for the [Scribble PDF] button in DrRacket for a scribble file, in order to work properly? and following some of that got things kind of working by:

  1. scribble --latex mouse.scrbl
  2. commenting out the two \packageMathabx references in the mouse.tex file
  3. pdflatex mouse.tex

And then got lost following the other suggestions.

Given that this error occurred following the simplest example in the manual, what do yo advise?

2 Likes

I ran it at the command line w/o any “tricks” and I got a fine PDF:

[matthias@texas ~/Books/srsd ]  cat > foo.scrbl 
#lang scribble/base

@title{On the Cookie-Eating Habits of Mice}

If you give a mouse a cookie, he's going to ask for a
glass of milk.
[matthias@texas ~/Books/srsd ] scribble --dest Tmp/ --pdf foo.scrbl 
 [Output to Tmp/foo.pdf]
[matthias@texas ~/Books/srsd ] open Tmp/foo.pdf 
[matthias@texas ~/Books/srsd ] racket --version 
Welcome to Racket v8.5.0.8 [cs].

I also ran it via —latex and it ran fine:

[matthias@texas ~/Books/srsd ] scribble --dest Tmp/ --latex foo.scrbl 
 [Output to Tmp/foo.tex]
[matthias@texas ~/Books/srsd ] cd Tmp/
[matthias@texas ~/Books/srsd/Tmp ] pdflatex foo.tex 
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./foo.tex
LaTeX2e <2020-02-02> patch level 5
L3 programming layer <2020-03-06>
…

LaTeX Font Warning: Some font shapes were not available, defaults substituted.


LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.

 ){/usr/local/texlive/2020/texmf-dist/fonts/enc/dvips/base/8r.enc}</usr/local/t
exlive/2020/texmf-dist/fonts/type1/urw/times/utmr8a.pfb>
Output written on foo.pdf (1 page, 13636 bytes).
Transcript written on foo.log.
[matthias@texas ~/Books/srsd/Tmp ] 

My guess is that plain 8,5 would work, too. If not, I’d work with the snapshot.

Hmmm

Tried again with 8.5, same error when going straight to PDF, and commenting out the packageMathabx references in mouse.scrbl "worked" as before.

Dan

I recommend upgrading to the Racket snapshot for now:

https://snapshot.racket-lang.org

Dan:

LaTex: MacTex 2022

MF:

/usr/local/texlive/2020

There could be a change in LaTeX.

Dan:
What is the exact error, you get?
[I mean the error text from LaTeX]

1 Like

indeed. I thought I had upgraded TeX on all my machines:


[matthias@antarctica ~/Tmp ] pdflatex foo
This is pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2022) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
(./foo.tex
LaTeX2e <2021-11-15> patch level 1
L3 programming layer <2022-02-24>
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/article.cls
Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/inputenc.sty)
pe)
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/ifthen.sty)
(/usr/local/texlive/2022/texmf-dist/tex/latex/etoolbox/etoolbox.sty)
(/usr/local/texlive/2022/texmf-dist/tex/generic/iftex/ifxetex.sty)
(/usr/local/texlive/2022/texmf-dist/tex/generic/iftex/ifluatex.sty)
(/usr/local/texlive/2022/texmf-dist/tex/latex/xkeyval/xkeyval.sty
(/usr/local/texlive/2022/texmf-dist/tex/generic/xkeyval/xkeyval.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/xkeyval/xkvutils.tex)))
(/usr/local/texlive/2022/texmf-dist/tex/latex/oberdiek/centernot.sty)
(/usr/local/texlive/2022/texmf-dist/tex/generic/kastrup/binhex.tex)

….
….

! 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.3155 ...^{{\wide@bar{#1}{0}}}{\wide@bar{#1}{1}}}

?

I recommend running —latex first, then the following script, then pdflatex:


#lang at-exp racket

(provide
;; comment out the latex package commands in TABLE because they interfere with each other
main)

;; ---------------------------------------------------------------------------------------------------
(define TABLE
`[ "packageWasysym"
"packageTxfonts" ])

(define (main . opt-file)
(define FILE (and (cons? opt-file) (first opt-file)))
(displayln " ********************************* FIXING ********************************* ")

(define lines (if FILE (file->lines FILE #:mode 'text) (port->lines)))
(define next
(for/list ([line lines])
(for/fold ([line line]) ([row TABLE])
(regexp-replace (~a "^\\\\" row) line (~a "%% \\\\" row )))))

(if FILE
(with-output-to-file FILE #:exists 'replace (λ () (for-each displayln next)))
(with-output-to-string (λ () (for-each displayln next)))))

(Posted w/o tests. See racket/scribble issues for full scripy.)

Hi Jens

I get no error from scribble --latex mouse.scrbl

Then I run pdflatex mouse.tex and after a bunch of warnings I get

! 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.3155 ...^{{\wide@bar{#1}{0}}}{\wide@bar{#1}{1}}}```

Sounds like this issue:

and

1 Like

Sounds like this issue ...

Yes, it sounds like the same issue.

BTW: Have you noticed a change in how diagrams generated using 2htdp/image appear about 3x larger in pdfs generated via Scribble lately?

1 Like

I am late to this discussion.

I ran into this problem and proposed a fix

I would appreciate if anyone who is latex-savvy review this pull request

4 Likes

Thanks. I didn’t notice the PR. I used it on the Dan’s latex file and it solves his problem.
(There are other problems in different contexts that I work around with the script that I posted.)

2 Likes

Hello @danprager:
If there is still a chance for you to do a little test, you can try the following code that was shared by @robby (in the link that you mentioned). In my case it solved the problem (that was very similar to yours). It may work fine in your case, also.

#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)

Best regards,
E. C.

1 Like

Hi Enrique

I ran @robby's example code that you posted — I may also have done so at the time — and it still gives the error in my set-up ...

! LaTeX Error: Command \widebar already defined.

If I comment out \packageMathabx in the intermediate Latex file it works.

Dan

1 Like

No. I haven't tried that recently.
Do you have a small example?

1 Like

Hi Jens

Do you have a small example?

Not really ... I just bit the bullet and scaled it down in my usage, rather than further isolating and investigating.