ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* \definesomething?
@ 2006-08-24  0:09 Pepe Barbe
  2006-08-26  4:16 ` \definesomething? Aditya Mahajan
  0 siblings, 1 reply; 5+ messages in thread
From: Pepe Barbe @ 2006-08-24  0:09 UTC (permalink / raw)


Hello,

In the ConTeXt manuales there is a reference to \definesomething as a
way to create new commands(?)/variables(?). The truth is that I
haven't bee able to truly understand if this is a generic example or I
can define my own commands with this and how the syntax would be used.
I would appreciate if anyone can clarify this to me.

Thanks,
Pepe

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: \definesomething?
  2006-08-24  0:09 \definesomething? Pepe Barbe
@ 2006-08-26  4:16 ` Aditya Mahajan
  2006-08-27  3:32   ` \definesomething? Pepe Barbe
  0 siblings, 1 reply; 5+ messages in thread
From: Aditya Mahajan @ 2006-08-26  4:16 UTC (permalink / raw)


On Wed, 23 Aug 2006, Pepe Barbe wrote:

> In the ConTeXt manuales there is a reference to \definesomething as a
> way to create new commands(?)/variables(?). The truth is that I
> haven't bee able to truly understand if this is a generic example or I
> can define my own commands with this and how the syntax would be used.
> I would appreciate if anyone can clarify this to me.

You can use if for almost anything you want. This is how \define is 
defined :)

\def\define#1%
   {\ifx#1\undefined
      \expandafter\def
    \else
      \message{[\noexpand#1is already defined]}%
      \expandafter\def\expandafter\gobbleddefinition
    \fi#1}

Which basically means that

\define\mymacro#1 is equivalent to

\def\mymacro#1 but also checks if mymacro has already been defined. 
In general, it is a good idea to use \define for all your private 
macros to make sure that you do not redefine one of context's internal 
macros. Another way to ensure the same thing is to use CAPS for all 
your private macros. If you really want to redefine a macro that is 
already defined, you should use

\redefine\macro....

you can also use \def\macro.... but \redefine gives you a warning 
message.

Aditya

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: \definesomething?
  2006-08-26  4:16 ` \definesomething? Aditya Mahajan
@ 2006-08-27  3:32   ` Pepe Barbe
  2006-08-27  4:04     ` \definesomething? Mojca Miklavec
  0 siblings, 1 reply; 5+ messages in thread
From: Pepe Barbe @ 2006-08-27  3:32 UTC (permalink / raw)


On 8/25/06, Aditya Mahajan <adityam@umich.edu> wrote:
> \define\mymacro#1 is equivalent to
>
> \def\mymacro#1 but also checks if mymacro has already been defined.

Thanks for the info. I am using \define for something simple, define
some keywords with special format that I will be repeating a lot.
Something like:

\define\mybi{\bf\sl BoldItalic}

Works fin except that if I use in a sentence like: This is \mybi word.
It wil be typeset without any space between BoldItalic and word, like
this: This is my BoldItalicword.

Any ideas on how to overcome this?

Thanks,
Pepe

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: \definesomething?
  2006-08-27  3:32   ` \definesomething? Pepe Barbe
@ 2006-08-27  4:04     ` Mojca Miklavec
  2006-08-27  4:19       ` \definesomething? Aditya Mahajan
  0 siblings, 1 reply; 5+ messages in thread
From: Mojca Miklavec @ 2006-08-27  4:04 UTC (permalink / raw)


On 8/27/06, Pepe Barbe wrote:
> On 8/25/06, Aditya Mahajan wrote:
> > \define\mymacro#1 is equivalent to
> >
> > \def\mymacro#1 but also checks if mymacro has already been defined.
>
> Thanks for the info. I am using \define for something simple, define
> some keywords with special format that I will be repeating a lot.
> Something like:
>
> \define\mybi{\bf\sl BoldItalic}

\define\mybi{{\bs BoldItalic}}

You need two braces, otherwise everything else will be bold italic as well.

> Works fin except that if I use in a sentence like: This is \mybi word.

Any space after a command is ignored (unless you start a new paragraph).

This is \mybi{} word.
This is \mybi\ word.

Don Knuth has written an excellent book about TeX (TeXBOOK) that is
really worth reading. Try to find it in a library or to compile it
from the source:
    http://www.ctan.org/tex-archive/help/Catalogue/entries/texbook.html

Mojca

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: \definesomething?
  2006-08-27  4:04     ` \definesomething? Mojca Miklavec
@ 2006-08-27  4:19       ` Aditya Mahajan
  0 siblings, 0 replies; 5+ messages in thread
From: Aditya Mahajan @ 2006-08-27  4:19 UTC (permalink / raw)


On Sun, 27 Aug 2006, Mojca Miklavec wrote:

> On 8/27/06, Pepe Barbe wrote:
>> On 8/25/06, Aditya Mahajan wrote:
>>> \define\mymacro#1 is equivalent to
>>>
>>> \def\mymacro#1 but also checks if mymacro has already been defined.
>>
>> Thanks for the info. I am using \define for something simple, define
>> some keywords with special format that I will be repeating a lot.
>> Something like:
>>
>> \define\mybi{\bf\sl BoldItalic}
>
> \define\mybi{{\bs BoldItalic}}
>
> You need two braces, otherwise everything else will be bold italic as well.
>
>> Works fin except that if I use in a sentence like: This is \mybi word.
>
> Any space after a command is ignored (unless you start a new paragraph).
>
> This is \mybi{} word.
> This is \mybi\ word.

There is also \autoinsertnextspace but that is not to be spoken about 
;)

> Don Knuth has written an excellent book about TeX (TeXBOOK) that is
> really worth reading. Try to find it in a library

or a book store ....

> or to compile it from the source:
>    http://www.ctan.org/tex-archive/help/Catalogue/entries/texbook.html

Do not do that! The file is copyrighted and should not be TeXed. From 
the file:

% This manual is copyright (C) 1984 by the American Mathematical Society.
% All rights are reserved!
% The file is distributed only for people to see its examples of TeX input,
% not for use in the preparation of books like The TeXbook.
% Permission for any other use of this file must be obtained in writing
% from the copyright holder and also from the publisher (Addison-Wesley).

Aditya

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-08-27  4:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-24  0:09 \definesomething? Pepe Barbe
2006-08-26  4:16 ` \definesomething? Aditya Mahajan
2006-08-27  3:32   ` \definesomething? Pepe Barbe
2006-08-27  4:04     ` \definesomething? Mojca Miklavec
2006-08-27  4:19       ` \definesomething? Aditya Mahajan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).