6

How can I insert a Latin Capital Letter D With Hook into a LaTeX formula?

Ɗ

lockstep
  • 250,273
adam
  • 63

1 Answers1

7

You can adapt this answer using the T4 encoding

\documentclass{article}

\pdfpkresolution=1200
\pdfpkmode{ljfzzz}

\usepackage[T4,T1]{fontenc}

\makeatletter
\def\easytfoursymbol#1{\mathord{\mathchoice
  {\mbox{\fontsize\tf@size\z@\usefont{T4}{\rmdefault}{m}{it}\char#1}}
  {\mbox{\fontsize\tf@size\z@\usefont{T4}{\rmdefault}{m}{it}\char#1}}
  {\mbox{\fontsize\sf@size\z@\usefont{T4}{\rmdefault}{m}{it}\char#1}}
  {\mbox{\fontsize\ssf@size\z@\usefont{T4}{\rmdefault}{m}{it}\char#1}}
}}
\makeatother

\newcommand{\hookD}{\easytfoursymbol{129}}

\begin{document}
$\hookD\ne D\quad \hookD_{\hookD_{\hookD}}$
\end{document}

enter image description here

You can create a table of the T4 encoding by typesetting the following document:

\documentclass{article}
\usepackage[T4]{fontenc}
\usepackage{fonttable}
\begin{document}
\xfonttable{T4}{cmr}{m}{n}
\end{document}

This is how I found the magic number 129.

Unfortunately, T4 fonts for the Computer Modern family (FC fonts) don't have a Type1 version and this is the reason of the lines \pdfpkresolution and \pdfpkmode: creating bitmaps at high resolution.


Here's a solution for XeLaTeX (assuming that the main font has the glyph and that a matching math font exists). Also unicode-math could be used, of course.

\documentclass{article}
\usepackage{newtxmath}
\usepackage{fontspec}
\setmainfont{Times New Roman}
\usepackage{newunicodechar}
\makeatletter
\newunicodechar{Ɗ}{%
  \ifmmode
    \mathord{\mathchoice
      {\mbox{\fontsize\tf@size\z@\normalfont\itshape Ɗ}}
      {\mbox{\fontsize\tf@size\z@\normalfont\itshape Ɗ}}
      {\mbox{\fontsize\sf@size\z@\normalfont\itshape Ɗ}}
      {\mbox{\fontsize\ssf@size\z@\normalfont\itshape Ɗ}}
    }%
  \else
    Ɗ%
  \fi}
\makeatother

\begin{document}
Ɗ

$Ɗ\ne D$
\end{document}

enter image description here

egreg
  • 1,121,712