Drasil icon indicating copy to clipboard operation
Drasil copied to clipboard

Rendering multicharacter symbols in LaTeX

Open smiths opened this issue 7 years ago • 12 comments

For symbols that consist of multiple characters, like min, max, MINFRACT, etc, when they are rendered in LaTeX equations they would look better in an \mbox. Rather than LaTeX interpreting min as m times i times n, a \mbox{min} would achieve a more natural spacing.

smiths avatar Feb 28 '18 16:02 smiths

I thought that if you used Atomic, they would get thus rendered (well, not with an mbox, but with mathsf or similar). Perhaps some of these are hacked-in rather than using the correct symbol combinators?

JacquesCarette avatar Feb 28 '18 19:02 JacquesCarette

We discussed this further in the "all hands meeting" on March 14. GlassBR has several examples of equations that look odd, for instance LR = NFR GTF LSF. This would look better with a multiplication symbol. Maybe we can detect cases like this an automatically add the symbol when rendering? This isn't a high priority, but something to keep in mind for the future.

smiths avatar Mar 14 '18 15:03 smiths

This would be quite hard to achieve, at least not without a clear way of understanding what is the root cause of the oddness. Having multiple multiplication symbols is not hard. It is the decision criteria to use one versus another which is.

JacquesCarette avatar Mar 15 '18 00:03 JacquesCarette

Yes, we talked about this a bit at the start of the meeting. We thought that with some thought we could come up with some rules for when explicit multiplication symbols would look nice. After all, human being have some implicit rules when they change the formatting of the display of an equation. This isn't a high priority, but it might be a little project for a future student to tackle. A simple rule might be that multi-character symbols multiplied together need an explicit multiplication symbol.

smiths avatar Mar 15 '18 00:03 smiths

Related to #1639

samm82 avatar Jul 18 '19 19:07 samm82

Is this still needed?

JacquesCarette avatar May 06 '20 19:05 JacquesCarette

Yes, this is still needed. I had a quick look at the LaTeX code and some of the equations are spaced very oddly. I'll attach the example of is_safeProb. It looks like is - safeProb, with LaTeX implicitly multiplying all the symbols.

is_safeProb

The solution might just be to use Atomic properly? Not all of the symbols look wrong in the documents.

smiths avatar Jun 04 '20 03:06 smiths

Yes, I think Atomic is the solution.

JacquesCarette avatar Jun 04 '20 20:06 JacquesCarette

Ah, I think we've given this a small attempt in #2865; image

However, some things are still problematic: image

(both are examples from GlassBR)

balacij avatar Dec 03 '21 01:12 balacij

Definitely still a problem! What is the generated LaTeX for that?

JacquesCarette avatar Dec 03 '21 03:12 JacquesCarette

For isSafeLoad = capacity > Load, we have: https://github.com/JacquesCarette/Drasil/blob/ad1e157f9ce96046e74787aaf31cb4e0726fe237/code/stable/glassbr/SRS/HTML/GlassBR_SRS.html#L938-L944 and https://github.com/JacquesCarette/Drasil/blob/ad1e157f9ce96046e74787aaf31cb4e0726fe237/code/stable/glassbr/SRS/PDF/GlassBR_SRS.tex#L439-L442


For LR = NFLGTFLSF, we have: https://github.com/JacquesCarette/Drasil/blob/ad1e157f9ce96046e74787aaf31cb4e0726fe237/code/stable/glassbr/SRS/HTML/GlassBR_SRS.html#L1894-L1897 and https://github.com/JacquesCarette/Drasil/blob/ad1e157f9ce96046e74787aaf31cb4e0726fe237/code/stable/glassbr/SRS/PDF/GlassBR_SRS.tex#L1064-L1067

It's also weird that the generated HTML here is different between them. They look like they should use the same constructors and have the same code-styled output, and yet they're not.

balacij avatar Dec 03 '21 23:12 balacij

I think that MathJax wants \[ for inline math, whereas "standard latex" now prefer \begin{displaymath} (over $). I think it's ok, and this is controlled via some options that are passed in.

Is there still a problem with >? I don't think so?

Anyways, implicit multiplication is definitely a problem. At the very least, we should hand-insert some space (I tend to use \ , i.e. backslash-space in my own latex. Although we might want to use \thinspace instead as a first experiment. That will definitely be better. We might still need to explore using an explicit multiplication symbol.

JacquesCarette avatar Dec 04 '21 16:12 JacquesCarette