在许多文章中,特别是中文文章中,我们会见到带有圆圈的数字。它们有点是单独出现的,有点作为列表的计数出现。 LaTeX 提供了 \textcircled 命令,但效果并不好LaTeX studio 曾经提供了一个方法,但缺乏通用性。 这里给出一个利用 TikZ 绘制的方法,能较好地解决这个问题,但仍需完善。 基本的思路是定义一个新命令,接受一个数字参数,用 TikZ 在它周围画圈。同时要考虑基线和对齐的问题。一个尝试如下:
\usepackage{tikz}
\newcommand*{\circled}[1]{\lower.7ex\hbox{\tikz\draw (0pt, 0pt)%
    circle (.5em) node {\makebox[1em][c]{\small #1}};}}
这个新定义的命令可以按照 \textcircled 方法在正文中使用,如果需要用在列表中,则因为「脆弱命令」的问题,需要处理一下。这里我们选择使用 etoolbox 宏包提供的 \robustify 来处理一下,同时结合 enumitem 宏包,给出示例用法如下:
\documentclass{article}
\usepackage{tikz}
\usepackage{etoolbox}
\usepackage{enumitem}
\newcommand*{\circled}[1]{\lower.7ex\hbox{\tikz\draw (0pt, 0pt)%
    circle (.5em) node {\makebox[1em][c]{\small #1}};}}
\robustify{\circled}
\begin{document}
\mbox{}\rlap{\rule{.7\linewidth}{.4pt}}%
This is the circled number \circled{20}.

\begin{enumerate}[label=\circled{\arabic*}]
\item I
\item am
\item happy
\item to
\item join
\item with
\item you
\item today
\item in
\item what
\item will
\item go
\item down
\item in
\item history
\item as
\item the
\item greatest
\item demonstration
\item for
\item freedom
\item in
\item the
\item history
\item of
\item our
\item nation.
\end{enumerate}
\end{document}
效果图:
textcirclednumber20140508231427
选自:http://liam0205.me/2014/05/08/latex-circled-numbers/

点赞(6)

评论列表 共有 1 条评论

远方不远 8月前 回复TA

输入两位数字时,十位数字和个位数字之间的间距有点大啊,比如77,十位的7的起笔点和个位的7的折点都挤到圈上了——强迫症犯了,抱歉——还是不完美啊~

立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部