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
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
On 8/25/06, Aditya Mahajan
\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
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
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
participants (3)
-
Aditya Mahajan
-
Mojca Miklavec
-
Pepe Barbe