I want to write my own library. How could one define a new command equivalent to the following ?
\par\noindent\rule[5pt]{\textwidth}{1pt}
The general answer is the one from my comment:
you can wrap most macro sequences into a newcommand macro. In your case e.g. \newcommand{\commandname}{\par\noindent\rule[5pt]{\textwidth}{1pt}} where you can exchange \commandname with your preference.
At the regular user level command names can't contain hyphens, underscores an other special characters.
Of course, there are many possibilities more to define new commands, like \NewDocumentCommand, simple \def or expl3 variants.
But for your simple use case \newcommand seems best for me.
\def for defining new commands/macros.
– lukeflo
Aug 12 '23 at 10:41
newcommandmacro. In your case e.g.\newcommand{\commandname}{\par\noindent\rule[5pt]{\textwidth}{1pt}}where you can exchange\commandnamewith your preference. If that makes sense with your code, is another question, because we don't know your exact use case. Instead of posting just a code snippet, a compilable MWE, which shows your aims, would help. – lukeflo Aug 12 '23 at 05:44commandnamedo not allow hyphens-or underscores_? – Bhanat Aug 12 '23 at 06:28newcommandwill give a warning/error. – lukeflo Aug 12 '23 at 07:15