$text{}$ appears when copying and pasting from Gemini
I am creating a Java Silver practice question set in another article on this blog. I rely on Gemini for these explanations. I copy Gemini’s output and paste it into the Custom HTML block of the WordPress post editor.

It used to be fine, but recently (starting October 16, 2025), even though it doesn’t look like this in Gemini’s description (photo above), pasting it results in the following:
Analysis of execution results: The initial state of variables is $text{p} = 0$, and the list $text{i}$ is $text{[0, 1, 2, 3, 4]}$. 1st time (p = 0) b: the for loop starts. $texttt{System.out.print(“;”)}$ is executed. Output: ; c: the for loop starts (while $text{j}$ remains $0$). The first $text{for(k:i)}$: when $text{k=0}$, $text{k%2==1}$ is false, so it outputs 0 via $texttt{System.out.print(k)}$. When $text{k=1}$, $text{k%2==1}$ is true, so it exits this inner loop with $texttt{break}$.
It ends up looking like the above. Everything in English is surrounded by things like $text{}$.
It has been over two weeks since I started making the question set, and this never happened before. This symptom suddenly appeared, no matter what explanation I ask for.
Whether on a smartphone or a PC, the result is the same regardless of the destination, such as the blog body or a notepad.
Toward a Solution
I persistently asked Gemini about the cause, and we concluded that the different fonts for Japanese and English characters might be the reason.
After searching the web, it seems $text{}$ is code for a document preparation system called LaTeX. It appears you write code to output documents like those created in Word. It seems to have been widely used for creating academic papers (Reference).
(Font type){Main text}
It seems that if you specify the font type as shown above, the text inside {} will be in the specified font. It also seems possible to specify things like bold text (Reference).
I did not understand why these tags are added when copying and pasting.
So, I asked Gemini to use a single font when responding. Then,

I obtained a result like the one above, and when I pasted the blue part into the Custom HTML, it looked like this:
First loop execution (do-while / label a): The first iteration of the do-while(true) loop (label a) begins. Start of the internal for(;;) loop (label b): This is an infinite loop, but it exits via an internal control statement. Execution of System.out.print(“;”);: The output is ;. Start of the internal for(int j=0; j<1;) loop (label c): Since there is no update process while j is 0, this would normally be an infinite loop, but it exits via an internal control statement.
This improved things. However, numbers and other elements were still surrounded by $, such as $0$. Therefore, I additionally asked Gemini to display all numbers and variables as plain strings when responding.

1st do-while loop (label a)
Enters the infinite for loop (label b).
System.out.print(“;”); is executed.
The current output is ;.
Enters the for(int j=0; j<1;) loop (label c).
The first enhanced for loop (for(int k:i))
If k is 0:
0 % 2 == 1 is false (0 is not odd).
It outputs k, which is 0, on the else side via System.out.print(k);.
The current output is ;0.
By doing so, I got the result I wanted.
However, after a few days, the same symptom occurred again in the same chat thread. No matter how hard I tried to ask it to use only one font or for LaTeX tags not to appear during copying, it would not improve. Even asking Gemini itself didn’t provide an answer.
So I tried creating a new chat. Then I asked it again to use only one font. When I did that, it was actually fixed.

By the way, if you want to display line breaks as they are, you should wrap the text with <pre></pre> and paste it into the Custom HTML block.
<pre>1st do-while loop (label a)
Enters the infinite for loop (label b).
System.out.print(";"); is executed.
The current output is ;.
Enters the for(int j=0; j<1;) loop (label c).
The first enhanced for loop (for(int k:i))
If k is 0:
0 % 2 == 1 is false (0 is not odd).
It outputs k, which is 0, on the else side via System.out.print(k);.
The current output is ;0.</pre>
1st do-while loop (label a)
Enters the infinite for loop (label b).
System.out.print(";"); is executed.
The current output is ;.
Enters the for(int j=0; j<1;) loop (label c).
The first enhanced for loop (for(int k:i))
If k is 0:
0 % 2 == 1 is false (0 is not odd).
It outputs k, which is 0, on the else side via System.out.print(k);.
The current output is ;0.
Summary
I do not know why Gemini suddenly started producing that problematic output.
Did it learn from its interactions with me?
Finally, I am a beginner who just learned about LaTeX this time. I am not particularly familiar with WordPress either, other than writing blogs normally.
If there are any mistakes in my description or if there is a smarter solution, please let me know.
コメント