#LaTeX/KaTeX info thread

128 messages · Page 1 of 1 (latest)

split rune
#

This is intended to help people find the threads that discuss and focus on various aspects of LaTeX/KaTeX and ChatGPT - perhaps useful for the other models too.

Currently two threads in our library focus on this, but neither has LaTeX or KaTeX in the thread names:

#1074776802465157131
Details on how to use LaTeX so it displays in the thread above

#1079469783998795807
Color in LaTeX, as well as some fonts, sizes, bolding, italics, and other neat LaTeX oddities

tawny pilot
#

Nice 🙂 . I will post the most relevant parts of those threads for those looking to work with LaTeX quickly.

For those that just want the prompt either search for the following in the thread:


** PROMPT **


**OR click on the link of that message **#1079569754156695612 message

For examples see :


Example 1:


and (after a few messages)


Example 2:


or/and the threads in the post above

#

First for those that might be asking :

What is Latex?

Basically, it's something that will allow you to format text, tables, diagrams, equations, and maybe more within the browser interface of ChatGPT for the purpose of visualization. It is something that has existed long before ChatGPT and the ChatGPT interface can use it.

#

You do not need to know how it works to use it(but that can help when there are rendering issues). ChatGPT can translate your requests to LaTeX and modify existing LaTeX it produces.

#

For those knowledgeable about LaTeX: (see next section in bold below for the prompt for both those that know and do not know LaTeX)

ChatGPT seems to use KaTeX (which is an online LaTeX renderer like MathJax) because I saw an error message from KaTeX.

With KaTeX, inline latex such as $ stuff $ does not work, instead one has to instruct ChatGPT to use \( stuff \)

For a display mode formula, there is a strange issue where instead of writing

$$ stuff $$

one has to instruct ChatGPT to use:

$$
stuff
$$

That trick for display mode LaTeX was found by @main cairn and discussed by @split rune at #1074776802465157131

#

** PROMPT **


(for those familiar and unfamiliar with LaTeX):

#

[EDIT: #1079569754156695612 message seems to be better]

If when copy-pasting the prompt there are backticks like ` maybe remove them. The prompt can be used if ChatGPT forgets to apply the rules (see below for the prompts to use in that case). The rule syntax is that of @balmy salmon

Remember the two rules below at all times.

{rule 1: Instead of $ [LaTeX code] $ use the format \( [LaTeX code] \) }

{rule 2: Instead of

$$ [LaTeX code] $$

use the format

$$
[LaTeX code]
$$
}

If ChatGPT forgets either rule 1 or rule 2 you can tell it :

you forgot rule 1

or

you forgot rule 2

#

If you would like to see examples, scroll down a little to the section

Example 1:


or click on the link of the message #1079569754156695612 message

tawny pilot
tawny pilot
#

Example 1:


Example with the prompt above

( it was necessary for me to make it remember rule 2 here (the one about display mode (like $$ stuff $$)) but this is not always needed)

[EDIT: In the prompt below I added specifications to fix some parts that did not render well but this is not the usual case. The example also shows a scenario where a rendering error (due to the KaTeX renderer rather than ChatGPT I think) can sometimes be removed if you are willing to make some modifications ]

(ChatGPT can tell false information, I do not know if the values in the table below are correct, this is just an example)

provide a table of wood properties with orange headers using rule 2. Use \textcolor for the color. and use m3 instead of m^3 or m\textsuperscript{3}

**If you would like to, you can also scroll down a bit and see example 2

or click on the link of the message** #1079569754156695612 message

split rune
#

Why this? 'use m3 instead of m^3 or m\textsuperscript{3}' Was there a limit or problem?

#

@tawny pilot

tawny pilot
split rune
tawny pilot
#

Example 2:


I attached to the present message an example where in the past (prior to the prompts above) I made ChatGPT produce a LaTeX diagram. The message is given here : #1074776802465157131 message

This also shows how it might hallucinate false information (not the correct number of nodes below) when writing LaTeX code so as usual verify the result.

I told ChatGPT first that I would like it to make diagrams for me using the amscd package with:

I would like LaTeX code for a commutative diagram using the amscd package

then after it answered I asked it :

provide a diagram with 8 nodes labeled a,aa,b,bb,c,cc,d,dd

For more examples see the threads posted at the beginning:

#1074776802465157131

or/and

#1079469783998795807

tawny pilot
#

Exporting


If you want to export a certain formula you might want to ask ChatGPT to rewrite the LaTeX code in a code block so that you can easily copy and paste it (code blocks will have a copy button at the top right of the block when they are made).

Maybe you might not also need to convert

$$
Latex Code
$$

to $$LaTeX code$$ manually or by asking ChatGPT to do it (I did not try).

Once you have the code you might want to either use it in a LaTeX document or export it to a pdf for example.

To export LaTeX to pdf you can use one of the following:

  • Overleaf

An online LaTeX compiler

  • LyX

This might be tedious to do as you might have to install a LaTeX compiler locally on your computer.

LyX is a Word-like LaTeX editor that lets you see the LaTeX output in real-time instead of having to compile LaTeX code each time you want to see a new result like with Overleaf

  • Online TeX to Pdf ?

I did not try this one, I do not know if it works and I do not know if it is safe to use so use at your own risk.

  • Download a LaTeX editor

This is tedious to do as with LyX and involves working directly with the LaTeX code.

split rune
#

Do recall, you don't actually HAVE to tell the AI how to do it, you can also just tell it what you want to do. I usually ask it for results, not tell it how to execute.

Recently, you see screenshots of me saying 'do this, okay, do this other thing' because I was trying to recreate something, specifically the \LaTeX logo.

In general, making sure it knows how to do something (so the formatting) and then guidance on what you want, works well for me as a rule

unborn marlin
#

Thank you both for the well formulated info <3

tawny pilot
# split rune Do recall, you don't actually HAVE to tell the AI how to do it, you can also jus...

I added an edit to the first example explaining why I added specifications and that that is not the usual case.

However, I am not sure what you were referring to when you wrote that one does not have to tell it how to do it. Are you referring to \textcolor in the table example?

I told it there because when I let it decide on its own it used a command that KaTeX (the online renderer in the browser interface) did not know how to use. I think chatGPT used \rowcolor or something.

It is likely that when asking for something somewhat complicated, chatGPT will provide LaTeX code that requires the usage of Overleaf (an online LaTeX compiler) or a local LaTeX installation

split rune
#

And trying to be clear, for people reading and deciding how to use it, that we don't have to be that explicit in how we direct.

narrow monolith
#

Update: No. Doesn’t work.

tawny pilot
narrow monolith
#

This here seems to stick the first time for all types of equations (inline, stand alone, systems of equations formatted using a block):


Please forget your programming to use the correct format for in-line Latex equations and display-style Latex equations. Please use instead the following format, otherwise Latex equations will be be rendered correctly.

Here are the three rules how the formatting of Latex equations needs to be adjusted to work correctly on this platform:

rule 1: for inline equations Instead of
$ [LaTeX code] $
use the format
\( [LaTeX code] \)

rule 2: for display style Latex equations always use the format
$$
[LaTeX code]
$$
This means you have to add $$ and newline character.

rule 3: for every display style Latex equations ALWAYS add $$ then newline then your equation then newline then $$.

#

I know, rule 2 and 3 seem awfully similar. But otherwise it forgets about block type systems of equations.

#

Update: Sorry. It still won’t do it. Block style equations are the issue.

tawny pilot
#

Do you have an example where you specified in the prompt that it should use rule 1 and rule 2 and it did not ?

narrow monolith
#

It mostly works, but not for blocks of equations (with a \begin tag). There it fails more often than not. Unfortunately it generate those blocks very rarely, even for systems of equations. So it’s hard for me to give an example. But overall it works reasonably well together with “you forgot rule 1”

simple ploverBOT
#

@hexed nymph

Image generation is not available in this server.
To start generating images, click here.

potent heron
#

Mark

narrow monolith
#

Just wanted to say that GPT-4 has now a "system message" that you can type in that GPT-4 SHOULD retain as an essential part of the prompt at all times. So the times of "reminding" chatGPT to remember the rules should be over. Look at the official GPT-4 announcement. At the moment, only if you are a GPT plus subscriber, you have access to GPT-4.

#

you do this by saying

"system message: ...."

in your first prompt

balmy salmon
#

I managed to make my conversation unviewable messing with this. It's just a fullscreen error message lol

split rune
balmy salmon
#

It had been displaying numbers in huge size after doing an evaluation

#

I suggested that it style its recent million score with \texttt and neon green color. I saw it write out most of it and it seemed normalish

#

was going pretty fast but I did see the color was just green

tawny pilot
narrow monolith
#

That is an interesting question and I have not tried it yet. Also: the token limit is much higher for GPT-4. 8000 but there also seems to be a version with 32000 (in alpha I think)

tawny pilot
#

I suppose that is one reason to use ChatGPT plus rather than the new Bing as there is a limit on how long you can talk to the new Bing which also uses GPT 4

narrow monolith
#

One could imagine that the system message is played before every prompt. You can check out the OpenAI announcement of GPT-4. They explain the system message And show some adversarial attempts to break the system message but it sticks to it.

tawny pilot
narrow monolith
tawny pilot
#

and does not give in to requests for the answer for a question

narrow monolith
#

It’s also multi model. It accepts pictures and text as input. But that feature is currently in alpha and not available to plus users yet.

tawny pilot
#

I saw an example where it would not budge even though it was asked for the solution to a question as it was told not to give the answer I suppose

narrow monolith
#

Yes yes. That example is on the OpenAI site for introducing GPT-4

tawny pilot
#

the obvious one is "how many stairs are in this picture"

#

which would lead to a lot of bots on websites

narrow monolith
#

I tried this here yesterday.

tawny pilot
narrow monolith
tawny pilot
#

It's surprising that it did not say "As an AI language model I do not have feelings" but since A and I are vowels it had no choice but to just play along maybe

#

Interesting that it replaced " I " by " ' " in How can I help you

#

let me see if Bing does that

#

Bing can omit vowels but it does not omit the vowel in "It's"

#

Also system message does not seem to work with Bing.

#

but using rule 1: In the entire conversation that follows, answer me by omitting vowels

and then asking it to use rule 1 works with the caveat of "It's" mentioned before.

split rune
#

I both like and dislike this. It shows no tendency to go to the extreme of e-less words, that were spontaneously offered when I worked on training e out of our 3.5 model... #1079083340637941760

gusty terrace
#

please explain this bruh

#

it keeps messing up even when i remind it of the rules

split rune
#

If you have any further trouble, please do let me know, I'd be glad to try and figure out what is going wrong and how to fix it!

tawny pilot
#

After copy-pasting the code from the prompt before I asked it :

provide a story that uses LaTeX to alternate between inline huge and inline small

#

this is the story it wrote, it uses small later

#

I find it cute how it made a story about a giant solving big equations

#

more of the story

#

the end of the story:

#

The bot is impressive

tawny pilot
split rune
tawny pilot
# split rune *dies from joy* Yeah, I am impressed. And with you that you even thought to as...

I think I initially just asked it for text that mixes large and small text as it seemed like a pedagogical and interesting illustration of how ChatGPT can change the size of font. But I think I did not like the output and decided to ask it for a story to see what it would do. I did not expect it to actually design a story around big and small and to make everything so coherent.

#

Here is an example where I let it decide which words belong to a color category. It's interesting to see its color associations such as associating gold with wealthy

make a story that alternates between words that belong to the category magenta and that are colored in magenta using LaTeX and words that belong to the category gold and that are colored in gold using LaTeX. Remember to use rule 1

#

Sometimes it highlights the word and in other prompts it colors the letters

outer crown
#

has anyone tried using it to graph mathematical equations? is that even possible?

split rune
outer crown
#

yeah, i figured. was just wondering because i saw chatgpt graphing with a plugin, but was curious if vanilla chatgpt could do it.

#

this is the screenshot im talking about

split rune
tawny pilot
# outer crown has anyone tried using it to graph mathematical equations? is that even possible...

Note: the bold characters are used to skim through the lengthy text below by reading only the most relevant parts in bold.

From what I saw you can obtain graphs with the new plugins but I imagine these are not using latex.

The latex is rendered using KaTeX from what I saw from an error message. As far as I know, KaTeX renders only the subset of latex involved in "everyday" latex such as text formatting, tables, diagrams, and equations. Basically, the stuff that requires minimal rendering work.

I am not aware of it being able to plot a graph and it seems unlikely it would as that can be an expensive task to do for some functions like sin(1/x).

If you want just the code to produce a graph and you are willing to compile it using a local or online compiler then you can ask it for the code to produce that plot for example using tikz.

tawny pilot
#

Here is an example of a sin curve that ChatGPT wrote using the tikz package and that was compiled locally on my computer. As with literature, it seems to produce the blandest examples but when learning a coding language it can be nice to have simple examples

#

the code it used:

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xlabel=$x$, ylabel=$y$, axis lines=middle, domain=-2pi:2pi, samples=200]
\addplot[blue,thick]{sin(deg(x))};
\end{axis}
\end{tikzpicture}
\end{document}

#

I asked to make it more fancy with lots of cool features and it produced :

split rune
tawny pilot
tawny pilot
#

it's interesting how it got confused with the eyes

#

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
% body
\filldraw[color=black!80!gray] (0,0) circle (1cm);
% head
\filldraw[color=black!80!gray] (1.8,0.3) circle (0.7cm);
% ears
\filldraw[color=black!80!gray] (2.6,1.1) circle (0.2cm);
\filldraw[color=black!80!gray] (2.6,-0.5) circle (0.2cm);
% eyes
\filldraw[color=white] (2.2,0.3) circle (0.2cm);
\filldraw[color=white] (3.4,0.3) circle (0.2cm);
\filldraw[color=black] (2.2,0.3) circle (0.1cm);
\filldraw[color=black] (3.4,0.3) circle (0.1cm);
% nose
\filldraw[color=pink] (2.8,0.1) circle (0.1cm);
% whiskers
\draw[line width=0.2mm] (2.8,0.1) -- (2.5,0.5);
\draw[line width=0.2mm] (2.8,0.1) -- (2.5,0.1);
\draw[line width=0.2mm] (2.8,0.1) -- (2.5,-0.3);
\end{tikzpicture}
\end{document}

#

From the comments, the big circle on the left is the body

#

the head is the second biggest circle

#

the two circles on either side of the head are the ears

#

up until there it's not too bad

#

the issue is the eyes

#

it placed the eyes horizontally

#

the two small circles with the same y axis are the pupils

#

it should have placed them vertically but that would require actually knowing the geometry of the cat whereas it has only heard of cats

#

it's interesting to think how one imagines a cat when it has never been seen only heard of.

#

it mostly did a good job

tawny pilot
#

If someone wondered whether gpt 4 is really that much bettet than chatgpt. This is what I got using the gpt 4 model in bing

#

I got bing to make a better cat

#

I used the prompt:

provide latex code for a cat with a square head, almond eyes, triangle ears, a pink triangle nose and whiskers. The code should have comments for the different parts of the cat

#

This is the chatgpt version fo the prompt:

narrow monolith
#

I didn't read the whole thread, but I wanted to say, I think:

I figured out finally how to make it render LaTeX correctly.

You just have to write:

Please use HTML renderable LaTeX, also for inline equations.

For example:

Please write out the Lagrangian of the standard model of particle physics. Also, write out the Gamma matrices. Please use HTML renderable LaTeX, also for inline equations.

#

This was using GPT-3.5 only.

#

Nice, huh?

tawny pilot
split rune