szhorvat / MaTeX

LaTeX labels in Mathematica
http://szhorvat.net/mathematica/MaTeX
MIT License
375 stars 45 forks source link

MaTeX should work with StringForm #3

Closed sungmin817 closed 9 years ago

sungmin817 commented 9 years ago

This is not an issue but a feature request and this might be just a matter of taste.

I recently found that MaTeX cannot handle StringForm correctly, e.g.,

StringForm[ "\\frac{x}{``}", 3] // MaTeX

gives an unexpected result. I know there is a very simple workaround such as

StringForm[ "\\frac{x}{``}", 3] // ToString // MaTeX

I understand that MaTeX should not have all possible overloads for arbitrary heads. However, I think StringForm is primitive enough to be considered special.

szhorvat commented 9 years ago

MaTeX simply applies TeXForm to everything that is not a string, so the result you see is ultimately due to TeXForm's behaviour. The only objects it doesn't apply TeXForm are strings, there are no other exceptions (for now).

The argument for keeping things as they are is that this behaviour is simple and predictable.

Of course I can see why this is annoying with StringForm. But is there any reason to use StringForm instead of StringTemplate with MaTeX? Is StringTemplate["\\frac{x}{``}][3] an acceptable workaround for you?

sungmin817 commented 9 years ago

Thanks for the quick reply. You workaround StringTemplate["\frac{x}{``}][3] seems very nice. I simply did not know it.

Anyway, thanks for the nice package.

2015-07-29 13:27 GMT+02:00 Szabolcs Horvát notifications@github.com:

MaTeX simply applies TeXForm to everything that is not a string, so the result you see is ultimately due to TeXForm's behaviour. The only objects it doesn't apply TeXForm are strings, there are no other exceptions (for now).

The argument for keeping things as they are is that this behaviour is simple and predictable.

Of course I can see why this is annoying with StringForm. But is there any reason to use StringForm instead of StringTemplate with MaTeX? Is StringTemplate["\frac{x}{``}][3] an acceptable workaround for you?

— Reply to this email directly or view it on GitHub https://github.com/szhorvat/MaTeX/issues/3#issuecomment-125923686.

szhorvat commented 9 years ago

I thought about this and I can't find much harm in adding the exception for StringForm while it will make the user experience a bit better.

So fixed by 527a2dabea22c17df11d017dc00cd871666f244a

To force a literal formatting of the string (the effect StringForm had before) one can use HoldForm. But I don't see anyone needing this anyway, given MaTeX's main focus.

sungmin817 commented 9 years ago

Thank you for the consideration.

2015-07-29 13:54 GMT+02:00 Szabolcs Horvát notifications@github.com:

I thought about this and I can't find much harm in adding the exception for StringForm while it will make the user experience a bit better.

So fixed by 527a2da https://github.com/szhorvat/MaTeX/commit/527a2dabea22c17df11d017dc00cd871666f244a

To force a literal formatting of the string (the effect StringForm had before) one can use HoldForm. But I don't see anyone needing this anyway, given MaTeX's main focus.

— Reply to this email directly or view it on GitHub https://github.com/szhorvat/MaTeX/issues/3#issuecomment-125929666.