TransWikia.com

How to get rid of last comma

TeX - LaTeX Asked on May 28, 2021

I am using the following code to print a list of all characters that say something in a given scene of a play-script.

newcommandsceneroles[2][Roles]{%
  defscenename{#2}%
  textbf{#1}:%
  Bind{?id}{rdf:type}{rl:role}{%
    % GetVal prints the variable name,
    % GetValProperty extracts property from the name
    % Set the default left time
    % use the real at:left if it has been set
    IfProperty{GetVal{?id}}{is:playsin#2}{%
        GetValProperty{?id}{rl:name}, %
    }{}%
  }%
}

the problem is, that I cannot get rid of the last comma.

what should be printed is:

Roles: Romeo, Juliet

what is printed:

Roles: Romeo, Juliet,

One Answer

Use this definition:

newcommandsceneroles[2][Roles]{%
  defscenename{#2}% Store scene names
  defnamesep{defnamesep{, }}% One cycle delay name separator
  textbf{#1}:%
  Bind{?id}{rdf:type}{rl:role}{%
    % GetVal prints the variable name,
    % GetValProperty extracts property from the name
    % Set the default left time
    % use the real at:left if it has been set
    IfProperty{GetVal{?id}}{is:playsin#2}{%
      namesepGetValProperty{?id}{rl:name}%
    }{}%
  }%
}

It uses a cunning (La)TeX trick.

Correct answer by Werner on May 28, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP