randy3k / AlignTab

An alignment plugin for Sublime Text using regular expression
MIT License
631 stars 25 forks source link

Allignment of table with both negative and positive numbers #49

Closed AllanLRH closed 9 years ago

AllanLRH commented 9 years ago

This is a snippet of a LaTeX table I aligned with AlignTab.

  &  -1.5    \\
  &  -1.0    \\
  &  -0.5    \\
  &  0.0    \\
  &  0.5    \\

While it's beautiful, I'd like to be able to align it like this instead (aligning to the first number, not it's sign).

  &  -1.5    \\
  &  -1.0    \\
  &  -0.5    \\
  &   0.0    \\
  &   0.5    \\

Is this possible? I can't seem to figure out an appropriate combination of regex and alignment specification.

randy3k commented 9 years ago

thought it looks a bit complicated, it is the input that you need

(?<!\\)&|\\\\|[0-9.]*/l0l1
randy3k commented 9 years ago

does it work?

AllanLRH commented 9 years ago

Yes, sorry for not answering – It's exam time for me :)

It works. However I ran into trouble, when commands are included:

foo  &  \num{2.8110e-08}   &  -0.16246           \\
bar  &  \textbf{-123.321}  &  0.16246            \\

…but I guess that the point of ignoring the sign when aligning diminishes as the table fills up with commands.