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

Ross Moore ross.moore at mq.edu.au
Sun Apr 12 23:20:36 CEST 2020


Hi Zdenek,

On 13/04/2020, at 0:00, "Zdenek Wagner" <zdenek.wagner at gmail.com<mailto:zdenek.wagner at gmail.com>> wrote:

Hi all,

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}}

This idea can be extended somewhat.

\makeatletter
\def\MY at label#1{Do something with #1 \LTX at label{#1}}
\AtBeginDocument{
 \let\LTX at label\label
 \let\label\MY at label
}
\makeatother

This way you retain pointers to both your own version and the original,
so can change between them if necessary, within different parts of your
document, or within specially tailored environments.

Delaying the \let rebindings using \AtBeginDocument means that it will still work
if some other package (such as  hyperref ) makes its own changes,
which you also want to incorporate.


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

Sure.
It is particularly useful when devising templates that will be filled with information
provided by a database, and command-line shell software that automates
calls to TeX or LaTeX or other engine.

latex '\def\name{client name} ... \input{mytemplate.tex}'

where  mytemplate.tex  is the main LaTeX source, having
  \providecommand{\name}{some default}
and similarly for all the variable data fields.

I use this kind of setup to automate personalised assignment cover-sheets,
generated online in response to student requests from a web page.
Sometimes the full question sheet is done this way,
with versions personalized, or randomized, based upon student ID numbers.


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

With \csname  you can test for all kinds of things,
and even adjust macros like  \begin  and  \end  to patch in extra coding
for specific environments, whether a package is loaded or not.

The possibilities are endless.


Cheers.
Stay safe.

      Ross


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<https://protect-au.mimecast.com/s/QcrSCnx1Z5UgvO8wS9Msu9?domain=ttsm.icpf.cas.cz>
http://icebearsoft.euweb.cz<https://protect-au.mimecast.com/s/fkdBCoV1Y2S5EqO9HzWPDx?domain=icebearsoft.euweb.cz>


ne 12. 4. 2020 v 12:49 odesílatel Ross Moore <ross.moore at mq.edu.au<mailto: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<mailto: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<mailto:ross.moore at mq.edu.au>
http://www.maths.mq.edu.au
<image001.png>
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/291feea4/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 4605 bytes
Desc: image001.png
URL: <https://tug.org/pipermail/xetex/attachments/20200412/291feea4/attachment-0001.png>


More information about the XeTeX mailing list.