<div dir="ltr">If i create a simple sty file, say mypackage.sty which includes:<br><br>%%%%%%%%%%%%%%%%%%%%%%%%%%%<br>\NeedsTeXFormat{LaTeX2e}<br>\ProvidesPackage{mypackage}<br>\catcode`$=11<br>\newcommand*{\eqcommand}[2]{%<br>
\expandafter\@ifdefinable \csname#1\endcsname{%<br>\expandafter\let\csname#1\expandafter\endcsname\csname#2\endcsname}}<br>\eqcommand{new$command}{newcommand}<br>\endinput<br>%%%%%%%%%%%%%%%%%%%%%%%%%%<br><br>then this tex file gives error:<br>
<br>
<style type="text/css">p, li { white-space: pre-wrap; }</style>
<p style="margin: 0px; text-indent: 0px;">\documentclass{article}</p>
<p style="margin: 0px; text-indent: 0px;">\usepackage{mypackage}</p>
<p style="margin: 0px; text-indent: 0px;">\new$command\test{Test}</p>
<p style="margin: 0px; text-indent: 0px;">\begin{document}</p>
<p style="margin: 0px; text-indent: 0px;">This is a test\TeX</p>
<p style="margin: 0px; text-indent: 0px;">\end{document}</p><p style="margin: 0px; text-indent: 0px;"><br></p><p style="margin: 0px; text-indent: 0px;">and the error is:</p><p style="margin: 0px; text-indent: 0px;"><br><style type="text/css">p, li { white-space: pre-wrap; }</style>! Undefined control sequence.
</p><p style="margin: 0px; text-indent: 0px;"><recently read> \new </p>
<p style="margin: 0px; text-indent: 0px;"> </p>
<p style="margin: 0px; text-indent: 0px;">l.3 \new</p>
<p style="margin: 0px; text-indent: 0px;"> $command\test{Test}</p>
<p style="margin: 0px; text-indent: 0px;">? <br></p><p style="margin: 0px; text-indent: 0px;"><br></p><p style="margin: 0px; text-indent: 0px;">Then I I change my tex file so that I leave a blank line after \usepackage{mypackage}, no error happens:</p>
<p style="margin: 0px; text-indent: 0px;"><br><style type="text/css">p, li { white-space: pre-wrap; }</style>\documentclass{article}
</p><p style="margin: 0px; text-indent: 0px;">\usepackage{mypackage}</p><p style="margin: 0px; text-indent: 0px;"><br></p><p style="margin: 0px; text-indent: 0px;">\new$command\test{Test}</p><p style="margin: 0px; text-indent: 0px;">
\begin{document}</p><p style="margin: 0px; text-indent: 0px;">This is a test\TeX</p><p style="margin: 0px; text-indent: 0px;">\end{document}</p><p style="margin: 0px; text-indent: 0px;"><br></p><p style="margin: 0px; text-indent: 0px;">
but even without using a package, this gives no error:</p><p style="margin: 0px; text-indent: 0px;"><br></p><p style="margin: 0px; text-indent: 0px;"><br><style type="text/css">p, li { white-space: pre-</style><br></p><p style="margin: 0px; text-indent: 0px;">
\documentclass{article}</p><p style="margin: 0px; text-indent: 0px;">\makeatletter</p><p style="margin: 0px; text-indent: 0px;">\catcode`$=11</p><p style="margin: 0px; text-indent: 0px;">\newcommand*{\eqcommand}[2]{%</p><p style="margin: 0px; text-indent: 0px;">
\expandafter\@ifdefinable \csname#1\endcsname{%</p><p style="margin: 0px; text-indent: 0px;">\expandafter\let\csname#1\expandafter\endcsname\csname#2\endcsname}}</p><p style="margin: 0px; text-indent: 0px;">\eqcommand{new$command}{newcommand}</p>
<p style="margin: 0px; text-indent: 0px;">\makeatother</p><p style="margin: 0px; text-indent: 0px;">\new$command\test{Test}</p><p style="margin: 0px; text-indent: 0px;">\begin{document}</p><p style="margin: 0px; text-indent: 0px;">
This is a test\TeX</p><p style="margin: 0px; text-indent: 0px;">\end{document}</p><p></p><p></p><p></p><br><br>So can you please enlighten me why this error only happens when my definitions are inside sty file and how can I fix this?<br clear="all">
<br>-- <br><div dir="ltr">I prefer the most bloodcurdling death to living with humility. The only country I am faithful to, is IRAN. Do not denigrate my last moments...<br></div><br>
</div>