namedtensor / notation

108 stars 5 forks source link

LaTeX macros #51

Closed davidweichiang closed 3 years ago

davidweichiang commented 3 years ago

In #31 @boazbk suggests changing the \ndot, \nsum, etc. macros so that they don't automatically change font. Instead, he suggests defining a separate macro for each axis name.

The advantage of this is that it makes it easier to write \ndot{ax_i} where i is a variable. Right now, this would print i in the name font, which is not correct. There's an ugly hack in there right now (\ndot{ax\sub{i}}) which should really be fixed.

Similarly, it would become easier to write \ndot{\substack{\foo \ \bar}} to stack axis names, which we can't currently do. We could even build the \substack into the macro, so we'd be able to write \ndot{\foo \ \bar}.

boazbk commented 3 years ago

Yes I strongly prefer this - I would like the latex to be readable, and so I really like \foo and \bar as macros that can be used throughout the code (maybe use them also with \ensuremath and \xspace so we can use them also outside of math mode)

davidweichiang commented 3 years ago

Are there any situations where someone might need to define a lot of names and be unhappy about filling the namespace with lots of macros?

More realistically, I can easily imagine that this would encourage lazy authors to write \ndot{foo} causing foo to be set in the wrong font.

boazbk commented 3 years ago

As I mentioned, I think we need to have an optional argument that will enable someone to separate the name of the axis from the name of the macro, and so enable defining \axfoo for \foo

People can always be lazy, but probably if \foo gives the ax foo in the right font, then it encourages to use it more in situations such as $\R^\foo$ etc..

davidweichiang commented 3 years ago

I think I'd prefer it if it were not optional, i.e., the user always defines a name using \newaxis{\foo}{foo}. This is similar to amsmath's \DeclareMathOperator and it also works with Pandoc.

boazbk commented 3 years ago

Sure

On Wed, Jan 13, 2021 at 11:57 AM David Chiang notifications@github.com wrote:

I think I'd prefer it if it were not optional, i.e., the user always defines a name using \newaxis{\foo}{foo}. This is similar to amsmath's \DeclareMathOperator and it also works with Pandoc.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/namedtensor/notation/issues/51#issuecomment-759582302, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJYO6DZ62SFIB5IBUCXW5TSZXGFZANCNFSM4WA7V3WQ .

davidweichiang commented 3 years ago

Trying this out in #52. One benefit of defining a macro for each name is that it helps you to catch inconsistent names. On the flip side, it might encourage people to reuse existing names, which might encourage them to use very generic names.

davidweichiang commented 3 years ago

Maybe we should retain the \name macro for one-off names (like amsmath does with \DeclareMathOperator versus \operatorname).