我怎样才能将 tikz 节点左对齐?

我怎样才能将 tikz 节点左对齐?

我正在使用一个模板制作简历,该模板使用 tikz 节点作为一般技能部分。该部分如下所示:

在此处输入图片描述

我希望节点相对于彼此左对齐,但目前看来它们在页面上是对齐的。

这是用于生成这些节点的代码:

    \section{General Skills}
    \smallskip % additional skip because tag outlines use up space
    \tag{Good Written and Verbal communication}{A}{}
    \tag{Can work to a deadline}{B}{}
    \tag{Analytical/ Scientific approach to work}{}{}
    \tag{Work well in a team}{}{}
    \tag{Can simply communicate complex ideas}{}{}

这是用于生成标签命令的代码:

\newcommand{\tag}[3]{%
  \tikz[baseline]\node[anchor=base, draw=body!30,rounded corners,inner xsep=1ex,inner ysep =0.75ex,text height=1.5ex,text depth=.25ex, #3] (#2) {#1};
}

我尝试使用参数向\node命令添加可选参数,但似乎不起作用。例如,对于参数 3,我尝试添加right=1em of A.east第二个标签,但这只是将第二个标签稍微向下移动。我该怎么做才能阻止这些节点对齐?

答案1

有了它,tabular你就不必改变你的tag定义:

\documentclass{article}
\usepackage{tikz}

\colorlet{body}{red}

\newcommand{\tag}[3]{%
  \tikz[baseline]\node[anchor=base, draw=body!30,rounded corners,inner xsep=1ex,inner ysep =0.75ex,text height=1.5ex,text depth=.25ex, #3] (#2) {#1};
}

\begin{document}
\begin{tabular}{rr}
    \tag{Good Written and Verbal communication}{A}{} &
    \tag{Can work to a deadline}{B}{} \\
    \tag{Analytical/ Scientific approach to work}{}{} &
    \tag{Work well in a team}{}{}  \\
    \tag{Can simply communicate complex ideas}{}{}
\end{tabular}
\end{document}

在此处输入图片描述

相关内容