乳胶逐字显示:使用后备字体显示字符吗? [英] Latex verbatim: show characters using a fallback font?

查看:112
本文介绍了乳胶逐字显示:使用后备字体显示字符吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在逐字块上使用特定的monofont.在我的逐字记录块中,某些字符未包含在字体中.如这篇文章中所建议的那样,可以使用其他字体,也可以使用pmboxdraw包呈现不支持的字符.但是,这似乎对我不起作用.

I use a specific monofont for verbatim blocks. In one of my verbatim block, some characters are not included in the font. As suggested in this post, one can use either a different font, or use pmboxdraw package to render the un-supported characters. But it seems that it does not work for me.

以下是MWE,其中黑色圆圈(即第二行的第一个字符)无法正确绘制.我的意图是使用我在逐字记录块中使用的monofont,并为黑圈字符使用任何替代字体.有解决方案吗?非常感谢!

The following is a MWE, in which the black circle (i.e., 1st character of the second line) can not be drawn correctly. My intention is that to use the monofont I used for the verbatim block, and use whatever substitute font for the black circle character. Is there a solution for that? Thanks a lot!

\documentclass{article}
\usepackage{fancyvrb}

\usepackage[utf8]{inputenc}
\usepackage{pmboxdraw}

\usepackage{fontspec}
\setmonofont[Path=./fonts/PragmataPro/,
    UprightFont=*-R,
    ItalicFont=*-RI,
    BoldFont=*-B,
    BoldItalicFont=*-BI]{PragmataPro}

\begin{document}
\begin{Verbatim}
$ systemctl status redsocks
● redsocks.service - Redsocks transparent SOCKS proxy redirector
   Loaded: loaded (/lib/systemd/system/redsocks.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2019-10-28 16:14:16 CST; 5s ago
  Process: 1499 ExecStart=/usr/sbin/redsocks -c ${CONFFILE} (code=exited, status=0/SUCCESS)
  Process: 1496 ExecStartPre=/usr/sbin/redsocks -t -c ${CONFFILE} (code=exited, status=0/SUCCESS)
\end{Verbatim}
\end{document}

使用xelatex的输出显示黑圈显示不正确:

The output using xelatex shows that the black circle is rendered incorrectly:

顺便说一句,如果我不指定自定义的单字体,则根本不会绘制黑色圆圈.

Btw, if I don't specify the customized monofont, the black circle will not be drawn at all.

推荐答案

您可以使用newunicodechar包替换单个符号.您只需要找到包含该字符的字体即可,例如 https://www.fileformat.info/info/unicode/char/25cf/fontsupport.htm

You can replace individual symbols with the newunicodechar package. You just need to find a font that contains the character, see e.g. https://www.fileformat.info/info/unicode/char/25cf/fontsupport.htm

% !TeX TS-program = xelatex

\documentclass{article}
\usepackage{fancyvrb}

\usepackage[utf8]{inputenc}
\usepackage{newunicodechar}

\usepackage{fontspec}
\setmonofont{Monaco}

\newfontfamily{\dejamono}{DejaVu Sans Mono}

\newunicodechar{●}{{\dejamono ●}}

\begin{document}
\begin{Verbatim}
$ systemctl status redsocks
● redsocks.service - Redsocks transparent SOCKS proxy redirector
   Loaded: loaded (/lib/systemd/system/redsocks.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2019-10-28 16:14:16 CST; 5s ago
  Process: 1499 ExecStart=/usr/sbin/redsocks -c ${CONFFILE} (code=exited, status=0/SUCCESS)
  Process: 1496 ExecStartPre=/usr/sbin/redsocks -t -c ${CONFFILE} (code=exited, status=0/SUCCESS)
\end{Verbatim}
\end{document}

(我在上面的示例中使用的是Monaco字体,因为该字体也缺少符号,并且我没有专有的PragmataPro字体)

(I'm using Monaco font for the example above, because this font also lacks the symbol and I don't have the proprietary PragmataPro font)

这篇关于乳胶逐字显示:使用后备字体显示字符吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆