3

This question already has an answer here:

I am wondering if it is possible to change the output of a \newcommand after it is used once? I am creating a template for video transcription and I want the names to appear in full once, and then just the first letter in subsequent lines.

I would like to do the following:

\documentclass{report}
\newcommand{\mycommand}[1]{NameOfPerson: #1} % what do I change here?
\begin{document}

\mycommand{Transcription of what the person says here}
\mycommand{Another line from the same person}

\end{document}

And the output to look something like:

NameOfPerson: Transcription of what the person says here

N: Another line from the same person


I am new to LaTeX so please forgive me if this is a simple question!

marked as duplicate by clemens, Stefan Pinnow, TeXnician, Schweinebacke, user36296 Jun 28 '17 at 9:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

5

You don’t need anything special:

\documentclass{report}

\newcommand{\mycommand}[1]{%
    \renewcommand{\mycommand}[1]{N.:\nobreak\space ##1}%
    NameOfPerson: #1%
}



\begin{document}

% \show\mycommand

\mycommand{Transcription of what the person says here}

% \show\mycommand

\mycommand{Another line from the same person}

\mycommand{Yet another line from the same person}

\end{document}

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