LaTeX-auto-activating-snippets icon indicating copy to clipboard operation
LaTeX-auto-activating-snippets copied to clipboard

combine with siunitx

Open fbraennstroem opened this issue 3 years ago • 7 comments

Hi, very interesting snippets approach... is there some thinking about handling siunitx with the convenient approach as well? It would be great if the units get converted like m gets converted to \m and e.g. kg to \kg... but only if it is located in the second part of the SI-environment $\SI{10}{\m}... maybe this already possible!?

Thank you in advance!

Fab

fbraennstroem avatar May 25 '21 14:05 fbraennstroem

Hmmm. That's would be nice. I can't say I'll work on this any time soon but feel free to propose something.

tecosaur avatar May 25 '21 15:05 tecosaur

ok, thank you for your quick reply; I try to get familiar with it

fbraennstroem avatar May 25 '21 16:05 fbraennstroem

I was about to recommend writing a yasnippet snippet for \SI{}{} with a field transformation in the second {}. But then I thought that maybe my concept of \SI is wrong, so I went to the siunitx documentation and fount: image

Anyway, having these \m \kg snippets expand only in \SI* macros is troublesome. If that field transformation is too complicated to write maybe you could make another yasnippet for \SI that enables a snippet keymap only in the context of the snippet.

ymarco avatar Jun 01 '21 17:06 ymarco

Hi, could there be the option to use e.g. ,, after the unit as it is a quicker way to write a backslash.

your code from yesterday includes a wrapping

(aas-set-snippets 'laas-mode
  :cond #'laas-object-on-left-condition
  ". " (lambda () (interactive)
         (laas-wrap-previous-object "dot")
         ;; if you want a space after the \dot{}, I think it's an improvement
         ;; and I changed ".. " to this behavior in the latest commit
         ;;(insert " ")
         ))

maybe a similar way exists to just a "" before the previous object?

Thank you in advance! Fab

fab6 avatar Jan 14 '22 18:01 fab6

maybe a similar way exists to just [add?] a "" before [after?] the previous object?

You can give laas-wrap-previous-object a cons, it's in the function documentation.

could there be the option to use e.g. ",, " after the unit as it is a quicker way to write a backslash.

Not sure how this is quicker.

ymarco avatar Jan 14 '22 18:01 ymarco

Thank you for your quick response! For my current arm/hand position typing the backslash is a bit outside so I need to twist a bit the fingers... this results (it seems) in a slowdown for me typing siunitx equations.

fab6 avatar Jan 14 '22 18:01 fab6

ok, not sure yet if this is really better ;-)

      ",, " (lambda () (interactive)
             (laas-wrap-previous-object (cons "\\" " "))
             )

fab6 avatar Jan 14 '22 19:01 fab6