PreFigure: Global shape definitions and defining shapes with multiple anchors

34 views
Skip to first unread message

Derek Thuecks

unread,
Mar 30, 2026, 4:58:11 PMMar 30
to PreTeXt support
Good afternoon.

I'm pretty new to PreFigure and have been using TikZ and CircuiTikZ to create figures for an electronics text that I'm writing. I'm looking at whether to make the transition to PreFigure but can't figure out whether I can effectively build circuit diagrams in PreFigure.

I have seen the LCR circuit example in the PreFigure documentation, but I'm wondering if I can 
  • create/define custom shapes associated with other circuit components for use globally across many figures in my book, and 
  • define a custom shape with callable anchors representing terminals on a multi-terminal device (e.g. transistors, operational amplifiers, etc).
I fully intend to convert to use of PreFigure for other diagrams that are not circuit schematics, but I'm wondering if circuit schematics might be an option as well.

Thanks!
Derek

David Austin

unread,
Mar 30, 2026, 6:46:21 PMMar 30
to pretext...@googlegroups.com
Hi Derek,

Can you say more about what kind of custom shapes you'd like to define?  Sharing some examples would be particularly helpful.  I've had some thoughts along these lines, but it would help to know more specifically about what you'd like.

But with that said, I think the answer to your questions is currently "no".

David

--
You received this message because you are subscribed to the Google Groups "PreTeXt support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pretext-suppo...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-support/a354dbd4-064b-45f3-bc27-8673c51883c6n%40googlegroups.com.

Derek Thuecks

unread,
Mar 31, 2026, 10:09:02 AMMar 31
to PreTeXt support
Hi David.

Thanks for your reply. I'll do my best to be concise.
  • One class of example shapes would cover circuit elements with one or two poles, similar to your resistor (zigzag decoration), capacitor (capacitor decoration), and inductor (coil decoration). See the bipolar-circuit-symbols.png  and diode-circuit-symbol.png attachments for a few examples.
  • A second class of circuit elements has multiple poles, each with specified anchor names. This allows a user to connect external elements to specific locations on the defined circuit element. See the two fig-bjt-homework-1 attachments (.tex and .png) for one circuit example that uses a three-pole transistor with base (B), collector (C), and emitter (E) terminals. The opamp-description-circuitikz.png shows a clipping from the CircuiTikZ manual for the operational amplifier with five named terminals/anchors.
In both example classes above, it would be helpful if I were able to define new shapes in a PreFigure preamble similar to the latex-image-preamble in the docinfo.ptx file. This would allow one initial shape definition to be used in multiple figures throughout the textbook.

I completely understand that what I'm proposing is likely a bit of a corner case, but I thought I'd ask. I'm fine if I end up using CircuiTikZ for circuit schematics and PreFigure for most else.

Thanks for your help!
Derek

fig-bjt-homework-1.tex
opamp-description-circuitikz.png
bipolar-circuit-symbols.png
diode-circuit-symbol.png
bjt-description-circuitikz.png
fig-bjt-homework-1.png

Andrew Scholer

unread,
Mar 31, 2026, 11:03:47 AMMar 31
to pretext...@googlegroups.com
Derek - 

One option you have is using some tool to preprocess your diagrams. Create some macro that replaces custom elements or arbitrary patterns with valid PreFigure.

I started playing with using XSL to do this:

But you could use the language of your choice to do something similar.

Andrew 


Mark Fitch

unread,
Mar 31, 2026, 12:12:59 PMMar 31
to pretext...@googlegroups.com

Not having tried to write such macros, this is a bit of a shot in the dark, but for one of my classes I used SVG files that contain all the circuit elements. Currently I cut and paste them into Inkscape to produce SVG images. However, the SVG file could be read and converted into PreFigure (both are XML structures). The only thing this does not do, is assist in connecting the elements. One has to know coordinates for the wire ends rather than software figuring that out.

David Austin

unread,
Mar 31, 2026, 4:34:26 PMMar 31
to pretext...@googlegroups.com
Thanks to everyone for contributing ideas.  To follow up on Mark's suggestion, one can import an SVG into a PreFigure diagram, but I'm not sure this is a sustainable approach.

Derek:  how exhaustive is the list of elements in those attachments you sent?  Do they cover most of what one would want for electrical diagrams?  I could imagine making an #electrical-diagram element that provides the capabilities for adding these elements at various locations and then connecting them to one another.  That wouldn't be too hard and would allow for semantic markup.

I have thought a bit about having some type of macros, which would essentially be a shorthand for a reusable group of elements.  That would likely provide you with the flexibility you need.

Neither of these two fixes are likely to happen in the next month as we're moving toward the end of the semester, but I'd be interested to hear your thoughts.

Thanks,
David

Mark Fitch

unread,
Mar 31, 2026, 4:52:46 PMMar 31
to pretext...@googlegroups.com

To clarify I was suggesting the SVG code could be converted to PreFigure code using some one time conversion tool producing re-usable PreFigure snippets (or make them macros).

Derek Thuecks

unread,
Apr 1, 2026, 7:16:33 PMApr 1
to PreTeXt support
Hi everyone.

Thank you Andrew, Mark, and David for your suggestions. I wonder if I could create a full circuit schematic (not just a single component) using CircuiTikZ, grab the xml commands from within the svg files generated during the PreTeXt build, and place them into a PreFigure file. It might take a little time to figure out how to correctly assign annotations to items in the circuit schematic in this format. I do worry a bit about this approach as it will make things a bit more challenging or confusing for anyone who wishes to modify or remix my materials. Perhaps conversion of individual circuit element svg files would be better in this respect, just as Andrew and Mark suggested.

David,  I've looked through my course notes (the starting point for my Electronics textbook) and put together a list of components/shapes that are pretty exhaustive for my particular purposes, at least in my first pass at including content in the text. Let me know if there is a better way for me to provide this information or other details that may currently be missing. 

I completely understand that this isn't a feature that will be added immediately, even if it is deemed to be desirable functionality. Our semester has entered the final month and April is always the most stressful month of the academic year. 

Thanks to all of you for your thoughts!
Derek
Circuit components with anchors.pdf

David Austin

unread,
Apr 2, 2026, 1:30:11 PMApr 2
to pretext...@googlegroups.com
Thanks for sending that, Derek.  That looks very reasonable, but things are pretty busy here, as you note, so I won't be able to get to it for a little.  I'll let you know when I have something for you to try.

Thanks again,
David

--
You received this message because you are subscribed to the Google Groups "PreTeXt support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pretext-suppo...@googlegroups.com.

Derek Thuecks

unread,
Apr 2, 2026, 1:50:21 PMApr 2
to PreTeXt support
Thank you David for entertaining this and for putting together a great tool!

Derek

David W. Farmer

unread,
Apr 2, 2026, 1:51:53 PMApr 2
to pretext...@googlegroups.com

If there were some type of cheat sheet with the components/shapes
needed for a wide variety of circuits, and a way to use that
cheat to help you build the circuit, I think that is a great
solution because it is in keeping with the idea that authors
should just specify what it is and then PreFigure takes care
of the presentation.

Regards,

David
> https://groups.google.com/d/msgid/pretext-support/CANXmVMAs6hZh-LwfwkeQc%2BGqpHeNDAO-sS6dS3N3AsyZ%3D7y6Gw%40mail.gmail.com.
>
>
Reply all
Reply to author
Forward
0 new messages