我想实现以下几点:
但是我无法将垂直文本和线条粘合在一起。我使用了一个tabular
环境,这就是我得到的结果:
我的代码是这样的:
%!TEX program = xelatex
\documentclass[a4paper]{article}
\RequirePackage{pgffor}
\RequirePackage{wasysym}
\newcommand{\dotrating}[1]{
\foreach \n in {1,...,4}{%
\ifnum\n>#1%
\fullmoon%
\else%
\newmoon%
\fi%
~
}
}
\RequirePackage{multirow}
\RequirePackage{rotating}
\RequirePackage{ifthen}
\newcounter{skillsNumber}
\newenvironment{skillgroup}[2]{%
\setcounter{skillsNumber}{0}
\newcommand{\skill}[2]{
\addtocounter{skillsNumber}{1}
\ifthenelse{\equal{1}{\value{skillsNumber}}}{
\multirow{#2}{*}{
\rotatebox{90}{\centering
\tiny\uppercase{#1}
}
}
}{}
& \parbox{2.5cm}{\raggedright##1} & \dotrating{##2} \\
}
\renewcommand{\arraystretch}{0.5}
\begin{tabular}{r|ll}
}{%
\end{tabular}
}
\begin{document}
\begin{skillgroup}{PROGRAMMATION}{6}
\skill{C}{3}
\skill{C++}{3}
\skill{JAVA}{2}
\skill{MATLAB}{4}
\skill{VBA/6/.NET}{4}
\skill{Shell}{4}
\end{skillgroup}
\end{document}
如何将垂直线和文本粘贴在一起?此外,多行的宽度太大。我该如何减小它?
答案1
我会做类似的事情(而且你也有很多%
不需要它们的地方\else%
,也有很多%
需要它们的地方缺失了(其他地方:-)
\documentclass[a4paper]{article}
\RequirePackage{wasysym}
\RequirePackage{graphicx}
\newcommand{\dotrating}{%
\ifnum\count0<\count2 %
\newmoon
\else
\fullmoon
\fi
\hspace{.5em}%
\ifnum\count0<3
\advance\count0 1 %
\expandafter\dotrating
\fi
}
\newcounter{skillsNumber}
\newenvironment{skillgroup}[2]{%
\setcounter{skillsNumber}{0}%
\newcommand{\skill}[2]{%
##1&\count0=0\count2=##2\relax
\dotrating\\%
}
%
\renewcommand{\arraystretch}{1.1}%
\rotatebox{90}{\llap{\tiny\uppercase{#1}}}%
\begin{tabular}[t]{@{}|ll}%
}{%
\end{tabular}%
}
\begin{document}
\begin{skillgroup}{PROGRAMMATION}{6}
\skill{C}{3}
\skill{C++}{3}
\skill{JAVA}{2}
\skill{MATLAB}{4}
\skill{VBA/6/.NET}{4}
\skill{Shell}{4}
\end{skillgroup}
\end{document}
答案2
这是否接近您想要的?此解决方案建议保留您的代码,并进行少量更改,% here
并添加一个raisebox
方案以降低文本
\raisebox{-1.5ex}[0ex][0ex]{\tiny\uppercase{#1}\hspace{-14ex}}
代码
%!TEX program = xelatex
\documentclass[border=10pt]{standalone}%[a4paper]{article}
\RequirePackage{pgffor}
\RequirePackage{wasysym}
\newcommand{\dotrating}[1]{%
\foreach \n in {1,...,4}{%
\ifnum\n>#1%
\fullmoon
\else
\newmoon
\fi
~
}
}
\RequirePackage{multirow}
\RequirePackage{rotating}
\RequirePackage{ifthen}
\newcounter{skillsNumber}
\newenvironment{skillgroup}[2]{%
\setcounter{skillsNumber}{0}
\newcommand{\skill}[2]{%
\addtocounter{skillsNumber}{1}
\ifthenelse{\equal{1}{\value{skillsNumber}}}{%
\multirow{#2}{*}{%
\rotatebox{90}{%
\raisebox{-1.5ex}[0ex][0ex]{\tiny\uppercase{#1}\hspace{-14ex}} % here
}
}
}{}
& \parbox{2.5cm}{\raggedright##1} & \dotrating{##2} \\
}
\renewcommand{\arraystretch}{1.3} % here
\begin{tabular}{r@{}|ll} % here
}{%
\end{tabular}
}
\begin{document}
\begin{skillgroup}{PROGRAMMATION}{6}
\skill{C}{3}
\skill{C++}{3}
\skill{JAVA}{2}
\skill{MATLAB}{4}
\skill{VBA/6/.NET}{4}
\skill{Shell}{4}
\end{skillgroup}
\end{document}
更新: 定义自制fullmoon
且不newmoon
使用wasysymb
包装
代码
%!TEX program = xelatex
\documentclass[a4paper]{article}
\usepackage{tikz}
\newcommand*\circled[1]{\tikz[]{
\node[shape=circle,draw,inner sep=0.01ex] () {#1};}}
\newcommand*\fullmoon{\tikz[]{
\draw[] circle(.75em);}}
\newcommand*\newmoon{\tikz[]{
\draw[fill] circle(.5em);}}
\RequirePackage{pgffor}
%\RequirePackage{wasysym}
\newcommand{\dotrating}[1]{%
\foreach \n in {1,...,4}{%
\ifnum\n>#1%
\fullmoon
\else
\circled\newmoon
\fi
~
}
}
\RequirePackage{multirow}
\RequirePackage{rotating}
\RequirePackage{ifthen}
\newcounter{skillsNumber}
\newenvironment{skillgroup}[2]{%
\setcounter{skillsNumber}{0}
\newcommand{\skill}[2]{%
\addtocounter{skillsNumber}{1}
\ifthenelse{\equal{1}{\value{skillsNumber}}}{%
\multirow{#2}{*}{%
\rotatebox{90}{%
\raisebox{-1.5ex}[0ex][0ex]{\tiny\uppercase{#1}\hspace{-14ex}}
}
}
}{}
& \parbox{2.5cm}{\raggedright##1} & \dotrating{##2} \\
}
\renewcommand{\arraystretch}{1.3}
\begin{tabular}{r@{}|ll}
}{%
\end{tabular}
}
\begin{document}
\begin{skillgroup}{PROGRAMMATION}{6}
\skill{C}{3}
\skill{C++}{3}
\skill{JAVA}{2}
\skill{MATLAB}{4}
\skill{VBA/6/.NET}{4}
\skill{Shell}{4}
\end{skillgroup}
\end{document}
答案3
以下是使用 TikZ 图片而不是表格环境的解决方案:
\documentclass[border=4pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\makeatletter
\def\aerow{0}
\def\aehu{0.45cm*}%% horizontal unit for placement of circled nodes
\newcommand\ae@parse@current@skill[2]{%%
\xdef\aerow{\number\numexpr\aerow+1}%%
\node[anchor=west] (N\aerow) at (0,-\aerow) {\sffamily#1};
%% \ae@last@node is used to help draw vertical line
\gdef\ae@last@node{N\aerow}%%
\foreach \myn in {0,1,2,3}
{
\edef\ae@h@position{\dimexpr\ae@longest+\aehu\myn+10pt}%%
\node [draw,circle,inner sep=3pt] at (\ae@h@position,-\aerow) {};
\ifnum\myn<#2\relax
\draw[fill] (\ae@h@position,-\aerow) circle (2.75pt) ;
\fi
}
\def\ae@skill@level{#2}}
\newlength\ae@tmp
\newlength\ae@longest
\newcommand\skillgroup[2]{%%
\def\ae@title{#1}%%
\def\ae@skillgroup{#2}%%
%% first determine the length of the longest skill name
\foreach \myskill in \ae@skillgroup
{\expandafter\ae@extract@parts\myskill
\settowidth\ae@tmp{\ae@current@skill}%%
\ifdim\ae@tmp>\ae@longest
%% \global is necessary because of grouping created by \foreach
\global\setlength\ae@longest{\ae@tmp}%%
\fi
}%%
%% now present all the skills
\begin{tikzpicture}[y=4ex]
\foreach \myskill in \ae@skillgroup
{
\expandafter\ae@parse@current@skill\myskill
}
\node[anchor=south east,rotate=90,inner sep=0pt] at ([xshift=-1pt]N1.north west) {\ae@present@title};
\draw (N1.north west) -- (\ae@[email protected] west);
\end{tikzpicture}}
\def\ae@present@title{\textsf{\tiny\expandafter\uppercase\expandafter{\ae@title}}}
\def\ae@extract@parts#1#2{%%
\def\ae@current@skill{#1}%%
\def\ae@current@level{#2}}
\makeatother
\begin{document}
\skillgroup{PROGRAMMATiON}{%%
{C}{3},
{C++}{3},
{JAVA}{2},
{MATLAB}{4},
{VBA/6/.NET}{4},
{Shell}{4}}
\end{document}