0

Good morning. In my theatre script I create a \newcommand for each character. I would like to simplify by solving everything with a single command using \NewDocumentCommand, but the documentation is really difficult. Is this possible? Thank you very much!

\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{titlesec}
\usepackage{lipsum}

% Fonts
\usepackage{nimbusmononarrow}
\renewcommand*\familydefault{\ttdefault}

% def characters
\newcommand\JAMES{\par\vspace{5mm}\noindent\makebox[35mm][l]{JAMES}\hangindent=35mm}
\newcommand\CLARE{\par\vspace{5mm}\noindent\makebox[35mm][l]{CLARE}\hangindent=35mm}
\newcommand\BILL{\par\vspace{5mm}\noindent\makebox[35mm][l]{BILL}\hangindent=35mm}
\newcommand\ESTER{\par\vspace{5mm}\noindent\makebox[35mm][l]{ESTER}\hangindent=35mm}

\begin{document}

\JAMES
\lipsum*[1][1-3]

\CLARE
\lipsum*[1][1-4]

\BILL
\lipsum*[1][1-5]

\ESTER
\lipsum*[1][1-2]

\end{document}
5
  • why and what do you want to change? Jun 10, 2022 at 10:25
  • 1
    In this case \newcommand\JAMES{... can just be replaced by \NewDocumentCommand\JAMES{}{.... Buy as Ulrike asks, why and what?
    – daleif
    Jun 10, 2022 at 10:27
  • 1
    What's wrong with what has already been suggested in tex.stackexchange.com/q/647157/4427 ?
    – egreg
    Jun 10, 2022 at 10:44
  • That post talked about internal alignment. Here I would like to keep the original alignment. Thank you.
    – Andy Toff
    Jun 10, 2022 at 10:55
  • @AndyToff frougon's answer aligns exactly as you wish here.
    – egreg
    Jun 10, 2022 at 13:24

2 Answers 2

4

If you would like to simplify it, you can define a common macro for each four persons because there is the same format commands for each person.

% def characters
\def\declname#1#2{%
   \def#1{\vskip5mm \noindent\hbox to35mm{#2\hss}\hangindent=35mm \ignorespaces}}
\declname \JAMES {JAMES}
\declname \CLARE {CLARE}
\declname \BILL  {BILL}
\declname \ESTER {ESTER}
2
  • 4
    they shouldn't use \hbox in latex. That is not color safe. Jun 10, 2022 at 10:50
  • It is color safe.
    – wipet
    Jun 10, 2022 at 17:18
0

Suggestion: To save typing the name twice, you can do:

% def characters
\newcommand\declname[1]{%
   \expandafter\newcommand\csname #1\endcsname{\par\vspace{5mm}\noindent\makebox[35mm][l]{#1}\hangindent=35mm}}

\declname {JAMES}
\declname {CLARE}
\declname {BILL}
\declname {ESTER}

names

MWE

\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{titlesec}
\usepackage{lipsum}

% Fonts
\usepackage{nimbusmononarrow}
\renewcommand*\familydefault{\ttdefault}

% def characters
\newcommand\declname[1]{%
   \expandafter\newcommand\csname #1\endcsname{\par\vspace{5mm}\noindent\makebox[35mm][l]{#1}\hangindent=35mm}}

\declname {JAMES}
\declname {CLARE}
\declname {BILL}
\declname {ESTER}
\begin{document}

\JAMES
\lipsum*[1][1-3]

\CLARE
\lipsum*[1][1-4]

\BILL
\lipsum*[1][1-5]

\ESTER
\lipsum*[1][1-2]

\end{document}

You must log in to answer this question.

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