# Why can’t I define a command with \renewcommand?

I try use boolean expresion which it has been shown on my MNWE:

\documentclass[12pt, b4paper, twoside]{scrbook}
\usepackage[log-declarations=false]{xparse}
\usepackage{xltxtra}
\usepackage{etoolbox}
\usepackage{amsmath, amsthm, amssymb, amsfonts, amsbsy}

\newbool{pboldvectors}%
\booltrue{pboldvectors}%

\ifbool{pboldvectors}%
{\renewcommand{\vecc}[1]{\mathbf{#1}}}                      % then clausule
{\renewcommand{\vecc}[1]{\vec{#1}}}                         % else clausule

\begin{document}
$$\vecc{x}$$
\end{document}


but without success. I have got Latex error: \vecc is undefinned. Before, I used the library ifthen, but it has been obsolete. I would like to use this switch for mathematical formatting.

• @jafan: Please accept karl’s instead, He was the first one an I can’t delete mine as long it is marked as accepted. – Tobi Aug 12 '13 at 20:43
• The issue has nothing to do with either koma-script, etoolbox or conditionals. Both tags and title of the question are quite misleading... – clemens Aug 12 '13 at 21:12
• @cgnieder: I tried to fix it, do you agree with my edit? – Tobi Aug 12 '13 at 21:24

To use \renewcomad a command must be defined before. Use \newcommand instead ...

• This was already in my comment... – karlkoeller Aug 12 '13 at 20:30
• @karlkoeller: Sorry I over read this (answered from my smart phone …). Why don’t you extend you comment a little an make an answer out of it? I’ll delete mine ;-) – Tobi Aug 12 '13 at 20:32
• OK, I will now... – karlkoeller Aug 12 '13 at 20:34

You can not use \renewcommand when a command has never been defined before, as in the case of \vecc.


So the code

\documentclass[12pt, b4paper, twoside]{scrbook}
\usepackage[log-declarations=false]{xparse}
\usepackage{xltxtra}
\usepackage{etoolbox}
\usepackage{amsmath, amsthm, amssymb, amsfonts, amsbsy}

\newbool{pboldvectors}%
\booltrue{pboldvectors}%

\ifbool{pboldvectors}%
{\newcommand{\vecc}[1]{\mathbf{#1}}}                      % then clausule
{\newcommand{\vecc}[1]{\vec{#1}}}                         % else clausule

\begin{document}
$$\vecc{x}$$
\end{document}


will work.