在不支持 OpenType 的 LaTeX 中插入斜线零

在不支持 OpenType 的 LaTeX 中插入斜线零

标准 LaTeX 字体中是否有斜线零符号,可以使用 pdflatex 等软件访问?我浏览了一下综合符号列表,但没有发现任何东西。

在 XeLaTeX 中,我可以在支持的字体上使用 OpenType 功能+zero。例如,卡鲁纳经过书目我可以做这样的事情:

\documentclass{minimal}

\usepackage{fontspec}

\newcommand*{\defaultfontfamily}{Calluna}
\setmainfont[Mapping=tex-text]{\defaultfontfamily}
\newcommand*{\lnum}[1]{{\fontspec[RawFeature={+lnum}]{\defaultfontfamily}#1}}
\newcommand*{\zero}[1]{{\fontspec[RawFeature={+zero}]{\defaultfontfamily}#1}}
\newcommand*{\zerolnum}[1]{{\fontspec[RawFeature={+lnum,+zero}]{\defaultfontfamily}#1}}

\begin{document}
0\zero{0}\lnum{0}\zerolnum{0}
\end{document}

并得到几种不同类型的零:

Calluna 中的几个不同的零

不过,我很想找到一种在不支持 OpenType 的 LaTeX 引擎中实现此目的的方法。

PS \(\emptyset\)\(\slashed{0}\)、 之类的不算。我最感兴趣的是文本模式,但如果你有文本模式的解决方案数学模式也不错。另外,在有人说之前,\o\O是字母,而不是数字。它们也不算数!

答案1

\pmzerodot下面的例子用点 ( ) 和斜线 ( )定义了穷人版的零\pmzeroslash

备注\pmzerodot

  • \cdot用作点。通常,它被放置在数学轴上,不必位于数字零的垂直中间。因此,测量数字的高度并将点放置在中间。
  • 对于倾斜的字体,会考虑数字零的斜体校正,以便更好地水平放置点。
  • \cdot在数学模式下使用。这会使粗体文本字体产生明显差异。如果字体系列 ( \f@series) 以 开头b,则\mathversion{bold}用于点。

备注\pmzeroslash

  • 斜线垂直位于数字零的中间。
  • 使用斜线的文本版本的优点在于,符号采用与数字相同的字体。

示例文件:

\documentclass{article}

\makeatletter
\newcommand*{\pmzerodot}{%
  \nfss@text{%
    \sbox0{$\vcenter{}$}% math axis
    \sbox2{0}%
    \sbox4{0\/}%
    \ooalign{%
      0\cr
      \hidewidth
      \kern\dimexpr\wd4-\wd2\relax % compensate for slanted fonts
      \raise\dimexpr(\ht2-\dp2)/2-\ht0\relax\hbox{%
        \if b\expandafter\@car\f@series\@nil\relax
          \mathversion{bold}%
        \fi
        $\cdot\m@th$%
      }%
      \hidewidth
      \cr
      \vphantom{0}% correct depth of final symbol
    }%
  }%
}
\newcommand*{\pmzeroslash}{%
  \nfss@text{%
    \sbox0{0}%
    \sbox2{/}%
    \sbox4{%
      \raise\dimexpr((\ht0-\dp0)-(\ht2-\dp2))/2\relax\copy2 %
    }%
    \ooalign{%
      \hfill\copy4 \hfill\cr
      \hfill0\hfill\cr
    }%
    \vphantom{0\copy4 }% correct overall height and depth of the symbol
  }%
}
\makeatother

\usepackage{amstext}% for resizing the symbol in math

\begin{document}

  \newcommand*{\teststring}{0\pmzerodot\pmzeroslash}

  \teststring

  % check symbol bounding boxes
  \setlength{\fboxsep}{0pt} 
  \setlength{\fboxrule}{.1pt}
  \fbox{0}\fbox{\pmzerodot}\fbox{\pmzeroslash}

  % test different fonts

  \textsf{\teststring}

  \texttt{\teststring}

  \textbf{\teststring}

  \textit{\teststring}

  % math test
  $\teststring^{\teststring^{\teststring}}$

\end{document}

结果

评论:

  • 符号被包裹在 中\nfss@text。它由 LaTeX 内核定义为\mbox组内。包amstext(由 加载amsmath)将其重新定义为\text允许符号在数学模式下自动调整大小。

  • \ooalign仅保留第一行的高度和最后一行的深度。\vphantom插入以获得符号的正确的整体高度和深度。

  • \m@th\mathsurround如果使用的话,避免额外的水平间距。

  • 数学轴的高度可通过空的高度获得\vcenter{}

答案2

stackengine包允许您叠加字形。它在数学模式和文本模式下均可工作。

\documentclass{article}
\usepackage{stackengine}[2013-09-11]
\newcommand\slashzero{\stackinset{c}{}{c}{}{/}{0}}
\begin{document}
In text mode \slashzero\ and in math mode: \( A = \slashzero \)
\end{document}

在此处输入图片描述

答案3

这不是一个完整的答案,但这是我所知道的唯一包含图片的方法。

这个斜线零存在于 lucida grande 中;图片是从文章中裁剪出来的“哦,哦,零!“由 chuck bigelow 撰写,发表于最新一期的 tugboat 杂志(34:2,第 168-181 页);此字形作为示例出现在第 168 页和第 171 页。(本文目前仅供拖船成员访问,但应于 2014 年 9 月全面开放。)

从 lucida grande 字体中删除零

答案4

我制作的一些字体包包含一个命令,允许访问斜线零(如果可用)。例如对于拉丁现代字体:

\documentclass{article}
\usepackage{cfr-lm}
\begin{document}
    0123456789\zeroslash

    \tostyle
    0123456789\zeroslash

    \plstyle
    0123456789\zeroslash

    \tlstyle
    0123456789\zeroslash

    \bfseries
    0123456789\zeroslash

    \tostyle
    0123456789\zeroslash

    \plstyle
    0123456789\zeroslash

    \tlstyle
    0123456789\zeroslash

    \mdseries\sffamily
    0123456789\zeroslash

    \tostyle
    0123456789\zeroslash

    \plstyle
    0123456789\zeroslash

    \tlstyle
    0123456789\zeroslash

    \bfseries
    0123456789\zeroslash

    \tostyle
    0123456789\zeroslash

    \plstyle
    0123456789\zeroslash

    \tlstyle
    0123456789\zeroslash
\end{document}

berenisadf 还提供斜线零。

一般来说,我的软件包应该能够访问字体中可用的变体零。(我不会试图伪造这一点,因此可用性完全取决于字体包含的内容。)

相关内容