I am trying to define a macro which I will include in a class definition. For the time being I put the macro definition in the normal document. Compiling this document fails:
\documentclass[10pt,a4paper]{article}
\makeatletter
\def\ntcstitle#1{\def{\@ntcstitle}{#1}}
\newcommand{\thentcstitle}{\@ntcstitle}
\makeatother
\ntcstitle{Lorem Ipsum}
\begin{document}
\thentcstitle\par
\end{document}
This example is something I copied from another question here, which seemed to work: Define variable in a class
I also tried to move this definition into a class file. Omitted the \makeatletter and \makeatother commands. Using the class file was successful, the error message is the same.
This is the error message:
! Missing control sequence inserted.
<inserted text>
\inaccessible
l.10 \ntcstitle{Lorem Ipsum}
Then I replaced the macro with the Latex style definition:
\documentclass[10pt,a4paper]{article}
\usepackage{lipsum}
\makeatletter
\newcommand{\ntcstitle}[1]{\newcommand{\@ntcstitle}{#1}}
\newcommand{\thentcstitle}{\@ntcstitle}
\makeatother
\ntcstitle{Lorem Ipsum}
\begin{document}
\thentcstitle\par
\end{document}
And that works as expected.
I tried to use \def instead of \newcommand because I assumed \def was the correct way to define macros in class files. What I am doing wrong here?
Aucun commentaire:
Enregistrer un commentaire