如何从 STIX 导入“\hookrightarrow”?

如何从 STIX 导入“\hookrightarrow”?

在评论中https://tex.stackexchange.com/a/499227/298@egreg 说,我可以从 STIX 导入好看的\hookrightarrow。我发现这个如何从“STIX”字体导入求和符号并尝试将其应用于我的用例。我到目前为止:

\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}

但我必须承认,我不明白这部分发生了什么,\DeclareMathSymbol{\sumop}{\mathop}{xlargesymbols}{"B3}也不明白在我的情况下我应该怎么做。"B3我应该使用什么字体?字体名称是什么?

请解释一下,我如何才能找到这一点,以便将来尝试对另一个符号执行此操作时更容易。

答案1

查看stix.sty文件\hookrightarrow。您将发现

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

很好,这个符号属于arrows1数学组。我们来找找它:

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

好的,我们需要 LS1 编码;我们找到它的第一次出现

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

我们不需要与 LS2 相关的部分。改成\stix@MathSymbol\DeclareMathSymbol完成了。您可能想改成arrows1其他名称。

\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}

在此处输入图片描述

如果您不打算在数学模式中使用箭头,而只是用于列表,则无需设置符号字体。

\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}

相关内容