[XeTeX] Translation commands for package dramatist to put in the marathi.ldf file

Zdenek Wagner zdenek.wagner at gmail.com
Sun Apr 12 15:59:52 CEST 2020


Hi all,

just to summarize:

\def, \edef, \gdef, \xdef, \let, \chardef, \mathchardef are primitives,
they work always without any check. You can damage anything if you are not
careful.

\newcommand defines a new (fragile) macro (without a star it is \long),
reports an error if already exists

\renewcommand reports an error if the macro does not exist

\DeclareRobustCommand defines a robust macro (\long without a star), no
checks

\providecommand defines a macro only if it does not exist, it is not an
error if it already exists, the existing definition will not be changed

\newcommand\relax{be happy} will tell you that it is an error but
\gdef\relax{be happy} will be executed without an error and it will
probably be the last thing in your LaTeX document which will work,
\providecommand\relax{be happy} will do nothing, \renewcommand assumes that
you know what you are doing, hence you should know why you want to destroy
the whole LaTeX kernel by redefining \relax...

If you know what you are doing, and when preparing package-like macros you
should know it, there is no reason for not using the primitives directly.
For instance, in one document I want \label to do another action with its
argument. I believe that it will always have one argument but the code of
\label can be changed in the future. Thus I store its current definition,
define my addition and then call the original macro. This can be done with
\let and \def, not with \newcommand:

\let\savedLabel\label
\def\label#1{Do something with #1 \SavedLabel{#1}}

The second line could be replaced with
\renewcommand*\label[1]{Do something with #1 \SavedLabel{#1}}

\providecommand is useful if you assume that a definition exist but you
want to provide a default definition.

The newcommand family is useful because it offers a default first argument
but if you use arguments with the newcommand family, use always the star
version so that the macro is not \long. If you forget a right brace after
an argument, you will get an error message at the end of a paragraph but
without  the star you get an error message at the end of a file hence it is
difficult the source of the error.

Construct \csname scenename\endcsname expands to the contents of \scenename
if already defined or is defined to be identical with \relax if not yet
defined. When checking existence of definition, LaTeX does the following:

\expandafter\ifx\csname scenename\endcsname\relax
  code for \scenename not yet defined
\else
  code for \scenename already defined
\fi

Of course, the whole \else part can be omitted if you have nothing to put
there.

Zdeněk Wagner
http://ttsm.icpf.cas.cz/team/wagner.shtml
http://icebearsoft.euweb.cz


ne 12. 4. 2020 v 12:49 odesílatel Ross Moore <ross.moore at mq.edu.au> napsal:

> Hi Phil, Zdeněk and others.
>
> On 12 Apr 2020, at 7:46 pm, Philip Taylor <P.Taylor at Hellenic-Institute.Uk>
> wrote:
>
> Zdeněk Wagner wrote:
>
> I would not do it. Of course, you cannot use \renewcommand because
> \scenename is not used in any *.ldf. You could use \def\scenename{दरश्य} […]
>
>
> LaTeX has  \providecommand  with the same syntax as \newcommand  and
>  \renewcommand .
>
> It makes the definition *only* if the c-s is not already known.
> This means that you can always use:
>
>   \providecommand\mycs{}
>   \renewcommand\mycs{ what I really want }
>
> to get around such issues.
>
>
> A thought — if \scenename is not known at the point that the last line of
> [gloss-]marathi.ldf is read, would there be any point in using \def
> \scenename {दरश्य}, since such definition would either get over-ridden by
> whatever subsequent definition of \scename is causing the problem (\def,
> \renewcommand), or would prevent a subsequent \newcommand from working as
> \scenename would already be defined.  Is this not the case (he asked, as
> someone who barely understands anything that LaTeX does ...) ?
>
>
> There is always a way to get what you want,
> whether using Plain TeX or LaTeX or whatever other high-level macro
> structures.
>
> Thus the important thing is how to make it resistant to updates, as Zdeněk
> said.
>
>
> *Philip Taylor*
>
>
> Hope this helps.
> Stay safe.
>
> Ross
>
>
> Dr Ross Moore
> Department of Mathematics and Statistics
> 12 Wally’s Walk, Level 7, Room 734
> Macquarie University, NSW 2109, Australia
> T: +61 2 9850 8955  |  F: +61 2 9850 8114
> M:+61 407 288 255  |  E: ross.moore at mq.edu.au
> http://www.maths.mq.edu.au
>
> CRICOS Provider Number 00002J. Think before you print.
> Please consider the environment before printing this email.
>
> This message is intended for the addressee named and may
> contain confidential information. If you are not the intended
> recipient, please delete it and notify the sender. Views expressed
> in this message are those of the individual sender, and are not
> necessarily the views of Macquarie University. <http://mq.edu.au/>
> <http://mq.edu.au/>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/xetex/attachments/20200412/6c5a58eb/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 4605 bytes
Desc: not available
URL: <https://tug.org/pipermail/xetex/attachments/20200412/6c5a58eb/attachment-0001.png>


More information about the XeTeX mailing list.