How to not gobble space after a command
Hi all, I'm working with a few custom macros to simplify typing a bit, like: \def\VHDL{\small{VHDL}} However, when I use this macro in text, like \VHDL this, it gobbles the space after it. I've seen some references that say to solve this by writing \VHDL{} instead, but that is of course very unpretty. I've tried to put all kinds of stuff ({}, \mbox{}, \obeyedspace, etc.) inside the \VHDL macro, but it seems the space is already gone there, so that didn't work. (Note that just putting a space inside the macro won't work, for cases where I use \VHDL, like this) It seems that latex has an xspace package that does some guesswork about whether a space is required, but it looks mightily scary. Does ConTeXt provide for any way to solve this problem in a nice way? Or is this just so fundamental in TeX that there is no real solution? Gr. Matthijs
On Fri, Nov 20, 2009 at 11:23 AM, Matthijs Kooijman
Hi all,
I'm working with a few custom macros to simplify typing a bit, like:
\def\VHDL{\small{VHDL}}
However, when I use this macro in text, like \VHDL this, it gobbles the space after it. I've seen some references that say to solve this by writing \VHDL{} instead, but that is of course very unpretty. I've tried to put all kinds of stuff ({}, \mbox{}, \obeyedspace, etc.) inside the \VHDL macro, but it seems the space is already gone there, so that didn't work. (Note that just putting a space inside the macro won't work, for cases where I use \VHDL, like this)
It seems that latex has an xspace package that does some guesswork about whether a space is required, but it looks mightily scary. Does ConTeXt provide for any way to solve this problem in a nice way? Or is this just so fundamental in TeX that there is no real solution?
I don't know the answer. But I remember that a similar question time ago trigged to me to know more about \futurelet and I consider it a real gain for my own personal macro. Maybe can be the same for you. -- luigi
luigi scarso wrote:
On Fri, Nov 20, 2009 at 11:23 AM, Matthijs Kooijman
wrote: Hi all,
I'm working with a few custom macros to simplify typing a bit, like:
\def\VHDL{\small{VHDL}}
However, when I use this macro in text, like \VHDL this, it gobbles the space after it. I've seen some references that say to solve this by writing \VHDL{} instead, but that is of course very unpretty. I've tried to put all kinds of stuff ({}, \mbox{}, \obeyedspace, etc.) inside the \VHDL macro, but it seems the space is already gone there, so that didn't work. (Note that just putting a space inside the macro won't work, for cases where I use \VHDL, like this)
\autoinsertnextspace is the context version of \xspace (could be mkii only)
On Fri, Nov 20, 2009 at 11:41 AM, Matthijs Kooijman
\autoinsertnextspace is the context version of \xspace (could be mkii only) Woah, that works (in MkIV). Thanks!
hm , some problem here # context --version MTXrun | main context file: context.tex MTXrun | current version: 2009.11.10 13:30 %%% test.tex \starttext \tracingall \autoinsertnextspace\tracingnone A \stoptext #context test {undefined} ! Undefined control sequence. l.2 \tracingall \autoinsertnextspace \tracingnone # grep autoinsertnextspace * spac-gen.mkii:%D \setupsorting[logo][next=\autoinsertnextspace] \logo[TEX]{\TeX} spac-gen.mkii:\def\autoinsertnextspace{\futurelet\nexttoken\doautoinsertnextspace} spac-gen.mkii:\def\doautoinsertnextspace % slightly extended version of a user supplied macro strc-not.mkii: \c!next=\autoinsertnextspace, % new, experimental with startnotes strc-not.mkiv: \c!next=\autoinsertnextspace, % new, experimental with startnotes (note the \futurelet primitive) -- luigi
Hi Luigi,
hm , some problem here # context --version MTXrun | main context file: context.tex MTXrun | current version: 2009.11.10 13:30
Your example works fine for me on an older beta: $ context --version MTXrun | main context file: /usr/share/texmf/tex/context/base/context.tex MTXrun | current version: 2009.10.28 19:27 I'd upgrade to see if it breaks as well, but I have a document to ship today, so perhaps after that :-p Gr. Matthijs
On Fri, Nov 20, 2009 at 12:00 PM, Matthijs Kooijman
Hi Luigi,
hm , some problem here # context --version MTXrun | main context file: context.tex MTXrun | current version: 2009.11.10 13:30
Your example works fine for me on an older beta:
$ context --version MTXrun | main context file: /usr/share/texmf/tex/context/base/context.tex MTXrun | current version: 2009.10.28 19:27
I'd upgrade to see if it breaks as well, but I have a document to ship today, so perhaps after that :-p Ok (we all together cross the finger with you now :-) )
-- luigi
Hi Luigi,
hm , some problem here # context --version MTXrun | main context file: context.tex MTXrun | current version: 2009.11.10 13:30
Your example works fine for me on an older beta:
$ context --version MTXrun | main context file: /usr/share/texmf/tex/context/base/context.tex MTXrun | current version: 2009.10.28 19:27
I've just tried on a somewhat newer context which I found lying around, which does not give the error you gave (so it does know the \autoinsertnextspace command), but it doesn't work properly either (it never inserts a space AFAICT). matthijs@xanthe:~$ context --version MTXrun | main context file: /usr/share/texmf/tex/context/base/context.tex MTXrun | current version: 2009.11.24 10:13 I'll have another go with the newest version soon. Gr. Matthijs
On Mon, Nov 30, 2009 at 9:53 PM, Matthijs Kooijman
Hi Luigi,
hm , some problem here # context --version MTXrun | main context file: context.tex MTXrun | current version: 2009.11.10 13:30
Your example works fine for me on an older beta:
$ context --version MTXrun | main context file: /usr/share/texmf/tex/context/base/context.tex MTXrun | current version: 2009.10.28 19:27
I've just tried on a somewhat newer context which I found lying around, which does not give the error you gave (so it does know the \autoinsertnextspace command), but it doesn't work properly either (it never inserts a space AFAICT).
matthijs@xanthe:~$ context --version MTXrun | main context file: /usr/share/texmf/tex/context/base/context.tex MTXrun | current version: 2009.11.24 10:13
I'll have another go with the newest version soon.
Gr.
Matthijs
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAksUMOEACgkQz0nQ5oovr7wW/QCgwwSkz4uBofdezdDlWfVNLRWe MrEAoJzsKZwGtXADqSplbFVeRLopT3A4 =9QuU -----END PGP SIGNATURE-----
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
%%% test.tex \starttext \autoinsertnextspace A \stoptext #context test.tex ! Undefined control sequence. l.3 \autoinsertnextspace # context --version MTXrun | main context file: /opt/luatex/minimals-beta/tex/texmf-context/tex/context/base/context.tex MTXrun | current version: 2009.11.27 21:24 # luatex --version This is LuaTeX, Version beta-0.46.0-2009112820 It works with texexec #texexec test.tex ... Output written on test-matt.pdf (1 page, 15725 bytes). -- luigi
Hi Luigi, forget my last post. I was in a hurry last week and put a \def\autoinsertnextspace{} in my document just to get it compiling on context 2009.11.24. If I remove that, it stops working with "texexec --lua" (as well as just "context") with the same undefined control sequence error. It still works with just "texexec" (e.g., with MkII). So, it works for me with 2009.10.28, and gives errors with 2009.11.24. There is no version where it silently fails, that was my own fault :-) Actually, it does in fact seem the macro has completely disappeared. With the old version: /usr/share/texmf/tex/context/base$ grep def.autoinsertnextspace * spac-gen.mkii:\def\autoinsertnextspace{\futurelet\nexttoken\doautoinsertnextspace} spac-hor.mkiv:\def\autoinsertnextspace{\futurelet\nexttoken\doautoinsertnextspace} With the new version: /usr/share/texmf/tex/context/base$ grep def.autoinsertnextspace * spac-gen.mkii:\def\autoinsertnextspace{\futurelet\nexttoken\doautoinsertnextspace} The comment in the old version does say: %D This is a dangerous feature because it makes the \TEX\ source %D less portable, i.e. any parser now needs to apply exactly the %D same algorithm when it wants to interpret the source. We %D strongly recommend not to mention this feature in manuals! It's %D provided for users who are hooked to such a mechanism. So perhaps this is removed intentionally? Perhaps Hans can comment? Gr. Matthijs
Matthijs Kooijman wrote:
Hi Luigi,
forget my last post. I was in a hurry last week and put a
\def\autoinsertnextspace{}
in my document just to get it compiling on context 2009.11.24. If I remove that, it stops working with "texexec --lua" (as well as just "context") with the same undefined control sequence error. It still works with just "texexec" (e.g., with MkII).
So, it works for me with 2009.10.28, and gives errors with 2009.11.24. There is no version where it silently fails, that was my own fault :-)
Actually, it does in fact seem the macro has completely disappeared. With the old version:
/usr/share/texmf/tex/context/base$ grep def.autoinsertnextspace * spac-gen.mkii:\def\autoinsertnextspace{\futurelet\nexttoken\doautoinsertnextspace} spac-hor.mkiv:\def\autoinsertnextspace{\futurelet\nexttoken\doautoinsertnextspace}
With the new version:
/usr/share/texmf/tex/context/base$ grep def.autoinsertnextspace * spac-gen.mkii:\def\autoinsertnextspace{\futurelet\nexttoken\doautoinsertnextspace}
The comment in the old version does say:
%D This is a dangerous feature because it makes the \TEX\ source %D less portable, i.e. any parser now needs to apply exactly the %D same algorithm when it wants to interpret the source. We %D strongly recommend not to mention this feature in manuals! It's %D provided for users who are hooked to such a mechanism.
So perhaps this is removed intentionally? Perhaps Hans can comment?
indeed, it's a kind of hack and if we need something like that i'll make a better version some day ... configureable and using unicode char properties i'll remove the call in mkiv Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On Tue, Dec 1, 2009 at 12:14 AM, Hans Hagen
indeed, it's a kind of hack and if we need something like that i'll make a better version some day ... configureable and using unicode char properties
i'll remove the call in mkiv There is no \autoinsertnextspace in mkiv
-- luigi
luigi scarso wrote:
On Tue, Dec 1, 2009 at 12:14 AM, Hans Hagen
wrote: indeed, it's a kind of hack and if we need something like that i'll make a better version some day ... configureable and using unicode char properties
i'll remove the call in mkiv There is no \autoinsertnextspace in mkiv
there was a \c!next=\autoinsertnextspace ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On Friday 20 November 2009 11:41:16 Matthijs Kooijman wrote:
\autoinsertnextspace is the context version of \xspace (could be mkii only)
Woah, that works (in MkIV). Thanks!
*Everywhere* the authors use \CONTEXT\ and \TeX\ followed by an escaped space. (Is this space [sometimes] unbreakable?) In my own texts, I often use {\TeX} as I find this not (too) ugly. Also, I tend to make less mistakes with this method (since it is very easy to forget the trailing backslash). If \autoinsertnextspace is the right solution, perhaps this could be included in the standard definitions in cont-log.tex. Alan
participants (5)
-
Alan BRASLAU
-
Hans Hagen
-
luigi scarso
-
Matthijs Kooijman
-
Taco Hoekwater