How to include Tex code in latex-image using source

23 views
Skip to first unread message

Cuyler Warnock

unread,
Jan 29, 2026, 7:34:33 AMJan 29
to PreTeXt support
Hi,

Is there a way to keep my tex code for tikz images in a separate folder and then include them in <latex-image> using source? I tried <latex-image source="..."> (similar to image) and <latex-image><source>...</source> (what Copilot suggests), but neither method is working. My code compiles fine when pasted into the ptx file, I just wanted to clean-up how the file looks.

Best,
Cuyler

Sean Fitzpatrick

unread,
Jan 29, 2026, 8:32:00 AMJan 29
to pretext...@googlegroups.com
My first guess would be to use an xi:include. There's an option to set the parse mode to "text" if you don't want to escape all the reserved characters in your TikZ code. 

I don't know about copilot but the Guide has details: 

--
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/2854a2ea-fd2b-44c6-b0b8-e44018ed4073n%40googlegroups.com.

Cuyler Warnock

unread,
Jan 29, 2026, 8:42:48 AMJan 29
to PreTeXt support
Thank you very much! I asked Copilot about using xi:include and it told be that it would definitely NOT work, so I didn't try it. Should have tested it out. Thanks!

kcri...@gmail.com

unread,
Jan 29, 2026, 2:03:05 PMJan 29
to PreTeXt support
On Thursday, January 29, 2026 at 8:42:48 AM UTC-5 cuyler...@gmail.com wrote:
Thank you very much! I asked Copilot about using xi:include and it told be that it would definitely NOT work, so I didn't try it. Should have tested it out. Thanks!

On Thursday, January 29, 2026 at 8:32:00 AM UTC-5 dsfitz...@gmail.com wrote:
My first guess would be to use an xi:include. There's an option to set the parse mode to "text" if you don't want to escape all the reserved characters in your TikZ code. 

I don't know about copilot but the Guide has details: 


I use this a lot.  An advantage to this is that you can then use the image several times in the document by xinclude-ing this snippet several times.  

(Unfortunately, as of the last time I tried this, there wasn't a good mechanism for generating an image only once, but including it several times.  Other than putting it in the external images directory after generating in some other fashion than with PreTeXt auto-generation.)
Reply all
Reply to author
Forward
0 new messages