goldfirere / units

The home of the units Haskell package
95 stars 19 forks source link

support LaTeX expressions of units #30

Closed nushio3 closed 10 years ago

nushio3 commented 10 years ago

See how the units are rendered in The Solar physics sample article .

The Solar luminosity is 3.839e30 (kg * m^2)/s^3, or 3.839e30 W.

We'd like to utilize the LaTeX's ability and represent units more beautifully, using superscripts and special unit symbols (e.g. \AA for angstrom and \mu for micro.)

I think a way to do this is to define Render instances for specific unit types in units-defs and for unit combinators.in units . There can be other ways with other benefits. For example we may not want units to depend on HaTeX package. We can permit orphan instances. I'd like to listen for better ways.

goldfirere commented 10 years ago

My approach to this is to expose the parseUnit function so that your code can then do what it wants with parsed unit expressions, such as desugar them to LaTeX. I believe this should work for your purposes -- please reopen with more info if not.

nushio3 commented 10 years ago

My idea was to convert quantity values (Qu s) to LaTeX expressions, not unit template haskell strings. In other words, I'd like to create the published versions of the pretty printers mentioned in the paper . However, on my second thought, I can do what I want by defining a special-purpose type class on the pretty-printer module. The implementation will probably go into part of authoring library. Therefore I don't need to update units for this purpose.

Thank you for pointing out the ideas! parseUnit will come in handy in the future.