如何在 algorithm2e 包中将注释标记设为长划线?

如何在 algorithm2e 包中将注释标记设为长划线?

评论有些奇怪algorithm2e。我想让评论的左侧标记变成长划线。类似于 \textemdash。我按照这里给出的答案操作如何在 algorithm2e 中使用 algorithmx 注释符号但我不想像上面的链接那样使用三角形标记,而是想使用---。但我无法让它工作。(实际上,上面答案中的示例在 TL 2016 上无法编译)。

Mathematica 图形

当我尝试时\SetKwComment{comment}{\textemdash}{},我没有得到我期望的结果。我得到了其他东西。MWE

\documentclass{article}
\usepackage[linesnumbered]{algorithm2e}

%now set comment left marker
\SetKwComment{comment}{\textemdash}{}
\begin{document}

This \textemdash\ is a test.

\begin{algorithm}[H]
  \DontPrintSemicolon
  \SetAlgoLined
  \eIf{true}
  {
     $x=1$ \comment*{Some comment}
  }
  {
     $x=0$
  }
\end{algorithm}
\end{document}

现在

lualatex foo2.tex
This is LuaTeX, Version 0.95.0 (TeX Live 2016) 
 restricted system commands enabled.
(./foo2.tex
LaTeX2e <2016/03/31> patch level 2
Babel <3.9r> and hyphenation patterns for 1 language(s) loaded.
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2016/texmf-dist/tex/latex/algorithm2e/algorithm2e.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/ifthen.sty)
(/usr/local/texlive/2016/texmf-dist/tex/latex/tools/xspace.sty)
(/usr/local/texlive/2016/texmf-dist/tex/latex/relsize/relsize.sty)
********************************************************
Package `algorithm2e' Release 5.1 -- october 19 2015 --
- [email protected] mailing list for announcement about releases
- [email protected] mailing list for discussion about package
subscribe by emailing [email protected] with 'subscribe <list> <firstname name>'
- Author: Christophe Fiorio ([email protected])
********************************************************
) (./foo2.aux) [1{/usr/local/texlive/2016/texmf-var/fonts/map/pdftex/updmap/pdf
tex.map}] (./foo2.aux))
(\end occurred inside a group at level 1)

### simple group (level 1) entered at line 1061 ({)
### bottom level
 631 words of node memory still in use:
   3 hlist, 1 vlist, 2 rule, 31 glue, 59 glue_spec, 1 write nodes
   avail lists: 2:21,3:10,4:4,5:26,6:61,7:71,8:14,9:47,10:3
</usr/local/texlive/2016/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx10.pfb><
/usr/local/texlive/2016/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx7.pfb></u
sr/local/texlive/2016/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi10.pfb></us
r/local/texlive/2016/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb></usr/
local/texlive/2016/texmf-dist/fonts/type1/public/amsfonts/cm/cmti10.pfb></usr/l
ocal/texlive/2016/texmf-dist/fonts/type1/public/amsfonts/cm/cmtt10.pfb>
Output written on foo2.pdf (1 page, 54390 bytes).
Transcript written on foo2.log.

给出

Mathematica 图形

我做错了什么。如何获取---左侧评论标记?如果我直接写,\SetKwComment{comment}{---}{}我会得到以下结果:

Mathematica 图形

而且它们并不相同。我想要看起来实心的破折号,就像上面的第一行一样。

2016 年

答案1

我的主要问题可能是等宽字体(注释似乎是用等宽字体排版的)没有破折号。

一个简单的补救措施可能是使用文档字体中的字体\textnormal{\textemdash}或类似字体。

相关内容