Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conceal amsmath matrix environments #2650

Closed
kiryph opened this issue Feb 26, 2023 · 10 comments
Closed

Conceal amsmath matrix environments #2650

kiryph opened this issue Feb 26, 2023 · 10 comments

Comments

@kiryph
Copy link
Contributor

kiryph commented Feb 26, 2023

This was part of the issue #2645.

Following amsmath matrix environments can be concealed by surrounding them with the corresponding character instead of \begin{type} and \end{type}.

syntax match texCmdEnvM "\\begin{Vmatrix}"     contained conceal cchar=
syntax match texCmdEnvM "\\end{Vmatrix}"       contained conceal cchar=
syntax match texCmdEnvM "\\begin{vmatrix}"     contained conceal cchar=|
syntax match texCmdEnvM "\\end{vmatrix}"       contained conceal cchar=|
syntax match texCmdEnvM "\\begin{Bmatrix}"     contained conceal cchar={
syntax match texCmdEnvM "\\end{Bmatrix}"       contained conceal cchar=}
syntax match texCmdEnvM "\\begin{bmatrix}"     contained conceal cchar=[
syntax match texCmdEnvM "\\end{bmatrix}"       contained conceal cchar=]
syntax match texCmdEnvM "\\begin{pmatrix}"     contained conceal cchar=(
syntax match texCmdEnvM "\\end{pmatrix}"       contained conceal cchar=)
syntax match texCmdEnvM "\\begin{smallmatrix}" contained conceal cchar=(
syntax match texCmdEnvM "\\end{smallmatrix}"   contained conceal cchar=)
@lervag
Copy link
Owner

lervag commented Feb 27, 2023

I've added these now; please update and test. Let me know if you think something be wrong.

@lervag lervag closed this as completed Feb 27, 2023
@kiryph
Copy link
Contributor Author

kiryph commented Mar 1, 2023

Yes, there is something wrong: \end{\([VvBbp]|small\)matrix should show the closing conceal character.

Screenshot 2023-03-01 at 07 32 21

lervag added a commit that referenced this issue Mar 1, 2023
@lervag
Copy link
Owner

lervag commented Mar 1, 2023

Sorry, that was a silly mistake on my part. Should be fixed now.

@kiryph
Copy link
Contributor Author

kiryph commented Mar 1, 2023

Yes, now it looks good. Thank you.

@lervag
Copy link
Owner

lervag commented Mar 1, 2023

By the way, we could add \s* to these regexps as well (e.g. \\begin{x}\s*) - would that be desireable?

@kiryph
Copy link
Contributor Author

kiryph commented Mar 1, 2023

By the way, we could add \s* to these regexps as well (e.g. \begin{x}\s*) - would that be desireable?

Here I am not sure. If someone wants to have it more compact, should be able to remove the whitespace physically.
I suppose you refer to my request to do this for \langle.
Here was my reasoning as following:
I usually use in math mode a space to terminate commands without args to be able to proceed with ordinary letters. I know for \langle A\rangle one could write also \langle{}A\rangle and \langle{} could be concealed as . I think what I have seen by others that, how I do it, is not uncommon.
So the addition of the space is somewhat necessary (to avoid inserting {}). But for \begin{} this is not the case. So adding here spaces could indicate that the author wants give the input a little bit of space and I would leave this untouched.

BTW, conceal \langle{} as could be another concealment request 😄.

A General Note About Concealment in Matrices

The alignment of columns in math matrices can be/is messed up due to active concealment which can actually decrease readability (Is the correct term in the correct column?). But I suppose there is nothing what can be done to align concealed blocks according to &, \\ and the length of the concealed expression.

@lervag
Copy link
Owner

lervag commented Mar 1, 2023

By the way, we could add \s* to these regexps as well (e.g. \begin{x}\s*) - would that be desireable?

Here I am not sure. If someone wants to have it more compact, should be able to remove the whitespace physically. I suppose you refer to my request to do this for \langle. Here was my reasoning as following: I usually use in math mode a space to terminate commands without args to be able to proceed with ordinary letters. I know for \langle A\rangle one could write also \langle{}A\rangle and \langle{} could be concealed as . I think what I have seen by others that, how I do it, is not uncommon. So the addition of the space is somewhat necessary (to avoid inserting {}).

You are right!

But for \begin{} this is not the case. So adding here spaces could indicate that the author wants give the input a little bit of space and I would leave this untouched.

Agreed!

BTW, conceal \langle{} as could be another concealment request smile.

Hmm... why would anyone want to write that?

A General Note About Concealment in Matrices

The alignment of columns in math matrices can be/is messed up due to active concealment which can actually decrease readability (Is the correct term in the correct column?). But I suppose there is nothing what can be done to align concealed blocks according to &, \\ and the length of the concealed expression.

Yes, that is probably right, and no, I don't think we can do much about that. Sorry.

@kiryph
Copy link
Contributor Author

kiryph commented Mar 2, 2023

Hmm... why would anyone want to write that?

I do not know. Not me.

@kiryph
Copy link
Contributor Author

kiryph commented May 15, 2023

Regarding the issue with alignment in matrix environments when concealment is active:

Do not use concealment but use directly unicode characters, e.g. with https://ctan.org/pkg/unicode-math or https://ctan.org/pkg/unicode-math-input and a vim plugin to help entering unicode characters: https://github.com/joom/latex-unicoder.vim.

@lervag
Copy link
Owner

lervag commented May 15, 2023

Yes, agreed, that would be a simple solution. At least conceptually!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants