答案1
无包装方法:
\documentclass{article}
\setlength{\unitlength}{1em}
\newcommand\like[1]{\begin{picture}(1,1)
\ifnum0=#1\put(.5,.35){\circle{1}}\else
\ifnum10=#1\put(.5,.35){\circle*{1}}\else
\put(.5,.35){\circle{1}}\put(.5,.35){\circle*{.#1}}
\fi\fi\end{picture}}
\begin{document}
I hate it \like{0} \like{1} \like{2} \like{3} \like{4} \like{5}
\like{6} \like{7} \like{8} \like{9} \like{10} I love it
\end{document}
答案2
这个怎么样:
该命令\satisfaction
接受一个参数,该参数必须是 0 到 4 之间的数字。使用可选参数可以设置颜色。它会随字体大小缩放。如果没有可选参数,它会采用周围的颜色。
代码:
\documentclass[10pt,a4paper]{article}
\usepackage{tikz}
\newdimen\satlevel
\newdimen\satdiameter
\newcommand{\satisfaction}[2][]{%
\satdiameter=2.5ex\relax
\ifcase#2\relax
\satlevel=0pt\relax
\or
\satlevel=0.125\satdiameter
\or
\satlevel=0.25\satdiameter
\or
\satlevel=0.375\satdiameter
\or
\satlevel=0.5\satdiameter
\fi
\tikz[baseline=-0.3\satdiameter]{%
\draw[#1] (0,0) circle (0.5\satdiameter);
\fill[#1] (0,0) circle (\satlevel);
}%
}
\begin{document}
M \satisfaction{0} M \satisfaction{1} M \satisfaction{2} M \satisfaction{3} M \satisfaction{4} M
\vspace{2ex}
M \satisfaction[blue]{0} M \satisfaction[blue]{1} M \satisfaction[blue]{2} M \satisfaction[blue]{3} M \satisfaction[blue]{4} M
\vspace{2ex}
{\Huge M \satisfaction[red]{0} M \satisfaction[red]{1} M \satisfaction[red]{2} M \satisfaction[red]{3} M \satisfaction[red]{4} M}
\vspace{2ex}
{\scriptsize M \satisfaction[cyan]{0} M \satisfaction[cyan]{1} M \satisfaction[cyan]{2} M \satisfaction[cyan]{3} M \satisfaction[cyan]{4} M}
\vspace{2ex}
\textcolor{green}{M \satisfaction{0} M \satisfaction{1} M \satisfaction{2} M \satisfaction{3} M \satisfaction{4} M}
\end{document}
答案3
解决方案 pstricks
。我定义了 5 个命令,它们带有一个可选参数,即外圆的半径,默认值为0.75 em
。您可以通过 键更改它satradius
。颜色(默认值:黑色)的更改方式如下\psset{linecolor=some_colour}
:
\documentclass[border=3pt, x11names]{standalone}
\usepackage{pstricks-add, cellspace}
\setlength{\cellspacetoplimit}{2pt}
\setlength{\cellspacebottomlimit}{2pt}
%
\usepackage{auto-pst-pdf}
\newlength{\satradius}
\makeatletter
\define@key[psset]{pstricks}{satradius}[0.75em]{\setlength{\satradius}{#1}}
\makeatother
\newcommand{\vlsat}{\raisebox{-0.4\height}{\begin{pspicture}\pscircle(0,0){\satradius}\end{pspicture}}}
\newcommand{\lsat}{\raisebox{-0.4\height}{\begin{pspicture}\pscircle(0,0){\satradius}\psscalebox{0.3}{\qdisk(0,0){\satradius}}\end{pspicture}}}
\newcommand{\msat}{\raisebox{-0.4\height}{\begin{pspicture}\pscircle(0,0){\satradius}\psscalebox{0.5}{\qdisk(0,0){\satradius}}\end{pspicture}}}
\newcommand{\hsat}{\raisebox{-0.4\height}{\begin{pspicture}\pscircle(0,0){\satradius}\psscalebox{0.75}{\qdisk(0,0){\satradius}}\end{pspicture}}}
\newcommand{\vhsat}{\raisebox{-0.4\height}{\begin{pspicture}\qdisk(0,0){\satradius}\end{pspicture}}}
\begin{document}
\psset{linecolor=Coral2, satradius=0.67em}
\begin{tabular}{|Sc|l|}%
\hline
\vlsat & Very low \\[2pt]
\hline
\lsat
& Low \\[2pt]
\hline
\msat & Medium \\[2pt]
\hline
\hsat & High \\[2pt]
\hline
\vhsat & Very High \\[2pt]
\hline
\end{tabular}
\end{document}