Latex conversion to pdf issues

I’m a high school math teacher who is using ChatGPT to produce worksheets on various math topics. Aside from the occasional off topic question, my main issue is that latex is used to produce “nice looking” math expressions in the chat, but has major trouble producing the same math expressions in a pdf. I can’t copy and paste the chat into a document because the latex doesn’t allow the nice looking math expressions to stay the same. I can take snippets but clearly not an efficient method. I had some lucky converting to csv and then to a pdf before. And I understand I can take latex, put into text editor, and then compile it, but not an efficient method either.

Are there any fixes or good prompts out there? Anyone else running into similar issues?

Thanks

I know you are reporting this as a bug but I don’t see it as a bug; a tweak of the prompt might be all that is needed.

Can you give

  1. An example of a prompt you use.
  2. An image of what you expect the worksheet to look like posted as an image
  3. The LaTeX that was used to create the image posted.
  4. Point out what ChatGPT generated and what should be changed for what you expect.

The reason for asking for such is that while you note LaTeX that may not be what ChatGPT is generating. Also without out seeing exactly what you expect trying to help could easily turn into a guessing game which would not be an efficient use of time.

I don’t mind spending about 30 minutes on this to see if I can help you but also know that having specific details has a much better chance at getting a possible solution.

Thanks for the response. The prompt was as follows.

Create a worksheet based upon algebra 2 remainder theorem problems.

I’m out and can’t send more, but if you just put this prompt in you will get beautiful looking problems, but the pdf not so much

Thanks kevin

Hi Eric,

I can give you more specifics when I get home. I really want to use the power of ai to help my students and the latex issue is slowing me down a bit.

Thanks,

Kevin

1 Like

Took a quick look at this using your prompt with ChatGPT 4o this was generated.

Sure, I can help you create a worksheet based on Algebra 2 Remainder Theorem problems. Here's a set of sample problems and instructions for the worksheet:

---

### Algebra 2: Remainder Theorem Worksheet

**Instructions:** For each polynomial \( P(x) \) and given divisor \( x - c \), use the Remainder Theorem to find the remainder when \( P(x) \) is divided by \( x - c \). The Remainder Theorem states that the remainder of the division of a polynomial \( P(x) \) by a linear divisor \( x - c \) is \( P(c) \).

#### Problem 1
Given \( P(x) = 3x^3 - 2x^2 + 5x - 7 \) and \( x - 2 \), find the remainder.

#### Problem 2
Given \( P(x) = 4x^4 - 5x^3 + 2x^2 - x + 1 \) and \( x + 1 \), find the remainder.

#### Problem 3
Given \( P(x) = 2x^5 - 3x^4 + 6x^3 - x^2 + 4x - 5 \) and \( x - 3 \), find the remainder.

#### Problem 4
Given \( P(x) = 5x^2 - 3x + 9 \) and \( x - 4 \), find the remainder.

#### Problem 5
Given \( P(x) = x^4 - 6x^3 + 11x^2 - 6x + 8 \) and \( x - 1 \), find the remainder.

#### Problem 6
Given \( P(x) = 7x^3 - 4x^2 + 2x - 8 \) and \( x + 2 \), find the remainder.

#### Problem 7
Given \( P(x) = x^5 - x^4 + 2x^3 - 2x^2 + x - 1 \) and \( x - 0 \), find the remainder.

#### Problem 8
Given \( P(x) = 3x^4 - 2x^3 + x^2 - 5x + 3 \) and \( x - (-3) \), find the remainder.

#### Problem 9
Given \( P(x) = 2x^3 + 5x^2 - 4x + 6 \) and \( x - 5 \), find the remainder.

#### Problem 10
Given \( P(x) = x^4 + 2x^3 - x^2 - 2x + 3 \) and \( x + 1 \), find the remainder.

---

**Note:** To find the remainder using the Remainder Theorem, simply substitute the value \( c \) from the divisor \( x - c \) into the polynomial \( P(x) \).

---

Would you like this worksheet in a specific format, such as a Word document or PDF, or would you like to make any adjustments?

However

Using Google Chrome, right click on a line with a math expression and select Inspect, e.g.

and you will see HTML looking something like

image

Notice the lines with

  • “katex-mathml”
  • “katex-html”

So what is being created is not LaTeX but katex.

Since it seems you want to create a PDF and generate it from LaTeX I modified the prompt to

Create a worksheet based upon algebra 2 remainder theorem problems. Generate the output as LaTeX for use with PdfLaTeX.

which created

\documentclass[12pt]{article}
\usepackage{amsmath}

\title{Algebra 2: Remainder Theorem Worksheet}
\author{}
\date{}

\begin{document}

\maketitle

\section*{Instructions}

For each polynomial \( P(x) \) and given divisor \( x - c \), use the Remainder Theorem to find the remainder when \( P(x) \) is divided by \( x - c \). The Remainder Theorem states that the remainder of the division of a polynomial \( P(x) \) by a linear divisor \( x - c \) is \( P(c) \).

\section*{Problems}

\begin{enumerate}
    \item Given \( P(x) = 3x^3 - 2x^2 + 5x - 7 \) and \( x - 2 \), find the remainder.
    
    \item Given \( P(x) = 4x^4 - 5x^3 + 2x^2 - x + 1 \) and \( x + 1 \), find the remainder.
    
    \item Given \( P(x) = 2x^5 - 3x^4 + 6x^3 - x^2 + 4x - 5 \) and \( x - 3 \), find the remainder.
    
    \item Given \( P(x) = 5x^2 - 3x + 9 \) and \( x - 4 \), find the remainder.
    
    \item Given \( P(x) = x^4 - 6x^3 + 11x^2 - 6x + 8 \) and \( x - 1 \), find the remainder.
    
    \item Given \( P(x) = 7x^3 - 4x^2 + 2x - 8 \) and \( x + 2 \), find the remainder.
    
    \item Given \( P(x) = x^5 - x^4 + 2x^3 - 2x^2 + x - 1 \) and \( x - 0 \), find the remainder.
    
    \item Given \( P(x) = 3x^4 - 2x^3 + x^2 - 5x + 3 \) and \( x - (-3) \), find the remainder.
    
    \item Given \( P(x) = 2x^3 + 5x^2 - 4x + 6 \) and \( x - 5 \), find the remainder.
    
    \item Given \( P(x) = x^4 + 2x^3 - x^2 - 2x + 3 \) and \( x + 1 \), find the remainder.
\end{enumerate}

\end{document}

Pasting that into an online site that can convert the LaTeX to a PDF for viewing, e.g.

https://texviewer.herokuapp.com/

and clicking

image

This is what is displayed in the right hand panel

Notice also in the upper right the download button

image

which can save the file as a PDF to your local machine

On Windows I get a file dialog with this for the specific file

image

notice the file type is PDF. :slightly_smiling_face:

While I am sure you still have questions on why Katex and not Latex and exactly how to do this, which I will gladly answer, hopefully this gives you enough to see that your endeavor is worth pursuing and I would wager being accomplished successfully.

Hi Eric…thanks for the reply.

Prompt: Create a worksheet based upon algebra 2 remainder theorem problems.

chat window creates: here’s a sample of first two questions

Eric!

Thanks for your time. I can get to the off from latex , but didn’t want to have to compile everything myself. So I’m just looking to do less and have gpt do more. It says that pdflatex is not found in the environment, which I’m taking as there is no built in compiler that seems to work in ChatGPT?

Since almost all of my work involved in school will involve latex, it’s just something that I’m hoping I can eventually not have to wonder about compiling

Seems some words might be missing. :man_shrugging:

Please provide more details as I can only guess what that means.

While the word LaTeX is used colloquially which results in many thinking there is only one LaTeX, in reality there are many variations with even the official download from Tex Live including several that are not compatible.

I tested the prompt without noting PdfLaTeX and it still works as expected in that LaTeX is created that has to be converted into a PDF.

Create a worksheet based upon algebra 2 remainder theorem problems. Generate the output as LaTeX.

Essentially what you need for this to work is for ChatGPT on any LLM to generate LaTeX specifically and not a variation such as KaTeX.

If you are expecting ChatGPT to generate a PDF file that you can download then does it really need to be LaTeX first? In other words you are asking for LaTeX but then expecting a PDF file for download. If you are asking for LaTeX that can be then converted to a PDF but also have ChatGPT provide the PDF for download with the generated LaTeX then that is something that I would not expect ChatGPT to do, nor would I want it to do as the normal process is to create LaTeX then use another tool to create the PDF. This way you have access to the LaTeX which will be more amenable for future changes; PDFs were created for better typographic layout not for word processing and such.

In trying to get ChatGPT to generate a PDF file using this prompt

Create a worksheet based upon algebra 2 remainder theorem problems. Generate the output as a PDF file for download.

It first created some Python code then had to fix it with a few iterations before finally creating the PDF for download as a link which was a valid PDF file and needed no other work but seeing ChatGPT create Python code then having to fix the Python code before it worked is not something I am recommending but noting for completeness sake.

Here is the Python code that ChatGPT created for those interested.

Python code (click triangle to expand)
# Correcting the multi_cell method usage
pdf = FPDF()
pdf.add_page()
pdf.set_font("Arial", size=12)

# Title
pdf.cell(200, 10, txt="Algebra 2 Worksheet: Remainder Theorem", ln=True, align='C')

# Instructions
pdf.ln(10)
pdf.cell(200, 10, txt="Instructions:", ln=True)
pdf.multi_cell(0, 10, txt="1. Determine the Remainder: For each polynomial, use the Remainder Theorem to find the remainder when divided by the given linear divisor.\n2. Verify the Remainder: Use polynomial long division or synthetic division to verify your answer.")

# Problems
problems = [
    "1. Find the remainder when P(x) = 2x^3 - 3x^2 + 4x - 5 is divided by x - 2.",
    "2. Find the remainder when P(x) = x^4 - x^3 + 2x^2 - x + 1 is divided by x + 1.",
    "3. Find the remainder when P(x) = 3x^3 + 5x^2 - 2x + 7 is divided by x - 3.",
    "4. Find the remainder when P(x) = 4x^5 - 2x^4 + 3x^3 - x^2 + 2x - 8 is divided by x + 2.",
    "5. Find the remainder when P(x) = x^2 - 5x + 6 is divided by x - 1.",
    "6. Find the remainder when P(x) = 2x^4 + x^3 - 3x^2 + x - 1 is divided by x + 3.",
    "7. Find the remainder when P(x) = -x^3 + 2x^2 - 3x + 4 is divided by x - 4.",
    "8. Find the remainder when P(x) = x^5 - 2x^4 + 4x^2 - x + 6 is divided by x + 5.",
    "9. Find the remainder when P(x) = 5x^3 + 3x^2 - x + 2 is divided by x - 6.",
    "10. Find the remainder when P(x) = 7x^4 - x^3 + 2x - 9 is divided by x - 7."
]

pdf.ln(10)
for problem in problems:
    pdf.multi_cell(0, 10, txt=problem)

# Output the PDF
pdf_output_path = "/mnt/data/Algebra2_Remainder_Theorem_Worksheet.pdf"
pdf.output(pdf_output_path)

pdf_output_path

However if you do want the PDF and possibly the LaTeX from a ChatGPT prompt then you need to consider finding or creating a custom GPT or using the OpenAI API.

Thanks for the time!

I just simply want a pdf, but I was getting math expressions that were garbage, meaning not looking like how we normally would see expressions.

Like this: 2x^3-4/3x

So, I then asked chat to generate the pdf so it looked like the proper math format it was using in the chat window (I’m assuming latex or latex)

This progressed to me getting occasional good PDFs but often chat saying the compiler that it was looking for I guess called pdflatex was not found in their environment.

So, then I would just ask for a latex file and go compile it myself, which has worked for the most part. However, it’s one or two extra steps that I’m trying to avoid, especially when I’m trying to automate more.

Hope this helps

Kevin

Yes this is true.

ChatGPT as with all Chat bots based on LLMs that I am aware of are fundamentally next-token predictors meaning they try to give a text based answer. Getting them to create a link to a file is something recent in the last year with various results depending upon the format and LLM used. In this case getting ChatGPT to create a PDF download via link is not something I have seen it accomplish repeatedly successfully; Python code is an example of a file type that can often be requested for download with more success.

As such you will need to either use what ChatGPT gives you, LaTeX as text, and then finish the conversion to a PDF manually or one of the following

If this were my problem I would not spend more time trying to get ChatGPT to create the PDF with the free version of ChatGPT and instead switch to using a custom GPT which can be augmented with source code to pass the result as LaTeX to a LaTeX to PDF compiler then pass that back as a link.

I am a paid user and have tried some custom gpts.

How would I prompt to get the desired output?

Good question.

As I do not use custom GPTs, prefer not to speculate on the exact way to do it but do see that as a very likely way to solve this, e.g.


In looking to give an answer to your question did some more specific searching of using code with a prompt and saw mention that the code interpreter can create PDFs

https://platform.openai.com/docs/assistants/tools/code-interpreter

While this option was not on my previous list, it is something I will take a closer look at. If something of value results from that I will post here.

1 Like