2

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]{
        \par\vspace{\baselineskip}{\Large\headingfont\color{headercolor} ##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]{
        \par\vspace{\baselineskip}{\Large\headingfont\color{headercolor} ##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 
Command \barline already defined. \begin{aside}
Package tikz Error: Giving up on this path.Did you forget a semicolon?. \barline{French}{70}

Option clash is a package issue that I must look into. I thought that my new command would override the command if it exists. Why is there an issue with the semicolon since I put it in the newcommand?

I hope you will be able to help me, I'm quite new with things more complicated than a simple report with LaTeX and it takes time to learn.

  • 1
    Welcome to TeX.SE. While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. Use \renewcommand instead of \newcommand if you want to redefine an existing command. – Peter Grill Jun 1 '17 at 9:47
  • 1
    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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.