latex3 / mathtools

Mathematical tools to use with amsmath
LaTeX Project Public License v1.3c
57 stars 7 forks source link

Underscore is typeset as overdot in empheq doc #61

Closed muzimuzhi closed 2 months ago

muzimuzhi commented 2 months ago

image https://github.com/latex3/mathtools/blob/8296a5e37d719ff6e7d298013b285d6f91e1e1b7/empheq.dtx#L443-L447

Found when checking the recent commit https://github.com/latex3/mathtools/commit/8296a5e37d719ff6e7d298013b285d6f91e1e1b7. Several \marg{env_name} are affected.

It seems adding \usepackage[T1]{fontenc} works, since the glyph for character "57 (_) in OT1 font encoding is overdot, but underscore in OT1. I didn't check if T1 would cause new problems in the package doc.

muzimuzhi commented 2 months ago
\documentclass{ltxdoc}
%\usepackage{mathpazo}
%\usepackage[overload]{empheq}
%\usepackage{xcolor,varioref,booktabs,fancybox}
%\usepackage[overload]{textcase}

\usepackage[T1]{fontenc}

%% excerpted from empheq.dtx
\makeatletter
\expandafter\def\expandafter\MakePrivateLetters\expandafter{%
  \MakePrivateLetters  \catcode`\_=11\relax
}

\def\MTmeta#1{%
     \ensuremath\langle
     \ifmmode \expandafter \nfss@text \fi
     {%
      \meta@font@select
      \edef\meta@hyphen@restore
        {\hyphenchar\the\font\the\hyphenchar\font}%
      \hyphenchar\font\m@ne
      \language\l@nohyphenation
      #1\/%
      \meta@hyphen@restore
     }\ensuremath\rangle
     \endgroup
}
\makeatother

\DeclareRobustCommand\meta{\begingroup\MakePrivateLetters\MTmeta}
\def\MHmarg#1{{\ttfamily\char`\{}\meta{#1}{\ttfamily\char`\}}\endgroup}
\DeclareRobustCommand\marg{\begingroup\MakePrivateLetters\MHmarg}

\begin{document}
OT1: \fontencoding{OT1}\selectfont
\marg{env_name}
\marg{env\UseName{_}name} % force use of \_

T1: \fontencoding{T1}\selectfont
\marg{env_name}
\marg{env\UseName{_}name} % force use of \_
\end{document}

image

daleif commented 2 months ago

I would just add fontenc (I would have thought it was there already) as I always udf pdflatex to compile the manual. I'll add it in a \iftutex\else ,,, \fi clause just in case.

daleif commented 2 months ago

Should be fixed in 31ef461