# Scribble to PDF pain

**URL:** <https://racket.discourse.group/t/scribble-to-pdf-pain/1076>\
**Category:** Questions & Answers\
**Tags:** scribble\
**Created:** [June 11, 2022, 1:17am UTC](https://racket.discourse.group/t/scribble-to-pdf-pain/1076 "2022-06-11T01:17:53Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![danprager](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/danprager/32/279_2.png) [@danprager](https://racket.discourse.group/u/danprager)\
**Post date:** [June 11, 2022, 1:17am UTC](https://racket.discourse.group/t/scribble-to-pdf-pain/1076/1 "2022-06-11T01:17:53Z")

</div>

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?](https://racket.discourse.group/t/what-system-configuration-is-needed-for-the-scribble-pdf-button-in-drracket-for-a-scribble-file-in-order-to-work-properly/528) 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?

---

<div class="post-metadata">

**Author:** ![EmEf](https://avatars.discourse-cdn.com/v4/letter/e/53a042/32.png) [@EmEf](https://racket.discourse.group/u/EmEf)\
**Post date:** [June 11, 2022, 3:09am UTC](https://racket.discourse.group/t/scribble-to-pdf-pain/1076/2 "2022-06-11T03:09:58Z")

</div>

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

```scheme
[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:

```scheme
[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.

---

<div class="post-metadata">

**Author:** ![danprager](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/danprager/32/279_2.png) [@danprager](https://racket.discourse.group/u/danprager)\
**Post date:** [June 11, 2022, 8:07am UTC](https://racket.discourse.group/t/scribble-to-pdf-pain/1076/3 "2022-06-11T08:07:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![EmEf](https://avatars.discourse-cdn.com/v4/letter/e/53a042/32.png) [@EmEf](https://racket.discourse.group/u/EmEf)\
**Post date:** [June 11, 2022, 11:31am UTC](https://racket.discourse.group/t/scribble-to-pdf-pain/1076/4 "2022-06-11T11:31:42Z")

</div>

I recommend upgrading to the Racket snapshot for now:

[https://snapshot.racket-lang.org](https://snapshot.racket-lang.org)

---

<div class="post-metadata">

**Author:** ![soegaard](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/soegaard/32/19_2.png) [@soegaard](https://racket.discourse.group/u/soegaard)\
**Post date:** [June 11, 2022, 11:51am UTC](https://racket.discourse.group/t/scribble-to-pdf-pain/1076/5 "2022-06-11T11:51:41Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![EmEf](https://avatars.discourse-cdn.com/v4/letter/e/53a042/32.png) [@EmEf](https://racket.discourse.group/u/EmEf)\
**Post date:** [June 11, 2022, 12:15pm UTC](https://racket.discourse.group/t/scribble-to-pdf-pain/1076/6 "2022-06-11T12:15:47Z")

</div>

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

```scheme

[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:

```scheme

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

---

<div class="post-metadata">

**Author:** ![danprager](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/danprager/32/279_2.png) [@danprager](https://racket.discourse.group/u/danprager)\
**Post date:** [June 11, 2022, 12:17pm UTC](https://racket.discourse.group/t/scribble-to-pdf-pain/1076/7 "2022-06-11T12:17:12Z")

</div>

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

````scheme
! 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}}}```
````

---

<div class="post-metadata">

**Author:** ![soegaard](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/soegaard/32/19_2.png) [@soegaard](https://racket.discourse.group/u/soegaard)\
**Post date:** [June 11, 2022, 12:22pm UTC](https://racket.discourse.group/t/scribble-to-pdf-pain/1076/8 "2022-06-11T12:22:51Z")

</div>

Sounds like this issue:

> <https://github.com/racket/scribble/issues/324>
>
> The following LaTeX document is reduced from what scribble generates from a hell…o world document. With 
> newtxmath.sty 1.7 (2021/12/18), it generates an error because \\widebar is already defined. Uncomenting the let
> for widebar seems to "fix" it, no idea if that's the best approach.
>  
> \`\`\`latex
> \\documentclass{article}
> \\usepackage{amsmath}
> \\usepackage{mathabx}
> \\let\\widering=\\relax
> %\\let\\widebar=\\relax
> \\usepackage{newtxmath}
> \\begin{document}
> hello world
> \\end{document}
> \`\`\`
> Here's the scribble document.
> 
> \`\`\`racket
> \#lang scribble/base
> @(require scribble/core
> scribble/manual)
> 
> hello world
> \`\`\`

and

> [@Problems generating pdf/latex from scribble](https://racket.discourse.group/t/problems-generating-pdf-latex-from-scribble/1010):
>
> I'm trying to get started using scribble to replace regular latex in my toolchain. However, I'm having a hard time generating both pdf and latex. I believe the error in both instances is related to the same error about \widebar. Here's the error I get when I tried to get a pdf from the scribble-generated tex: This is pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2022) (preloaded format=pdflatex) restricted \write18 enabled. entering extended mode (./test.tex LaTeX2e \<2021-11-15\> patch lev…

---

<div class="post-metadata">

**Author:** ![danprager](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/danprager/32/279_2.png) [@danprager](https://racket.discourse.group/u/danprager)\
**Post date:** [June 11, 2022, 12:31pm UTC](https://racket.discourse.group/t/scribble-to-pdf-pain/1076/9 "2022-06-11T12:31:47Z")

</div>

> 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?

---

<div class="post-metadata">

**Author:** ![capfredf](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/capfredf/32/935_2.png) [@capfredf](https://racket.discourse.group/u/capfredf)\
**Post date:** [June 11, 2022, 1:47pm UTC](https://racket.discourse.group/t/scribble-to-pdf-pain/1076/10 "2022-06-11T13:47:42Z")

</div>

I am late to this discussion.

I ran into this problem and proposed a fix

> <https://github.com/racket/scribble/pull/327>
>
> \`newtxmath\` has added \`\\widbar\` since the version 1.7.0. The latest version of \`…newtxmath\` is included in TeXLive 2022, which was just released in April.

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

---

<div class="post-metadata">

**Author:** ![EmEf](https://avatars.discourse-cdn.com/v4/letter/e/53a042/32.png) [@EmEf](https://racket.discourse.group/u/EmEf)\
**Post date:** [June 11, 2022, 2:04pm UTC](https://racket.discourse.group/t/scribble-to-pdf-pain/1076/11 "2022-06-11T14:04:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![encomer](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/encomer/32/280_2.png) [@encomer](https://racket.discourse.group/u/encomer)\
**Post date:** [June 22, 2022, 3:53am UTC](https://racket.discourse.group/t/scribble-to-pdf-pain/1076/12 "2022-06-22T03:53:22Z")

</div>

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.

```scheme
#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.

---

<div class="post-metadata">

**Author:** ![danprager](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/danprager/32/279_2.png) [@danprager](https://racket.discourse.group/u/danprager)\
**Post date:** [June 23, 2022, 12:36am UTC](https://racket.discourse.group/t/scribble-to-pdf-pain/1076/13 "2022-06-23T00:36:03Z")

</div>

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 ...

```scheme
! LaTeX Error: Command \widebar already defined.

```

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

Dan

---

<div class="post-metadata">

**Author:** ![soegaard](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/soegaard/32/19_2.png) [@soegaard](https://racket.discourse.group/u/soegaard)\
**Post date:** [June 23, 2022, 6:19am UTC](https://racket.discourse.group/t/scribble-to-pdf-pain/1076/14 "2022-06-23T06:19:05Z")

</div>

> [@danprager](#):
>
> BTW: Have you noticed a change in how diagrams generated using 2htdp/image appear about 3x larger in pdfs generated via Scribble lately?

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

---

<div class="post-metadata">

**Author:** ![danprager](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/danprager/32/279_2.png) [@danprager](https://racket.discourse.group/u/danprager)\
**Post date:** [June 27, 2022, 2:56pm UTC](https://racket.discourse.group/t/scribble-to-pdf-pain/1076/15 "2022-06-27T14:56:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![capfredf](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/capfredf/32/935_2.png) [@capfredf](https://racket.discourse.group/u/capfredf)\
**Post date:** [July 5, 2022, 4:45pm UTC](https://racket.discourse.group/t/scribble-to-pdf-pain/1076/16 "2022-07-05T16:45:34Z")

</div>

The PR above has been merged. Folks who have run into this issue can try out the latest snapshot builds, and the upcoming 8.6 will include the fix for this issue.
