# Diagrams in a Scribble document

**URL:** <https://racket.discourse.group/t/diagrams-in-a-scribble-document/3280>\
**Category:** Questions & Answers\
**Created:** [October 29, 2024, 6:20pm UTC](https://racket.discourse.group/t/diagrams-in-a-scribble-document/3280 "2024-10-29T18:20:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hendrikboom3](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/hendrikboom3/32/2748_2.png) [@hendrikboom3](https://racket.discourse.group/u/hendrikboom3)\
**Post date:** [October 29, 2024, 6:20pm UTC](https://racket.discourse.group/t/diagrams-in-a-scribble-document/3280/1 "2024-10-29T18:20:39Z")

</div>

I's like to have diagrams in a Scribble document.  
Now diagrams are build from lines, geometrical objects. and text.  
The text in the diagrams should have the same typography as the rest if the Scribble text.

Now there are ways to embed images in Scribble by putting them in separate files and linking to them.  
But this separates them from their contextual source code and creates additional difficulties:

- Making those diagrams separately.
- dealing with a lot of file names.
- Making it really hard to see what diagrams are where when editing source code. File names don't look like diagrams at all.
- And the usual image file formats for images are bulky.

So I want to embed the instructions for making the diagrams in the Scribble text and further embed pieces of Scribble text within those instructions.

Now HTML has a mechanism for efficiently embedded diagrams: SVG.  
And so does LATEX.  
And Racket has a variety of mechanisms for describing pictures.

I'd like to describe the construction of diagrams in the document source code and have it converted to either of these two output forms, whichever is being used for presenting the final document.

Are there already any tools for this within the rather large Racket ecosystem? Would they be hard to set up if not?

-- hendrik

---

<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:** [October 29, 2024, 7:44pm UTC](https://racket.discourse.group/t/diagrams-in-a-scribble-document/3280/2 "2024-10-29T19:44:14Z")

</div>

Picts can be used directly in Scribble - make sure that picts are rendered as svgs.  
In order to use LaTeX-formulas I use the `latex-pict` package.  
The functions `tex-math` and `tex-display-math` renders LaTeX math formulas  
into a pict. The pict can then be used labels, legends, etc.

See my blog for examples on the result:

[https://www.stxmat.dk/blog/](https://www.stxmat.dk/blog/)

Notes: If you decide to test `latex-pict` then be aware that DrRacket can't render the picts produced, so in the DrRacket repl you need to wrap it in an `pict->bitmap`.  
The same problem doesn't exists in racket-mode (Emacs), since it always converts  
picts to images.

Notes: You need to have Latex installed (I think, latex-pict works with TeX Live, but  
if you have a different distribution, you might need to change the settings).

---

<div class="post-metadata">

**Author:** ![benknoble](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/benknoble/32/16_2.png) [@benknoble](https://racket.discourse.group/u/benknoble)\
**Post date:** [October 29, 2024, 8:21pm UTC](https://racket.discourse.group/t/diagrams-in-a-scribble-document/3280/3 "2024-10-29T20:21:45Z")

</div>

There's also some code typeseting for picts in [https://docs.racket-lang.org/pict/More\_Pict\_Constructors.html#%28part._.Typesetting_.Racket\_.Code%29](https://docs.racket-lang.org/pict/More_Pict_Constructors.html#%28part._.Typesetting_.Racket_.Code%29)
