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
Comments
P.S. Warnings are emitted when running with pdflatex. With lualatex and xelatex, no warnings, and the expected typewriter <> are typeset. |
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 |
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. |
Sure, I am well aware that cmr doesn't have ASCII <>.
But we're talking about cmtt*, which isn't in the OT1 encoding.
Oh well, whatever. Life goes on. --thanks, karl.
|
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 |
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
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. |
Sorry to be a pest, but this problem is, in my experience, widespread.
I'm sure thousands of backslashes, braces, etc., have been incorrectly
typeset in roman instead of typewriter, and people just don't notice
(and/or care), since it feels so natural to write
\texttt{\textbackslash} and expect a typewriter backslash.
So ... maybe \textbackaslash etc. could also have fontdimen-based
special cases? AFAIK \ifdim\fontdimen3 > 0pt (outside math mode) can be
used to detect a typewriter font successfully enough. Something like:
```
\ifdim\fontdimen3 > 0pt
$\backslash$% not typewriter, so use math backslash
\else
\char92 % typewriter, use ASCII backslash
\fi
```
Probably doesn't fly, but just had to try one more time ... --best, karl.
|
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. |
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 ... |
***@***.***
\ifdim ***@***.***\font >\z@
Given this precedent, maybe the same sort of thing could be done for
<>\{} (and whatever else)? We can check for monospace fonts with a zero
\fontdimen3 (as far as I've seen, anyway). Something like:
***@***.***
\ifdim \fontdimen3\font >\z@
% do the switch to OML
\else
\char`\<
\fi
\egroup
}
But maybe it doesn't work. I realize it's not completely analogous to
the dollar/pounds case. Just thought I'd throw it out there.
I'm being a pest about it because I often see (e.g., in TUB articles)
\textless/textgreater/textbackslash/etc. being used nowadays in tt
contexts, and they don't come out right, even though the characters are
present in the tt font.
I'll try switching to T1 in the future but my feeling is that switching
encodings will sometimes induce other problems. Anyway, it would be
nicer if a default LaTeX document typeset \texttt{\textless} correctly. -k
|
I understand. Thanks for all the info.
|
Input:
Output:
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.
The text was updated successfully, but these errors were encountered: