我正在用 LaTeX 写简历,我想在我的技能旁边添加知识指标。我正在寻找一个可以显示“垂直堆栈”的包。类似于:
- 德语 ≡
- 英语 =
- 中国人 -
符号应与底部对齐,如果有两种颜色就更好了。因此,它始终是三条,但根据技能水平,一条、两条或三条将是第二种颜色。
答案1
只是为了好玩,使用picture
模式:
\documentclass{article}
\usepackage{xcolor}
\newcommand{\skill}[1][3]{%
\setlength{\unitlength}{1ex}%
\begin{picture}(1,1.8)
\linethickness{0.3ex}%
\textcolor{gray!15}{\multiput(0, 0.15)(0, 0.6){3}{\line(1,0){1}}}
\multiput(0, 0.15)(0, 0.6){#1}{\line(1,0){1}}
\end{picture}%
}
\begin{document}
\begin{itemize}
\item German \skill[3]
\item English \skill[2]
\item Chinese \skill[1]
\item Default \skill
\end{itemize}
Testing \skill[1], winning \skill[2], and excellence \skill[3].
\end{document}
答案2
构建于A.Ellet's answer
按要求生产某物(每组总是三个矩形;绿色矩形表示技能等级):
代码:
\documentclass{article}
\usepackage{tikz}
\definecolor{colori}{RGB}{249,193,158}
\definecolor{colorii}{RGB}{158,214,149}
\newcommand\skilllevel[1]{%%
\begin{tikzpicture}
\foreach \Val in {1,2,3}
{
\node[fill=colori,inner ysep=0pt]
at ([yshift=2*\Val]0,\Val pt) {};
}
\foreach \Val in {1,...,#1}
{
\node[fill=colorii,inner ysep=0pt]
at ([yshift=2*\Val]0,\Val pt) {};
}
\end{tikzpicture}%
}
\makeatother
\begin{document}
\noindent\begin{tabular}{lc}
German & \skilllevel{2} \\
Latin & \skilllevel{1} \\
Japanese & \skilllevel{3} \\
\end{tabular}
\end{document}
也许下面的修改不太容易让人混淆(见Andrew Cashner's comment
):
\documentclass{article}
\usepackage{tikz}
\definecolor{colori}{RGB}{249,193,158}
\definecolor{colorii}{RGB}{158,214,149}
\newcommand\skilllevel[1]{%%
\begin{tikzpicture}
\foreach \Val in {1,2,3}
{
\node[draw,fill=white,inner ysep=1pt]
at ([yshift=2*\Val]0,\Val pt) {};
}
\foreach \Val in {1,...,#1}
{
\node[draw,fill=colorii,inner ysep=1pt]
at ([yshift=2*\Val]0,\Val pt) {};
}
\end{tikzpicture}%
}
\begin{document}
\noindent\begin{tabular}{lc}
German & \skilllevel{2} \\
Latin & \skilllevel{1} \\
Japanese & \skilllevel{3} \\
\end{tabular}
\end{document}
答案3
使用堆栈。我选择将答案保持在正常行距的范围内,但可以通过调用来更改\setstackgap{L}{desired-baselineskip}
。条形厚度(1pt)和宽度(1ex)在\rl
和\rlf
定义中设置(以及颜色)。条形之间的垂直空间用设置\setstackgap{S}{1.5pt}
,单词和条形之间的间隙通过设置\setstacktabbedgap{1ex}
。
\documentclass{article}
\usepackage{tabstackengine,xcolor}
\def\rl{\textcolor{red}{\protect\rule{1ex}{1pt}}}
\def\rlf{\textcolor{red!15}{\protect\rule{1ex}{1pt}}}
\newcommand\level[1]{%
\if 1#1\stackon{\stackon{\rl}{\rlf}}{\rlf}\else
\if 2#1\stackon{\stackon{\rl}{\rl}}{\rlf}\else
\if 3#1\stackon{\stackon{\rl}{\rl}}{\rl}\else
\fi\fi\fi
}
\begin{document}
\renewcommand\stackalignment{l}
\setstackgap{S}{1.5pt}
\setstacktabbedgap{1ex}
\tabbedLongstack{German&\level{3}\\Latin&\level{2}\\Japanese&\level{1}}
\end{document}
如果对 TABstacks 不满意,可以使用普通堆栈来实现相同的效果,方法是
\Longstack{German\\Latin\\Japanese}%
\hspace{1ex}%
\Longstack{\level{3}\\\level{2}\\\level{1}}
答案4
你可以使用tikz
类似这样的方法:
\documentclass{article}
\usepackage{tikz}
\makeatletter
\newcommand\skilllevel[1]{%%
\def\ae@color{\ifcase#1\or
red\or
orange\else
blue\fi}%%
\tikz \node[draw,fill,rectangle,minimum height=#1em,\ae@color] (A) {};}
\makeatother
\begin{document}
\begin{tabular}{lc}
German & \skilllevel{2} \\
Latin & \skilllevel{1} \\
Japanese & \skilllevel{3} \\
\end{tabular}
\end{document}
这是一个类似的方法,但是带有条形图:
\documentclass{article}
\usepackage{tikz}
\makeatletter
\newcommand\skilllevel[1]{%%
\def\ae@color{\ifcase#1\or
red\or
orange\else
blue\fi}%%
\rule{0pt}{3ex}%%
\begin{tikzpicture}
\foreach \myn in {1,...,#1}
{
\typeout{==>\myn}%%
\node[fill,rectangle,inner sep=0pt,
minimum height=0.75ex,
minimum width=1em,\ae@color] (A\myn) at (0,\myn ex) {};
}
\end{tikzpicture}}
\makeatother
\begin{document}
\begin{tabular}{lc}
German & \skilllevel{2} \\
Latin & \skilllevel{1} \\
Japanese & \skilllevel{3} \\
\end{tabular}
\end{document}