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 the following 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:
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?
\newcommandif you can as it is safer. What is the purpose of the command exactly? I'm not sure why you are defining 3 different commands. – cfr Dec 01 '14 at 00:43\newcommandis LaTeX.\defis TeX. Only use\defwhen you know why\newcommandisn't suitable. – cfr Dec 01 '14 at 00:45\newcommand{\ntcstitle}[1]{\newcommand{\thentcstitle}{#1}}? – cfr Dec 01 '14 at 00:49