Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Ask HN: What prompt do you use to get Claude to consistently render LaTeX?
6 points by TobyTheCamel 10 days ago | hide | past | favorite | 5 comments
I currently have subscriptions to both Claude and ChatGPT. I generally prefer the former but find I can't fully commit to it for my maths-heavy workload as it often struggles to correctly render LaTeX.

An example of this failed rendering is here [1]. If I use Claude for all of my work, I come across issues like this or worse at least once a day. Instead, I find it easier just to ask any maths questions to ChatGPT which seems to have a much more robust system for outputting LaTeX.

I would love to merge my subscriptions though, so I'm here to ask whether anyone has a system prompt that has been effective in guiding Claude towards producing valid LaTeX. I've tried a few prompts myself but struggled to find anything that it consistently followed.

[1] https://imgur.com/yzlluOA

 help



I do this with claude frequently. The best tactic I have found is to include a finished file as a "style guide" alongside your content prompt. To find an appropriate style guide for your subject matter, find paper on the arxiv that covers similar material and click the "TeX Source" link.

LLMs only produce markdown [1], usually Math is wrapped with KaTeX [2]. The rendering happens in the Web UI. If some math failed to render, you can copy the code and paste to latex-sandbox [3] and fix yourself.

[1] https://docs.github.com/en/get-started/writing-on-github/wor...

[2] https://katex.org

[3] https://latex-sandbox.vercel.app


When you say consistently render what do you mean? Like without any sort of formatting issue? If thats the case I would lower your expectations a bit almost always as with any bit of copy editing regardless of using ai or not theres going to be issues to review. I have a claude skill using tectonic I believe and it works pretty well, and then I wrote hooks to make sure if certain things are going to be written it does it in a certain way.

It seems that GitHub gist can renders some of \LaTeX, but not perfect.

https://gist.github.com/ontouchstart/bcffb186a753c5b75522fc8...


Some things are just too hard for them to do reliably



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: