# Adding dynamic tikzpicture with newcommand inside new command

I have a side block command that lets me add content on the side of the page very easily but now I want to have the choice to add some kind of chart or dynamic graphic content in it too.

Lets say I want to add a skill/theme and a level of difficulty, instead of having it written I will add an icon for the skill and I want to add a nice stylized bar to show the level of difficulty.

This is my basic side block command:

\RequirePackage[absolute,overlay]{textpos}
\setlength{\TPHorizModule}{1cm}
\setlength{\TPVertModule}{1cm}

\newenvironment{aside}{%
\let\oldsection\section
\renewcommand{\section}[1]{
}
\begin{textblock}{3.6}(1.5, 4.33)
\begin{flushright}
\obeycr
}{%
\restorecr
\end{flushright}
\end{textblock}
\let\section\oldsection
}


Then I tried to modify it to be able to add a new rectangle with tikz for each "\barline" (the rectangle is a test).

\RequirePackage[absolute,overlay]{textpos,tikz}
\setlength{\TPHorizModule}{1cm}
\setlength{\TPVertModule}{1cm}

\newenvironment{aside}{%
\let\oldsection\section
\renewcommand{\section}[1]{
}
\newcommand{\barline}[2]{
\begin{tikzpicture}
\fill[fill=chartorange, rounded corners=0.08cm](-1,0) rectangle (1.5,0.5) {##1};
\end{tikzpicture}
}
\begin{textblock}{3.6}(1.5, 4.33)
\begin{flushright}
\obeycr
}{%
\restorecr
\end{flushright}
\end{textblock}
\let\section\oldsection
}


Using it like:

\begin{aside}
\section{Languages}
\barline{French}{70};
\end{aside}


My problem is that I must do something wrong since I get a lot of errors :

Option clash for package tikz. \setlength

• Do not define \barline within aside, but globally. – TeXnician Jun 5 '17 at 11:23
• Otherwise, the second time you use the environment, \barline is already defined and not new, so \newcommand fails. – cfr Jun 5 '17 at 12:49
• Are you sure you want to redefine \section like that? – cfr Jun 5 '17 at 12:50