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

\textless, \textgreater get font warnings in \texttt #824

Closed
kberry opened this issue May 22, 2022 · 11 comments
Closed

\textless, \textgreater get font warnings in \texttt #824

kberry opened this issue May 22, 2022 · 11 comments

Comments

@kberry
Copy link

kberry commented May 22, 2022

Input:

\documentclass{article}
\begin{document}
\texttt{\textless}
\texttt{\textgreater}
\end{document}

Output:

LaTeX Font Warning: Font shape `OML/cmtt/m/n' undefined
(Font)              using `OML/cmm/m/it' instead
(Font)              for symbol `textless' on input line 3.

LaTeX is forcing use of OML for \textless/greater even when the current font has <> characters. This seems unnecessary and undesirable, especially for commands named \text...

Besides switching to verbatim (yuck), is there a better way to typeset typewriter <>? I doubt you want to recommend \texttt{\char`<}, but that's the only way I see to do it?

Also, it seems strange that latex only warns about \textless. If that line is commented out, it then warns about \textgreater. Presumably you want to avoid a flood of warnings about the "same" thing, but ... two different commands ... anyway ...

Sorry if this is already addressed somewhere. I couldn't find it.

@kberry
Copy link
Author

kberry commented May 22, 2022

P.S. Warnings are emitted when running with pdflatex. With lualatex and xelatex, no warnings, and the expected typewriter <> are typeset.

@u-fischer
Copy link
Member

One of the various reasons why you shouldn't use OT1 encoding anymore. In OT1 encoding the cmtt contains < and > but .g. cmr has there ¡ and ¿. So LaTeX uses OML encoding for the two symbols. https://tex.stackexchange.com/questions/222448/

With \usepackage[T1]{fontenc} it works fine.

@FrankMittelbach
Copy link
Member

We would love to make T1 the default but in contrast to switching to utf8 this has more noticeable consequences, so for backwards compatibility this is not done automatically.

So it works as designed if Don's 7bit encodings are used.

@kberry
Copy link
Author

kberry commented May 23, 2022 via email

@davidcarlisle
Copy link
Member

which isn't in the OT1 encoding.

Well that's the thing, the decision (pre latex2e) was that tt would be declared as being in OT1 so that font commands such as \bfseries or \rmfamily that don't change the encoding axis do the right thing if starting in tt. verbatim special cases <_> so they come from the font but back then changing every font command to check for this would have taken more space than we had, and now it's been doing this for 30 years so can't really stop.

@FrankMittelbach
Copy link
Member

Sure, I am well aware that cmr doesn't have ASCII <>. But we're talking about cmtt*, which isn't in the OT1 encoding.

when NFSS was developed we had to abstract from the special font encodings that Don invented and normalized them (e.g., that a $ changes to a pound if you select cmti etc, the same happend for cmtt. The NFSS base assumption is that all fonts use the same fontencoding (in fact the first versions of NFSS didn't even have an encoding axis. So as far as NFSS is concerned all CM fonts are in OT1 and the internal specialities have been handled "manually" e.g., the definition for \textdollar does different things by looking at the slant of a font and goes:

\DeclareTextCommand{\textdollar}{OT1}{\hmode@bgroup
   \ifdim \fontdimen\@ne\font >\z@
      \slshape
   \else
      \upshape
   \fi
   \char`\$\egroup}

to account for the differences between fonts.

So as far as NFSS is concerned cmtt is in OT1 encoding (and OT1 doesn't contain those characters)

Using different font encodings instead would mean that you couldn't change font attributes without (sometimes) also having to change the encoding first (and then changing it back at some point later) which would be a huge mess either on the user interface or internally with introducing a lot of lookup tables and rules without any gain other than getting a few characters in CM fonts right that aren't available in all CM fonts.

@kberry
Copy link
Author

kberry commented Aug 13, 2022 via email

@FrankMittelbach
Copy link
Member

I don't know if it flies Karl, but it would change a lot of old documents. If that is acceptable then a better approach would be to finally drop OT1 as a default and instead use T1 and perhaps LM as the default family as it is already the case with the Unicode engines.

@kberry
Copy link
Author

kberry commented Aug 16, 2022

i guess you're right, it's too much of a change. even tough i tend to believe that documents would only be changed in the way that users intended in the first place, but no matter ...

@kberry
Copy link
Author

kberry commented Oct 11, 2022 via email

@kberry
Copy link
Author

kberry commented Oct 11, 2022 via email

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

No branches or pull requests

4 participants