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}
2
  • 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, 2020 at 11:11
  • 1
    Thanks for an explanation of the error!
    – Damitr
    Apr 2, 2020 at 11:12

1 Answer 1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .