35

I was wondering if it is possible to replace just the mathmode i from the default latex font with nearly the same letter, but where the dot on the i is a small heart. For example:

enter image description here

Thank you!

4
  • 8
    Is Valentine's day approaching again? Time flies ...
    – gernot
    Apr 22 at 9:59
  • 3
    @gernot Check out the Visigothic O on p. 29 of typofonts.com/LATIN_PALEOGRAPHY.pdf
    – Thérèse
    Apr 22 at 16:16
  • @gernot But with os rather than is?
    – cfr
    Apr 23 at 0:14
  • @cfr Yes, sure. Different time, different culture, different letter. 500 years from now it will be the letter M, as most scientists agree.
    – gernot
    Apr 23 at 7:46

3 Answers 3

31

Why not also j?

\documentclass{article}
\usepackage{amsmath}
\usepackage{l3draw}

\makeatletter
\NewDocumentCommand{\iheart}{}{\mathord{\mathpalette\iheart@{\imath{7}{1}}}}
\NewDocumentCommand{\jheart}{}{\mathord{\mathpalette\iheart@{\jmath{12}{2}}}}
\newcommand{\iheart@}[2]{\iheart@@#1#2}
\newcommand{\iheart@@}[4]{%
  \vbox{\m@th\offinterlineskip
    \sbox\z@{$\mkern1mu$}%
    \ialign{##\cr\hidewidth\smallheart@{#1}{#3}\hidewidth\cr\noalign{\kern\wd\z@}\cr$#1#2$\cr}%
  }%
  \mkern#4mu
}

\ExplSyntaxOn
\cs_new_protected:Npn \smallheart@ #1 #2
 {
  \draw_begin:
  \draw_transform_matrix_absolute:nnnn { 0.4 } { 0 } { 0.2 } { 0.3 }
  \draw_path_moveto:n { 0cm, 0cm }
  \hbox_set:Nn \l_tmpa_box { \boldmath$#1\mkern#2mu\heartsuit$ }
  \draw_box_use:N \l_tmpa_box
  \draw_end:
 }
\ExplSyntaxOff
\makeatother

\begin{document}

$2\pi\iheart_{\jheart}+\jheart$

\end{document}

enter image description here

How do the macros work? First off, some mathpalette trickery to have four arguments:

  1. the current math style, as usual
  2. the letter to be typeset, so either \imath and \jmath
  3. the (math) kern in front of the heart
  4. the math kern after the combination, to compense for the protrusion of the heart which is not taken into account because of \hidewidth

I make a \vbox with \ialign inside it that oversets the heart to the letter.

Finally, the heart is a bold \heartsuit in the suitable math style subject to an affine transformation that applies reduction and shearing.

Maybe some more experiments are needed for the various parameters.

1
  • 5
    Thanks! I was going to ask for j as well, but I wasn't sure if that would be too much of a hassle! You're a tex wizard!
    – Infimum
    Apr 22 at 19:41
33

enter image description here

\documentclass{article}
\begin{document}
$2\pi{\mathop{{}\imath}\limits^{\scriptscriptstyle\heartsuit}}$
\end{document}
11

mwe

\documentclass{article}
\usepackage{amsmath,graphicx}
\newcommand\iheart[1][\imath]{%
#1\kern-.2em\rlap{%
\raisebox{1.2ex}[0pt][0pt]{%
\rotatebox{-15}{%
\resizebox{.5ex}{.5ex}{\ensuremath{\heartsuit}}}}}\kern.2em} 
\begin{document}
\Huge  \[ 2\pi ii\iheart ii  =  2\pi\iheart[\jmath] \]
\end{document}
4
  • I get quite a lot of errors with this code. You are missing the $ in the argument of \resizebox.
    – campa
    Apr 23 at 9:12
  • 1
    @campa. Oh, sorry, yes, it fail miserably with pdlatex and xelatex for this reason, but it works as is with lualatex (bug or feature? haha).
    – Fran
    Apr 23 at 9:23
  • Added \ensuremath for engine compatibility
    – Fran
    Apr 23 at 9:33
  • Oh, didn't think of trying with luatex. Interesting...
    – campa
    Apr 23 at 10:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .