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

\rm deprecated in LaTeX #3037

Closed
benjub opened this issue Feb 12, 2023 · 26 comments · Fixed by #3052
Closed

\rm deprecated in LaTeX #3037

benjub opened this issue Feb 12, 2023 · 26 comments · Fixed by #3052
Labels

Comments

@benjub
Copy link
Contributor

benjub commented Feb 12, 2023

Since \rm is deprecated in LaTeX (it has been for 28 years), we should replace it overtime with \mathrm{...} (since symbol definitions assume we are in math mode) or at least use the latter for new symbols. Currently, set.mm has 828 occurrences of \rm.

(Remark: also deprecated in LaTeX are: \rm, \it, \bf, \tt, \sc, \sl, \sf and also $$ ... $$ for displayed equations.)

@tirix
Copy link
Contributor

tirix commented Feb 12, 2023

Can we do a global replace instead of replacing "over time"?
Also, are there also occurrences of the other deprecated LaTeX commands?
Also, pinging @GinoGiotto because he was interested in generating LaTeX from Metamath.

@benjub
Copy link
Contributor Author

benjub commented Feb 12, 2023

We can probably take care of most cases automatically by replacing appropriate regexes, but that's not that easy since we need to replace \rm arbitraryexpression with \mathrm{arbitraryexpression} where the arbitrary expression stops at the following space or quote (edit: or backslash, or anything else ending a LaTeX token...), but it can be a single or double quote, maybe there are extra quotes within the main quote, etc.

As for the other deprecated commands, I found in set.mm \sf once and \tt twice. But there are other databases (ping @jkingdon) and some deprecated commands may be found in the part of metamath.c that generates LaTeX code (I haven't checked).

@jkingdon
Copy link
Contributor

But there are other databases

A glance through iset.mm shows mostly markup copy-pasted from set.mm. The goal is to keep these identical so it should be feasible to make the edits in set.mm and then copy-paste the syntaxes which are found in both over to iset.mm. Or any other means of achieving (roughly) that result.

david-a-wheeler added a commit that referenced this issue Feb 13, 2023
Per #3037, update the LateX to change from the deprecated \rm
to the official \mathrm{...}.

I started this using this regular expression:
sed -E -i '' -e '/latexdef/s/\\rm (\\?[A-Za-z0-9\-^\.\[\]\;]+) *\}/\\mathrm{\1}}/g' set.mm iset.mm

.. and then fixed others by hand. I fixed all the entries in
set.mm, and many in iset.mm. If this approach seems reasonable we can fix
the rest of iset.mm.

Signed-off-by: David A. Wheeler <[email protected]>
@david-a-wheeler
Copy link
Member

I have good news, I know regular expressions https://xkcd.com/208/.

I made a first stab here:
#3039

@GinoGiotto
Copy link
Contributor

GinoGiotto commented Feb 17, 2023

Can we do a global replace instead of replacing "over time"? Also, are there also occurrences of the other deprecated LaTeX commands? Also, pinging @GinoGiotto because he was interested in generating LaTeX from Metamath.

Thanks for mentioning me, from my beginner side I can only say that {\rm text} and \mathrm{text} produce the same result in the output latex page except when line breaks get involved, as mentioned in metamath/metamath-exe#129 (comment). Although It's true that this edit would fix my specific case, I woudn't consider it as a fix for Metamath.exe bug #129, because as correctly stated in metamath/metamath-exe#129 (comment) the same problem would appear whenever there are any spaces in a tex substitution. So either we set a rule that no spaces should appear in any tex substitution, or the metamath.exe code should be changed.

@david-a-wheeler
Copy link
Member

Is it fixed if you set the maximum line width from within Metamath.exe?

@GinoGiotto
Copy link
Contributor

GinoGiotto commented Feb 17, 2023

Is it fixed if you set the maximum line width from within Metamath.exe?

As stated in metamath/metamath-exe#129 (comment) setting a line length too high cuts the text out of the latex page.
Now technically setting an appropriate length (not too high, not too low) fixes the issue in this example, but here is the problem:

Latex editors don't show which lines generate the errors, they only show that there are some errors somewhere inside the proof (more specifically they collect all the errors and show them at the end of the proof, which is not helpful) . So I found it challenging the first times to figure out what was going on and why since editors just refused to compile. The fact that I spent time trying to understand the cause doesn't mean that other new members would be willing to do the same. I can totally see new Metamath users being discouraged by that, since this error is quite common and some steps are required to understand the cause. I didn't have any specific interest in the "rankidn" theorem, the example I provided was for demonstration purpose only, I just chose it because it was short and easy to understand. Also it's not even guaranteed that a resolving line width exists for all proofs, since for long ones this error appear multiple times, and line breaking could just fell inside a following curly bracket in the same statement or some others.

So either it should be written somewhere that when an user sees those errors, he just have to "guess" an appropriate line width to fix it, or the line breaking itself should be adjusted.

@tirix
Copy link
Contributor

tirix commented Feb 18, 2023

the metamath.exe code should be changed

I believe that is what we need to do: metamath.exe does not handle line breaking correctly for LaTeX. That is also @digama0's comment. I think we can continue to track that issue there?

@GinoGiotto
Copy link
Contributor

the metamath.exe code should be changed

I believe that is what we need to do: metamath.exe does not handle line breaking correctly for LaTeX. That is also @digama0's comment. I think we can continue to track that issue there?

Yes, personally I agree with this approach, everything else looks like a palliative to me.

@david-a-wheeler
Copy link
Member

Let's try to keep the different issues separate.

"Open Latex curly brackets bug" metamath/metamath-exe#129 is about insertion of newlines within braces (which causes TeX errors). I suspect we'll change metamath-exe to stop generating newlines inside TeX, but whatever we do, that discussion belongs there.

This issue is the problem of replacing \rm and so on, which are deprecated, which expressions that are not deprecaated.

@benjub
Copy link
Contributor Author

benjub commented Feb 18, 2023

While looking at #3039, I also saw that many of these definitions are actually meant to be \operatorname (which differs from \mathrm mainly by spacing), but this is harder to fix globally since this is case-by-case.

@benjub
Copy link
Contributor Author

benjub commented Feb 19, 2023

I never use the feature but I just generated a tex file using metamath.c, and here are a few suggestions on the preamble:

  • replace \usepackage{amsmath} with \usepackage{mathtools}, which loads amsmath and is an extension to it, fixing some bugs and spacing inconsistencies (and it is a "core" package, maintained by the main team). See https://www.ctan.org/pkg/mathtools
  • replace \usepackage{graphicx} % For rotated iota with \usepackage{phonetic} and take latexdef of iota (resp. _iota) to be "\text{\riota}" (resp. "\underline{\text{\riota}}"). See https://www.ctan.org/pkg/phonetic and https://www.ctan.org/pkg/comprehensive paragraph "Reflecting and rotating existing symbols"
  • it appears that metamath.c displays label names in typewriter font and uses {\tt xxx} instead of \texttt{xxx}.

@david-a-wheeler
Copy link
Member

david-a-wheeler commented Feb 19, 2023

@benjub - those sound plausible. Can you please create a new issue for those ideas? This issue is about replacing \rm.

david-a-wheeler added a commit that referenced this issue Feb 20, 2023
* Update LaTeX, \rm -> \mathrm

Per #3037, update the LateX to change from the deprecated \rm
to the official \mathrm{...}.

I started this using this regular expression:
sed -E -i '' -e '/latexdef/s/\\rm (\\?[A-Za-z0-9\-^\.\[\]\;]+) *\}/\\mathrm{\1}}/g' set.mm iset.mm

.. and then fixed others by hand. I fixed all the entries in
set.mm, and many in iset.mm. If this approach seems reasonable we can fix
the rest of iset.mm.

* Fix long lines

* Remove unnecessary {..} around TeX \methrm

In TeX, \mathrm{...} is a single unit.

This removes the unnecessary {...} surrounding them in many cases.
This was done by:

~~~~sh
sed -E -e 's/\{\\mathrm\{([A-Za-z0-9;\\</#]+)\}\}/\\mathrm\{\1\}/g' set.mm \
  > ,set
mv ,set set.mm
~~~~~

Signed-off-by: David A. Wheeler <[email protected]>

* Remove unnecessary {...} in TeX on iset.mm

Signed-off-by: David A. Wheeler <[email protected]>
@benjub
Copy link
Contributor Author

benjub commented Feb 20, 2023

See metamath/metamath-exe#130

@david-a-wheeler
Copy link
Member

I've replaced \rm with \mathrm everywhere I found them, so I think we can close this issue.

@benjub - you said that:

(Remark: also deprecated in LaTeX are: \rm, \it, \bf, \tt, \sc, \sl, \sf and also $$ ... $$ for displayed equations.)

If you can tell me what precisely should be replaced with what, I can do a lot of it. E.g., "replace ``\rm FOOwith\mathrm{FOO}`.

I don't know what the TeX community prefers now, but I do know regular expressions :-).

@david-a-wheeler
Copy link
Member

I think we can (soon) close this issue, but I'm hoping that @benjub will create a new issue identifying the other needed replacements :-). Teamwork!

@benjub
Copy link
Contributor Author

benjub commented Feb 20, 2023

All .mm files in this repository with latexdef's (set.mm, iset.mm, hol.mm, ql.mm, nf.mm) should be fixed.

Actually, apart from \rm, the others occur sufficiently rarely that a manual change is probably better.

  • {\rm xxx} --> \mathrm{xxx}
  • {\cal xxx} --> \mathcal{xxx}
  • {\sf xxx} --> \mathsf{xxx}
  • {\Bbb xxx} --> \mathbb{xxx}
  • {\bb xxx} --> xxx \mathrm{xxx} (thanks @tirix)
  • \Sigma^\string^ --> \sum\hat{} (@glacode ?)

Note: the expressions on the LHS above are not always surrounded by braces...

  • \tt --> change manually the latexdef... I'll come up with something
  • \it, \bf, \sc, \sl: do not occur

edit: I hadn't seen your latest message above. Tell me if this is enough or your prefer a new issue.

@tirix
Copy link
Contributor

tirix commented Feb 20, 2023

{\bb xxx} --> xxx

Those \bb are actually for symbols introduced by Scott Fenton and are still only in use in his mathbox, AFAICS.

Normally \bb should be converted to \mathbb, but that would be for blackbold symbols ($\mathbb{R}$, $\mathbb{Z}$, $\mathbb{C}$). Here it is used for normal identifiers, like Seg. So maybe we can change them to \mathrm too?

@benjub
Copy link
Contributor Author

benjub commented Feb 20, 2023

{\bb xxx} --> xxx

Those \bb are actually for symbols introduced by Scott Fenton and are still only in use in his mathbox, AFAICS.

Sorry, I saw things about Tarski geometry so I assumed it was you ! But it's @sctfn (e.g., https://us.metamath.org/mpeuni/df-ofs.html). Actually, \bb is for a surrounding box, not for blackboard bold font. I don't know if the former or the latter was meant in the present case.

You're right, I should have written \mathrm{xxx} above.

@glacode
Copy link
Contributor

glacode commented Feb 20, 2023

  • \Sigma^\string^ --> \sum\hat{} (@glacode ?)

I'm afraid I've not edited a LaTex file since 1995... :-)

Please, feel free to apply any change that solves the issue

Glauco

@sctfn
Copy link
Contributor

sctfn commented Feb 21, 2023 via email

@david-a-wheeler
Copy link
Member

All & especially @benjub ...

I've been assuming that all generated TeX is in math mode. But I've found that show proof of foeq1produces an error - does this mean that we cant' use\math...{...}`, or something else? Here's the command that triggers the error & the error:

rm -f foo2.tex
metamath <<END
read set.mm
open tex foo2.tex
show proof foeq1 /tex
close tex
END
pdflatex foo2.tex

I get this error message:

(/usr/local/texlive/2022/texmf-dist/tex/latex/amsfonts/umsb.fd)
LaTeX Warning: Reference `eq:fneq1' on page 1 undefined on input line 47.
LaTeX Warning: Reference `eq:rneq' on page 1 undefined on input line 47.
LaTeX Warning: Reference `eq:eqeq1d' on page 1 undefined on input line 47.
LaTeX Warning: Reference `eq:anbi12d' on page 1 undefined on input line 47.
! LaTeX Error: \mathrm allowed only in math mode.
See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
l.47 \end{align}

@david-a-wheeler
Copy link
Member

Hmm, if I check out an old version:

git checkout 3c59fac57e36c67e6f34f0bfe012183639f68825

I still get an error with show proof foeq1 /tex ... pdflatex food2.tex:

(/usr/local/texlive/2022/texmf-dist/tex/latex/amsfonts/umsb.fd)
LaTeX Warning: Reference `eq:fneq1' on page 1 undefined on input line 45.
LaTeX Warning: Reference `eq:rneq' on page 1 undefined on input line 45.
! Missing } inserted.
<inserted text> 
                }
l.45 \end{align}

So maybe this is an unrelated problem (but I'd like to fix it).

@benjub
Copy link
Contributor Author

benjub commented Feb 21, 2023

That's because the \mbox command triggers text mode.
I think that latexdefs should not be that complicated anyway, see #3052 (comment) and #3054.

By the way, here is the tex file generated by my version, which is rather less that 45 lines long (edit: nevermind, I did show statement instead of show proof):

% This LaTeX file was created by Metamath on 21-Feb-2023 6:37 PM.
\documentclass{article}
\usepackage{graphicx} % For rotated iota
\usepackage{amssymb}
\usepackage{amsmath} % For \begin{align}...
\usepackage{amsthm}
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{definition}[theorem]{Definition}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{axiom}{Axiom}
\allowdisplaybreaks[1] % Allow page breaks in {align}
\usepackage[plainpages=false,pdfpagelabels]{hyperref}
\hypersetup{colorlinks} % Get rid of boxes around links
\begin{document}

\begin{theorem}\label{the:foeq1} Equality theorem for onto functions. 
(Contributed by NM, 1-Aug-1994.)
\begin{align}
\vdash ( F = G \rightarrow ( F : A
    \raisebox{.5ex}{${\textstyle{\:}_{\mbox{\footnotesize\mathrm{\
}}}}\atop{\textstyle{\longrightarrow}\atop{\textstyle{}^{\mbox{\footnotesize\mathrm{onto}}}}}$}
    B \leftrightarrow G : A \raisebox{.5ex}{${\textstyle{\:}_{\mbox{\footnotesize\mathrm{\
}}}}\atop{\textstyle{\longrightarrow}\atop{\textstyle{}^{\mbox{\footnotesize\mathrm{onto}}}}}$}
    B ) )\label{eq:foeq1}\tag{foeq1}
\end{align}
\end{theorem}
\end{document}

@benjub
Copy link
Contributor Author

benjub commented Feb 21, 2023

We should also remove \mbox: sometimes it is used in place of \mathrm, and sometimes in place of \text.
And \atop is deprecated too...
Don't worry, I'm keeping track and will open a new issue.

@benjub benjub added the LaTeX label Feb 26, 2023
@benjub
Copy link
Contributor Author

benjub commented Feb 26, 2023

Superseded by #3067.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants