texstudio-org / texstudio

TeXstudio is a fully featured LaTeX editor. Our goal is to make writing LaTeX documents as easy and comfortable as possible.
http://www.texstudio.org/
GNU General Public License v3.0
2.74k stars 344 forks source link

LaTeX auto insertion of maths delimiters rather than TeX's #2155

Open Atcold opened 2 years ago

Atcold commented 2 years ago

Environment

Expected behaviour

"Auto insert maths delimiters where needed" should add LaTeX maths delimiters \(…\) rather than TeX's $…$, or should let the user choose between LaTeX and TeX.

Moreover, how does one add custom maths to this auto delimiter insertion mechanism?

hair-splitter commented 2 years ago

You are wrong. $ ... $ can be used in LaTeX in the same way as in Plain TeX. But $$ ... $$ is not recommended for use in LaTeX.

Atcold commented 2 years ago

\( ... \) is LaTeX syntax. $ ... $ is TeX syntax.

plainTeX only allows $. In LaTeX you can use both, but \( ... \) will give less obscure error messages when there is a mistake inside it.

Both are shortcuts to start inline math environments.

https://tex.stackexchange.com/a/513/33287

hair-splitter commented 2 years ago

$ ... $ is officially-supported LaTeX2e syntax!

Atcold commented 2 years ago

Yes, LaTeX does support TeX commands, whereas TeX does not support LaTeX commands. Nothing I wrote seems incorrect to me.

hair-splitter commented 2 years ago

Your request suggested to me that using $ ... $ in LaTeX is incorrect, it is only correct to use it in plain TeX. I claim that $ ... $ is allowed in LaTeX as well as Plain TeX.

On the other hand, not all Plain TeX methods are supported in LaTeX! For example, $$ ... $$ works in LaTeX but is not supported!

sunderme commented 2 years ago

I take the feature request as making the delimiters user changeable. However that does not have a priority for me.

Atcold commented 2 years ago

@sunderme, thanks.

Could you also address my question? I.e. how to add custom maths to the auto-insertion of delimiters? Currently, typing \alpha will trigger the insertion of maths delimiters. But this won't happen, say, for \myAlpha. So, where is the list that the auto-insertion is checking? Is it user editable?

sunderme commented 2 years ago

cwl (completion word list) contain a indicator that a command is a math command, see manual/wiki.