2

I m trying to create a new short command for the dialogue package. While the regular use of \speak{} inside the environment works, the \newcommand that I have created using it doesn't.

\newcommand*\tchr{{\speak{Teacher}}}

While compiling it gives the error

LaTeX Error: Something's wrong--perhaps a missing \item.

I am sure the problem is with my definition of a newcommand using \speak but not sure how to resolve it.

MWE is appended below.

\documentclass{article}
\usepackage{dialogue}


% custom commands for speaking

\newcommand*\tchr{{\speak{Teacher}}}
\newcommand*\std{{\speak{Student}}}

\begin{document}


% this works

\begin{dialogue}

\speak{Teacher} This is going to be fun

\speak{Student} How so?

\end{dialogue}

% this doesn't

\begin{dialogue}

\tchr This is going to be fun

\std How so?

\end{dialogue}

\end{document}
  • Just to complement Matts answer, it is the braces here that is the problem {\speak{Teacher}}. \speak is implemented as starting a new list item, aka \item[...], but with the extra braces this becomes {\item[...]} and not the list cannot see the first item in the dialogue and thus gives an error about text in a list without a \item. – daleif Apr 2 at 11:11
  • 1
    Thanks for an explanation of the error! – Damitr Apr 2 at 11:12
3

When using \newcommand, I believe the format should be as such:

\newcommand{\nameofcommand}{<commandaction>}

So in your case, it would look like:

\newcommand{\tchr}{\speak{Teacher}}
\newcommand{\std}{\speak{Student}}

The problem with your code is that \speak should appear at the outer level, and the additional braces hinder its working.

| improve this answer | |

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.