# How to import the \hookrightarrow from STIX?

In a comment on https://tex.stackexchange.com/a/499227/298 @egreg said, that I could import the good looking \hookrightarrow from STIX. I found this How to import the summation symbol from the "STIX" font and tried to apply it in my use case. I got this far:

\documentclass[usenames,article,oneside]{memoir}
\usepackage{fontspec}
\usepackage[lining]{ebgaramond}
\usepackage[cmintegrals,cmbraces]{newtxmath}
\usepackage{ebgaramond-maths}
\usepackage{amssymb}
\usepackage{listings}
\usepackage{color}

\makeatletter
\DeclareFontEncoding{LS2}{}{\noaccents@}
\makeatother

\DeclareFontSubstitution{LS2}{stix}{m}{n}
\DeclareSymbolFont{xlargesymbols}{LS2}{stixex}{m}{n}
\DeclareMathSymbol{\nicearrow}{\mathop}{RelationsSTIX}{U+21AA}

\lstset{ language=R,
basicstyle=\footnotesize\ttfamily,
frame=single,
breaklines=true,
postbreak=\mbox{\textcolor{red}{$\nicearrrow$}\space},
showstringspaces=false
}
\begin{document}
\noindent In this example I want to use the nice looking \texttt{\textbackslash hookrightarrow} from STIX fonts.
\begin{lstlisting}
> install.packages("devtools")
trying URL 'http://cran.rstudio.com/bin/macosx/contrib/3.0/devtools_1.6.1.tgz'
[...]
The downloaded binary packages are in
/var/folders/6s/skl7sm9511g6_cw844vldx540000gp/T//RtmpUbrziM/downloaded_packages
\end{lstlisting}

\end{document}


But I must admit, that I don't understand, what is going on with the \DeclareMathSymbol{\sumop}{\mathop}{xlargesymbols}{"B3} part nor how I should do it in my case. What is "B3 and what is the name of the font I should use?

Please explain, how I can find this out as well, so it is easier when trying to do this for yet another symbol in the future.

## 1 Answer

Look into the stix.sty file for \hookrightarrow. You will find

\stix@MathSymbol{\hookrightarrow}           {\mathrel}{arrows1}{"B1}


Good, the symbol belongs to the arrows1 math group. Let's look for it:

\DeclareSymbolFont{arrows1}       {LS1}{stixsf}   {m} {n}


OK, we need the LS1 encoding; we find its first occurrence

\DeclareFontEncoding{LS1}{}{}
\DeclareFontEncoding{LS2}{}{\noaccents@}
\DeclareFontSubstitution{LS1}{stix}{m}{n}
\DeclareFontSubstitution{LS2}{stix}{m}{n}


We don't need the parts pertaining to LS2. Change \stix@MathSymbol into \DeclareMathSymbol and you're done. You might want to change arrows1 into another name.

\documentclass[usenames,article,oneside]{memoir}
\usepackage{fontspec}
\usepackage[lining]{ebgaramond}
\usepackage[cmintegrals,cmbraces]{newtxmath}
\usepackage{ebgaramond-maths}
\usepackage{amssymb}
\usepackage{listings}
\usepackage{color}

\DeclareFontEncoding{LS1}{}{}
\DeclareFontSubstitution{LS1}{stix}{m}{n}
\DeclareSymbolFont{arrows1}{LS1}{stixsf}{m}{n}
\DeclareMathSymbol{\nicearrow}{\mathrel}{arrows1}{"B1}

\lstset{ language=R,
basicstyle=\footnotesize\ttfamily,
frame=single,
breaklines=true,
postbreak=\mbox{\textcolor{red}{$\nicearrow$}\space},
showstringspaces=false
}

\begin{document}

\noindent In this example I want to use the nice looking \texttt{\textbackslash hookrightarrow} from STIX fonts.
\begin{lstlisting}
> install.packages("devtools")
trying URL 'http://cran.rstudio.com/bin/macosx/contrib/3.0/devtools_1.6.1.tgz'
[...]
The downloaded binary packages are in
/var/folders/6s/skl7sm9511g6_cw844vldx540000gp/T//RtmpUbrziM/downloaded_packages
\end{lstlisting}

\end{document}


If you don't plan to use the arrow in math mode, but just for listings, you don't need to set up symbol fonts.

\documentclass[usenames,article,oneside]{memoir}
\usepackage{fontspec}
\usepackage[lining]{ebgaramond}
\usepackage[cmintegrals,cmbraces]{newtxmath}
\usepackage{ebgaramond-maths}
\usepackage{amssymb}
\usepackage{listings}
\usepackage{color}

\newfontface{\stixsymbols}{STIX Two Math}
\newcommand{\nicearrow}{{\normalfont\stixsymbols\symbol{"21AA}}}

\lstset{ language=R,
basicstyle=\footnotesize\ttfamily,
frame=single,
breaklines=true,
postbreak=\mbox{\textcolor{red}{\nicearrow}\space},
showstringspaces=false
}

\begin{document}

\noindent In this example I want to use the nice looking \texttt{\textbackslash hookrightarrow} from STIX fonts.
\begin{lstlisting}
> install.packages("devtools")
trying URL 'http://cran.rstudio.com/bin/macosx/contrib/3.0/devtools_1.6.1.tgz'
[...]
The downloaded binary packages are in
/var/folders/6s/skl7sm9511g6_cw844vldx540000gp/T//RtmpUbrziM/downloaded_packages
\end{lstlisting}

\end{document}