Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering multicharacter symbols in LaTeX #468

Closed
smiths opened this issue Feb 28, 2018 · 15 comments · Fixed by #3881
Closed

Rendering multicharacter symbols in LaTeX #468

smiths opened this issue Feb 28, 2018 · 15 comments · Fixed by #3881
Assignees
Labels
artifacts easy At quick glance, it should be 'easy,' but you never know what'll happen! enhancement

Comments

@smiths
Copy link
Collaborator

smiths commented Feb 28, 2018

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.

@JacquesCarette
Copy link
Owner

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?

@smiths
Copy link
Collaborator Author

smiths commented Mar 14, 2018

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.

@JacquesCarette
Copy link
Owner

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.

@smiths
Copy link
Collaborator Author

smiths commented Mar 15, 2018

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.

@samm82
Copy link
Collaborator

samm82 commented Jul 18, 2019

Related to #1639

@JacquesCarette
Copy link
Owner

Is this still needed?

@smiths
Copy link
Collaborator Author

smiths commented Jun 4, 2020

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.

@JacquesCarette
Copy link
Owner

Yes, I think Atomic is the solution.

@balacij
Copy link
Collaborator

balacij commented Dec 3, 2021

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)

@JacquesCarette
Copy link
Owner

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

@balacij
Copy link
Collaborator

balacij commented Dec 3, 2021

For isSafeLoad = capacity > Load, we have:

<tr>
<th>Equation</th>
<td>
\[\mathit{isSafeLoad}=\mathit{capacity}\gt{}\mathit{Load}\]
</td>
</tr>
<tr>

and
\\ \midrule \\
Equation & \begin{displaymath}
\mathit{isSafeLoad}=\mathit{capacity}\gt{}\mathit{Load}
\end{displaymath}


For LR = NFLGTFLSF, we have:

<tr>
<th>Equation</th>
<td>\[\mathit{LR}=\mathit{NFL} \mathit{GTF} \mathit{LSF}\]</td>
</tr>

and
\\ \midrule \\
Equation & \begin{displaymath}
\mathit{LR}=\mathit{NFL} \mathit{GTF} \mathit{LSF}
\end{displaymath}

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.

@JacquesCarette
Copy link
Owner

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.

@balacij balacij self-assigned this Jan 31, 2023
@balacij balacij added artifacts easy At quick glance, it should be 'easy,' but you never know what'll happen! labels Apr 26, 2023
@balacij balacij assigned BilalM04 and unassigned balacij Jul 18, 2024
@BilalM04
Copy link
Collaborator

BilalM04 commented Jul 24, 2024

Currently the multiplication operator in the TeX printer is defined as:

The above code inserts a blank space in the TeX code between items being multiplied. When compiled and rendered, the PDF does not have any space between the items being multiplied.


The multiplication operator in the HTML printer is defined as:

&#8239 is a narrow no-break space. The HTML SRS uses HTML syntax for simple expressions, and TeX for the more complicated ones.


The issue here arises when multi-character symbols are being multiplied. Since the Mul operator is rendered without a space, it is difficult to distinguish what exactly is being multiplied when there are multi-character symbols. On the side of drasil-printers, it is not feasible to come up with rules at the time of rendering as it is very difficult to know whether we are multiplying single character or multicharacter symbols with the current structure, as @JacquesCarette mentioned in #468 (comment).

One possible quick fix solution is rendering the Mul operator as a thin space (\,). Although this solves the issue for multi-character symbols, it also inserts a thin space between single-character symbols being multiplied. I'm not sure if that is something we want. Here is examples of how it would render:

  1. Example with single-character symbols. (Original)
    image
  2. Example with multi-character symbols. (Original)
    image

This issue is more complicated than it appears, an exact solution just for multi-character symbols does not come to my mind. @balacij what do you think?

@JacquesCarette
Copy link
Owner

The original is "too tight". I think the solution of using \, seems quite reasonable.

@smiths
Copy link
Collaborator Author

smiths commented Jul 25, 2024

I agree with @JacquesCarette. This is a nice practical fix @BilalM04. The equation for LR in GlassBR has bothered me for years. It looks much better with your fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
artifacts easy At quick glance, it should be 'easy,' but you never know what'll happen! enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants