unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#44799: 28.0.50; Calc: Meter not printed as \text in latex output
@ 2020-11-22 15:20 Michael Heerdegen
  2020-11-22 16:38 ` Mattias Engdegård
  0 siblings, 1 reply; 8+ messages in thread
From: Michael Heerdegen @ 2020-11-22 15:20 UTC (permalink / raw)
  To: 44799


Hello,

in Calc, C-u d L to switch to latex language with \text{} printed units.

`min' for example is then printed "\text{min}" but (bug) Meter still
"m".  AFAIU, the printing code assumes that any unit has at least two
characters, which is obviously not the case for some units.

TIA,

Michael.



In GNU Emacs 28.0.50 (build 3, x86_64-pc-linux-gnu, GTK+ Version 3.24.23, cairo version 1.16.0)
 of 2020-11-22 built on drachen
Repository revision: ce5458fe6eeb37df37119d04228ac7fcd5d39236
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12008000
System Description: Debian GNU/Linux bullseye/sid






^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#44799: 28.0.50; Calc: Meter not printed as \text in latex output
  2020-11-22 15:20 bug#44799: 28.0.50; Calc: Meter not printed as \text in latex output Michael Heerdegen
@ 2020-11-22 16:38 ` Mattias Engdegård
  2020-11-22 21:12   ` Michael Heerdegen
  0 siblings, 1 reply; 8+ messages in thread
From: Mattias Engdegård @ 2020-11-22 16:38 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: 44799

It seems to be a heuristic for distinguishing units from variables, both of which unfortunately have the same representation in Calc. We could make it more precise by looking in the unit table (and allow for prefixes), but it would mean that a variable 'm' would always look like a unit. I'm afraid I have no other good solution at hand.

For that matter, shouldn't units use \mathrm{} rather than \text{} ?






^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#44799: 28.0.50; Calc: Meter not printed as \text in latex output
  2020-11-22 16:38 ` Mattias Engdegård
@ 2020-11-22 21:12   ` Michael Heerdegen
  2020-11-23 10:26     ` Mattias Engdegård
  0 siblings, 1 reply; 8+ messages in thread
From: Michael Heerdegen @ 2020-11-22 21:12 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: 44799

Mattias Engdegård <mattiase@acm.org> writes:

> It seems to be a heuristic for distinguishing units from variables,
> both of which unfortunately have the same representation in Calc. We
> could make it more precise by looking in the unit table (and allow for
> prefixes), but it would mean that a variable 'm' would always look
> like a unit. I'm afraid I have no other good solution at hand.

Ah, so there can be a variable and a unit of the same name at the same
time?  I can s s a variable "m".  Is it good to allow this?  I mean it's
good that meters is "m" as expected but if someone wants to use "m" as a
variable in the same formula it necessarily gets ugly.

> For that matter, shouldn't units use \mathrm{} rather than \text{} ?

I dunno.  latex language mode has several submodes (see
`calc-latex-language'), but none of them uses that.


BTW, do you know (Bug#30231) why allowed characters in units are
restricted?


Thanks,

Michael.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#44799: 28.0.50; Calc: Meter not printed as \text in latex output
  2020-11-22 21:12   ` Michael Heerdegen
@ 2020-11-23 10:26     ` Mattias Engdegård
  2020-11-23 12:16       ` Michael Heerdegen
  0 siblings, 1 reply; 8+ messages in thread
From: Mattias Engdegård @ 2020-11-23 10:26 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: 44799

22 nov. 2020 kl. 22.12 skrev Michael Heerdegen <michael_heerdegen@web.de>:

> Ah, so there can be a variable and a unit of the same name at the same
> time?  I can s s a variable "m".  Is it good to allow this?  I mean it's
> good that meters is "m" as expected but if someone wants to use "m" as a
> variable in the same formula it necessarily gets ugly.

Given the number of units, it seems difficult to disallow using the same symbols as variables. Many innocent-looking single-letter names are units: s, N, m, A, V, W, J, g, l, ...
For instance, 'e' both has a value (2.7something) and is a unit (electron charge).

Variables in Calc include not only names having an assigned concrete value, but also variables in the wider mathematical sense since Calc is capable of some symbolic computing. Units of measurement just use the same mechanism and are treated as any other variables in all computation except for operations explicitly related to units such as 'u s'.

A serious reform seems unlikely unless someone really is willing to do the work. More realistic might be adding a way to tell Calc which variables you want to have typeset as units, as this can vary from person to person and time to time.

> BTW, do you know (Bug#30231) why allowed characters in units are
> restricted?

No idea, but isn't it just the restriction of variable symbols in general? Unless they already play some syntactic role I suppose we could be more permissive. Currency symbols like €, ¥ and $ appear to be of special interest, but $ already has a special meaning.






^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#44799: 28.0.50; Calc: Meter not printed as \text in latex output
  2020-11-23 10:26     ` Mattias Engdegård
@ 2020-11-23 12:16       ` Michael Heerdegen
  2020-11-23 13:52         ` Mattias Engdegård
  0 siblings, 1 reply; 8+ messages in thread
From: Michael Heerdegen @ 2020-11-23 12:16 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: 44799

Mattias Engdegård <mattiase@acm.org> writes:

> A serious reform seems unlikely unless someone really is willing to do
> the work. More realistic might be adding a way to tell Calc which
> variables you want to have typeset as units, as this can vary from
> person to person and time to time.

Would it be possible to make output syntax depend on how the symbol is
actually interpreted by Calc in the given context?

> > BTW, do you know (Bug#30231) why allowed characters in units are
> > restricted?
>
> No idea, but isn't it just the restriction of variable symbols in
> general?

You mean, in Calc?  Then I wonder why we have that restriction.


Regards,

Michael.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#44799: 28.0.50; Calc: Meter not printed as \text in latex output
  2020-11-23 12:16       ` Michael Heerdegen
@ 2020-11-23 13:52         ` Mattias Engdegård
  2020-11-23 14:20           ` Michael Heerdegen
  0 siblings, 1 reply; 8+ messages in thread
From: Mattias Engdegård @ 2020-11-23 13:52 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: 44799

23 nov. 2020 kl. 13.16 skrev Michael Heerdegen <michael_heerdegen@web.de>:

> Would it be possible to make output syntax depend on how the symbol is
> actually interpreted by Calc in the given context?

Not sure if that is even possible. For example, adding 2 m and 3 m gives 5 m, and Calc doesn't care whether m is a variable or unit here.

>>> BTW, do you know (Bug#30231) why allowed characters in units are
>>> restricted?
>> 
>> No idea, but isn't it just the restriction of variable symbols in
>> general?
> 
> You mean, in Calc?  Then I wonder why we have that restriction.

Again, it's probably a matter of history. Calc is old and may even predate full Unicode support in Emacs.

Latin and Greek letters suffice for the vast majority of units; the only major exceptions I can think of are Å and ° (for the angle and °C). Same goes for variables, although diacritics could be useful. Then there are currencies, but as mentioned, $ has special meaning and cannot be used.






^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#44799: 28.0.50; Calc: Meter not printed as \text in latex output
  2020-11-23 13:52         ` Mattias Engdegård
@ 2020-11-23 14:20           ` Michael Heerdegen
  2020-11-23 15:13             ` Mattias Engdegård
  0 siblings, 1 reply; 8+ messages in thread
From: Michael Heerdegen @ 2020-11-23 14:20 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: 44799

Mattias Engdegård <mattiase@acm.org> writes:

> > Would it be possible to make output syntax depend on how the symbol is
> > actually interpreted by Calc in the given context?
>
> Not sure if that is even possible. For example, adding 2 m and 3 m
> gives 5 m, and Calc doesn't care whether m is a variable or unit here.

You are probably right.  Why don't we then just print all symbol names
as we do for units now?  In mathematical contexts variables like in $v$
are printed as Calc currently prints units.

> Latin and Greek letters suffice for the vast majority of units; the
> only major exceptions I can think of are Å and ° (for the angle and
> °C). Same goes for variables, although diacritics could be
> useful. Then there are currencies, but as mentioned, $ has special
> meaning and cannot be used.

There are variants of the latin alphabet including the same letters
looking a bit different.  People may also want to use these.  I don't
see a reason to exclude anything...oh wait, ok, the characters must be
compatible with all supported language modes, that may be the reason for
the restrictions.

Michael.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#44799: 28.0.50; Calc: Meter not printed as \text in latex output
  2020-11-23 14:20           ` Michael Heerdegen
@ 2020-11-23 15:13             ` Mattias Engdegård
  0 siblings, 0 replies; 8+ messages in thread
From: Mattias Engdegård @ 2020-11-23 15:13 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: 44799

23 nov. 2020 kl. 15.20 skrev Michael Heerdegen <michael_heerdegen@web.de>:

> You are probably right.  Why don't we then just print all symbol names
> as we do for units now?  In mathematical contexts variables like in $v$
> are printed as Calc currently prints units.

It's a matter of taste -- most (La)TeX users probably prefer variables in italic as usual.

For that matter, Calc's unit typesetting has more flaws that you may want to fix while you are at it. It omits the space between the number and the unit, normally written something like $9.8\ \mathrm{m/s^2}$. It also gives the unsightly \frac{23 m}{s} instead of the expected 23\ \mathrm{m/s}.

> There are variants of the latin alphabet including the same letters
> looking a bit different.

Right. I don't know how often they are used in Calc formulae though, but why not.






^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-11-23 15:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-22 15:20 bug#44799: 28.0.50; Calc: Meter not printed as \text in latex output Michael Heerdegen
2020-11-22 16:38 ` Mattias Engdegård
2020-11-22 21:12   ` Michael Heerdegen
2020-11-23 10:26     ` Mattias Engdegård
2020-11-23 12:16       ` Michael Heerdegen
2020-11-23 13:52         ` Mattias Engdegård
2020-11-23 14:20           ` Michael Heerdegen
2020-11-23 15:13             ` Mattias Engdegård

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).