我正在写简历。让我们考虑以下 MWE:
\documentclass[11 pt,oneside,a4paper,titlepage]{article}
\usepackage{multicol}
% advanced drawing
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usepackage{smartdiagram}
\usepackage{float}
\usepackage{array}
\usetikzlibrary{decorations.text}
\usetikzlibrary{fadings}
\usetikzlibrary{calc}
\usetikzlibrary{shapes.misc,positioning}
\usetikzlibrary{arrows}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{backgrounds}
\usetikzlibrary{shadings}
\usetikzlibrary{calendar}
\usetikzlibrary{er}
\usetikzlibrary{patterns}
\usetikzlibrary{shapes}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{decorations}
\usetikzlibrary{topaths}
\usepackage{graphicx}
% Skill bar
\newcommand\skillbar[1]{
\begin{tikzpicture}
\foreach [count=\i] \x/\y in {#1}{
\draw[fill=black!30,black!30] (0,\i) rectangle (2,\i+0.15);
\draw[fill=white,black](0,\i) rectangle (\y,\i+0.15);
\node[above right] at (0,\i+0.2) {\x};
}
\end{tikzpicture}
}
\begin{document}
% Programming Languages
\section*{PROGRAMMING LANGUAGES}
\vspace*{-0.5cm}
\begin{multicols}{2}
\begin{itemize}
\footnotesize
\item \textbf{Fortran 90} \skillbar{/0.5}
\item \textbf{Matlab} \skillbar{/1.5}
\item \textbf{\LaTeX} \skillbar{/1.2}
\item \textbf{C} \skillbar{/1.2}
\end{itemize}
\end{multicols}
\end{document}
我需要水平对齐技能栏,使它们从同一位置开始,你能演示一下怎么做吗?
答案1
使用“表格”代替\itemize
:
documentclass[11 pt,oneside,a4paper,titlepage]{article}
\usepackage{array}
\usepackage{tikz}
\usetikzlibrary{calc}
% Skill bar
\newcommand\skillbar[1]{
\begin{tikzpicture}
\foreach [count=\i] \x/\y in {#1}{
\draw[fill=black!30,black!30] (0,\i) rectangle (2,\i+0.15);
\draw[fill=white,black](0,\i) rectangle (\y,\i+0.15);
\node[above right] at (0,\i+0.2) {\x};
}
\end{tikzpicture}
}
\begin{document}
% Programming Languages
\section*{PROGRAMMING LANGUAGES}
\begin{tabular}{>{\textbullet}c >{\bfseries}ll
@{\qquad\qquad}
>{\textbullet}c >{\bfseries}ll }
& Fortran 90 & \skillbar{/0.5} && \LaTeX & \skillbar{/1.2} \\
& Matlab & \skillbar{/1.5} && C & \skillbar{/1.2}
\end{tabular}
\end{document}
附註:
稍微简化一下:
- \skillbar` 命令的定义,现在考虑 0(零,无知识)和 10(优秀)之间的知识等级,并且
表格列的规范(合并带有项目符号和语言名称的列):
\documentclass[11 pt,oneside,a4paper,titlepage]{article}
\usepackage{array}
\usepackage{tikz}
\usetikzlibrary{calc}
% Skill bar
\newcommand\skillbar[1]{% grade from 0 to 10
\tikz{\draw (0,0) rectangle (2, 1.5ex);
\fill[black] (0,0) rectangle (2*#1/10, 1.5ex);
}
}
\begin{document}
% Programming Languages
\section*{PROGRAMMING LANGUAGES}
\begin{tabular}{>{\textbullet\bfseries\ }ll
@{\qquad\qquad}
>{\textbullet\bfseries\ }ll }
Fortran 90 & \skillbar{4} & \LaTeX & \skillbar{6} \\
Matlab & \skillbar{7.5} & C & \skillbar{6}
\end{tabular}
\end{document}
答案2
像这样吗?
\documentclass[11pt,oneside,a4paper,titlepage]{article}
\usepackage{multicol}
% advanced drawing
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usepackage{smartdiagram}
\usepackage{float}
\usepackage{array}
\usetikzlibrary{decorations.text}
\usetikzlibrary{fadings}
\usetikzlibrary{calc}
\usetikzlibrary{shapes.misc,positioning}
\usetikzlibrary{arrows}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{backgrounds}
\usetikzlibrary{shadings}
\usetikzlibrary{calendar}
\usetikzlibrary{er}
\usetikzlibrary{patterns}
\usetikzlibrary{shapes}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{decorations}
\usetikzlibrary{topaths}
\usepackage{graphicx}
% Skill bar
\newcommand\skillbar[1]{
\begin{tikzpicture}
\foreach [count=\i] \x/\y in {#1}{
\draw[fill=black!30,black!30] (0,\i) rectangle (2,\i+0.15);
\draw[fill=white,black](0,\i) rectangle (\y,\i+0.15);
\node[above right] at (0,\i+0.2) {\x};
}
\end{tikzpicture}
}
% new:
\usepackage{calc} % for '\widthof' macro
\newcommand\mybox[2]{\parbox[l]{\widthof{\textbf{#2}}}{\textbf{#1}}}
\begin{document}
% Programming Languages
\section*{PROGRAMMING LANGUAGES}
\vspace*{-0.5cm}
\begin{multicols}{2}
\footnotesize
\begin{itemize}
\item \textbf{Fortran 90} \skillbar{/0.5}
\item \mybox{Matlab}{Fortran 90} \skillbar{/1.5}
\item \textbf{\LaTeX} \skillbar{/1.2}
\item \mybox{C}{\LaTeX} \skillbar{/1.2}
\end{itemize}
\end{multicols}
\end{document}