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.82k stars 345 forks source link

Autoinsert math delimiters doesn't work if command takes arguments #219

Closed mikeymell closed 6 years ago

mikeymell commented 6 years ago

The new feature works for math commands which are completed with no arguments such as \sin and \int, but math delimiters are not inserted for commands with arguments such as \frac{num}{den} or \int_{min}^{max}

Environment

Expected behavior

when enabled, all math commands should be inserted with delimiters, whether or not they have arguments.

dbitouze commented 6 years ago

In addition, this feature works if (e.g.) \sin is manually entered, but doesn't work if it is inserted from the "Math → Math Functions" menu entry.

sunderme commented 6 years ago

1) the cwl list are not complete, so txs does not know all math commands as math commands 2) I have no intention to insert $$ for every possible way to enter commands, this is strictly a completer feature only

sunderme commented 6 years ago

we can obviously extend the number of commands, but since the cwls are so numerous, it is far too much for me to do it. So pull-request are welcome.

mikeymell commented 6 years ago

@sunderme, that's understandable and I'd like to help. Can you give a brief description of what needs to be done? just a few lines to save me having to scour documentation. At the very least amsmath should work out of the box in the first release in which this feature is on by default, I think.

Furthermore, It seems surprising that the completer recognizes \int as a math command, but not \int_{min}^{max}, are you completely sure that's simply a problem with the CWL file?

sunderme commented 6 years ago

first you need access to the cwl files. The preferred way would be to clone our github repository (see also https://github.com/texstudio-org/texstudio/wiki/Compiling) It is not necessary to compile txs, you can place the cwl files from 'texstudio/completion' in %config%/texstudio/completion/user and adapt them there. The important step is that the math commands in the cwl file need to be classified as math-commands by setting '#m', see manual When done, you can either generate a pull-request, which is the easiest way for us, or send the changed files here.

mikeymell commented 6 years ago

As I said, \int inserts with delimiters while \int_{min}^{max} doesn't. Grep shows:

latex-mathsymbols.cwl
119:\int#m
120:\int_{min}^{max}#m
121:\int\limits_{min}^{max}#*m

It doesn't seem like this is just a CWL problem.

sunderme commented 6 years ago

okay, my bad. I will look into it, but probably in more detail after release of 2.12.10

mikeymell commented 6 years ago

Thanks.