I am trying to define some variables in the preamble so they are initialized there and then printed in the text body. Here is what I tried
\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[frenchb]{babel}
\newcommand{\cost}[1]{\def\@cost{#1}}
\newcommand{\refArticle}[1]{\def\@refArticle{#1}}
\cost{400}
\refArticle{TOTO01}
\begin{document}
This is a non-working test; it will cost \@cost dollars to buy \@refArticle.
\end{document}
It did not work. I got an error
! Use of \@ doesn't match its definition.
Which buggers me, since
\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[frenchb]{babel}
\newcommand{\cost}[1]{\def\@cost{#1}}
\newcommand{\refArticle}[1]{\def\@refArticle{#1}}
\cost{400}
% \refArticle{TOTO01}
\begin{document}
This is a working test; it will cost \@cost to buy what you want.
\end{document}
works.
I probably missed something with variable definitions. Have you any idea of what can be wrong with my approach?
\makeat[...]but inverting\varand\@var) but it didn't work, I did not think of doing it like that, thanks! – MBR Sep 17 '13 at 14:33