3

I want to make a package that has a bunch of commands that I define in all of my Problem Sets. I'm running into an issue where the compiler does not recognize commands that I define that have an argument. Here is a brain-dead simple example of something that isn't compiling and I can't seem to find out why.

This is my style file, aptly named mystyle.sty:

\ProvidesPackage{mystyle}

\newcommand{\test}{\Huge}
\newcommand{\hding}[1]{#1\newline\normaltext}

mystyle.sty has two commands in it. \test just makes the text Huge, and \hding appends a newline and changes the font back to normal. My brain-dead simple .tex file is as follows:

\documentclass{paper}

\usepackage{mystyle}

\begin{document}
Hello World!
%\hding{Hello World!} Hello World!
\test Hello World!
\end{document}

With just the test function, everything works fine. But if I try to compile with the \hding function uncommented, the compiler yells at me with the following error:

! Undefined control sequence.
\hding #1->#1\newline \normaltext 

l.7 \hding{Hello World!}
                     Hello World!

What is going on? What am I not understanding?

  • 1
    There is no command called \normaltext. Perhaps you're thinking of \textnormal. And by the way, welcome to TeX.SX! You can have a look at our starter guide to familiarise yourself further with our format. – ChrisS Sep 24 '14 at 2:29
  • Wow, I knew it was something dumb. But nothing was complaining about \normaltext. TexStudio was fine with it, and the compiler didn't say a thing. Ah well, the more you know. Thanks for the welcoming btw. – InspiredOne Sep 24 '14 at 2:37
  • 1
    The error message shows the command definition (\hding #1->#1\newline \normaltext) which means that the undefined control sequence is one of the commands used within the definition of \hding rather than \hding itself. – Nicola Talbot Sep 24 '14 at 8:40
  • Ok, I shall remember that for future reference. – InspiredOne Sep 24 '14 at 15:28
4

Most probable, the \normaltext command should rather read \normalsize, as the OP first changes the font size to \Huge and \hding should restore it to the normal font, this could be understood as restoring the original fontsize, which can be achieved by \normalsize.

As far as I know, there is no \normaltext command.

\textnormal, as suggested by ChrisS is rather used in math mode, in order to get normal text, not in math font.

mystyle.sty

    \ProvidesPackage{mystyle}

    \newcommand{\test}{\Huge}
    \newcommand{\hding}[1]{#1\newline\normalsize}%

main file

\documentclass{paper}

\usepackage{mystyle}


\begin{document}
\[\textnormal{Hello World!}\]
\[Hello World\]
Hello World!
\hding{Hello World!} Hello World!
Before \test Afterwards: Hello World!
\end{document}

enter image description here

Note

In principle, an environment would be better to achieve the font switch and restoring afterwards.

  • Thanks, I picked up that command from some website, and none of the tools I was using told me it was invalid. the error messages were very misleading and I ended up spending way too much time on this rather than actually working on the assignment DX. Thanks again. – InspiredOne Sep 24 '14 at 4:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.