Re: [NTG-context] \autoinsertedspace fails
On 1/6/2023 3:05 AM, Rik Kabel via ntg-context wrote: On 2023-01-05 04:35, Hans Hagen via ntg-context wrote: On 1/5/2023 4:21 AM, Rik Kabel via ntg-context wrote: [ snipped by rik] Here is a more lmtx-ish variant: \starttexdefinition tolerant protected BD #=#*#= \removeunwantedspaces \space % insert a space ( \ifparameter#2\or #1|–|#2 \orelse\ifparameter#1\or #1– \else {\red I NEED A DATE OR DATES!} \fi ) \autoinsertedspace \stoptexdefinition Hans Thank you for that. This works for me with \optionalspace, but fails in some cases with \autoinsertedspace. I have now re-read lowlevel-macros.pdf and have a better understanding of what I read when first I approached it; I still have a way to go. /Tolerant/ removes the need for /dodoubleempty/ and friends and the two-step /macro/ and /doMacro/ dance. There was a small advantage to the two-step, however. I had two separate macros, BD and BDNP (no parens), as shown. The old code in full was: % Birth and death dates ---% % Ferdinand de Saussure\BD{1857}{1913} % Noam Chomsky \BD{1928} % % Perhaps this could be tied to an acronym-like database so that the % dates are printed only once per person. % \removeunwantedspaces allows this to directly follow, or follow % after whitespace, the associated name: Name\BD{1}{2} or % Name \BD{1}{2}. % Using the compound indication (|–|) allows hyphenation after the % endash. Omitting it and using a bare endash inhibits hyphenation % ‘twixt the endash and the paren. % By default, add parens around the dates. If none are needed due to % the context, use \BDNP. % \newif\ifBDParen \starttexdefinition unexpanded BD \BDParentrue \dodoublegroupempty \doBD \stoptexdefinition \starttexdefinition unexpanded BDNP \BDParenfalse \dodoublegroupempty \doBD \stoptexdefinition \starttexdefinition doBD #1#2 \removeunwantedspaces\ \ifBDParen(\fi \ifsecondargument #1|–|#2 \else\iffirstargument #1– \else {\red I NEED A DATE OR DATES!} \fi\fi \ifBDParen)\fi \autoinsertedspace \stoptexdefinition Both call the same doBD, but they set a flag (newif) to control insertion or not of the parens. While there is no performance benefit compared to having two fully separate macros, there is a maintenance benefit in having only one place, doBD, to make changes should they be required. Can you suggest a way to do this under the new one-step scheme, or am I over-thinking this? just remove the #* in the example i sent, \starttexdefinition tolerant protected BD #=#= Hans - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] \autoinsertedspace fails
On 2023-01-05 04:35, Hans Hagen via ntg-context wrote: On 1/5/2023 4:21 AM, Rik Kabel via ntg-context wrote: [ snipped by rik] Here is a more lmtx-ish variant: \starttexdefinition tolerant protected BD #=#*#= \removeunwantedspaces \space % insert a space ( \ifparameter#2\or #1|–|#2 \orelse\ifparameter#1\or #1– \else {\red I NEED A DATE OR DATES!} \fi ) \autoinsertedspace \stoptexdefinition Hans Thank you for that. This works for me with \optionalspace, but fails in some cases with \autoinsertedspace. I have now re-read lowlevel-macros.pdf and have a better understanding of what I read when first I approached it; I still have a way to go. /Tolerant/ removes the need for /dodoubleempty/ and friends and the two-step /macro/ and /doMacro/ dance. There was a small advantage to the two-step, however. I had two separate macros, BD and BDNP (no parens), as shown. The old code in full was: % Birth and death dates ---% % Ferdinand de Saussure\BD{1857}{1913} % Noam Chomsky \BD{1928} % % Perhaps this could be tied to an acronym-like database so that the % dates are printed only once per person. % \removeunwantedspaces allows this to directly follow, or follow % after whitespace, the associated name: Name\BD{1}{2} or % Name \BD{1}{2}. % Using the compound indication (|–|) allows hyphenation after the % endash. Omitting it and using a bare endash inhibits hyphenation % ‘twixt the endash and the paren. % By default, add parens around the dates. If none are needed due to % the context, use \BDNP. % \newif\ifBDParen \starttexdefinition unexpanded BD \BDParentrue \dodoublegroupempty \doBD \stoptexdefinition \starttexdefinition unexpanded BDNP \BDParenfalse \dodoublegroupempty \doBD \stoptexdefinition \starttexdefinition doBD #1#2 \removeunwantedspaces\ \ifBDParen(\fi \ifsecondargument #1|–|#2 \else\iffirstargument #1– \else {\red I NEED A DATE OR DATES!} \fi\fi \ifBDParen)\fi \autoinsertedspace \stoptexdefinition Both call the same doBD, but they set a flag (newif) to control insertion or not of the parens. While there is no performance benefit compared to having two fully separate macros, there is a maintenance benefit in having only one place, doBD, to make changes should they be required. Can you suggest a way to do this under the new one-step scheme, or am I over-thinking this? Finally, is there any reason to go back to previously written and properly functioning macros and convert them to the LMTX-only syntax? It does imply committing to LMTX-only (or -- Rik ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] \autoinsertedspace fails
No change with the latest (2023.01.04). Is this a problem with what I am doing, or a bug? -- Rik On 2022-12-29 19:12, Rik Kabel via ntg-context wrote: Happy New Year all! Following up on the problem with \autoinsertnextspace (https://mailman.ntg.nl/pipermail/ntg-context/2022/107111.html) and the new \autoinsertedspace that came from that report, I see that there is still a problem, or perhaps a problem again after it was previously repaired. The following code, run under the latest (and recent previous) version, produces an incorrect result, with no space inserted where expected in many cases. As the first examples after \starttext show, the problem appears to be with \autoinsertedspace, but perhaps I am using it incorrectly in the macro as well. \starttexdefinition unexpanded BD \dodoublegroupempty \doBD \stoptexdefinition \starttexdefinition doBD #1#2 \removeunwantedspaces\ % insert a space ( \ifsecondargument #1|–|#2 \else\iffirstargument #1– \else {\red I NEED A DATE OR DATES!} \fi\fi ) \autoinsertedspace \stoptexdefinition \tt \starttext This\autoinsertedspace fails unexpectedly with autoinsertedspace.\par This\autoinsertedspace \emph{fails unexpectedly} with autoinsertedspace.\par This\autoinsertnextspace works with autoinsertnextspace.\par This\autoinsertnextspace \emph{fails} as expected with autoinsertnextspace.\par Saussure\BD{1857}{1913} works.\par Saussure \BD{1857}{1913} \emph{works}.\par Saussure \BD{1857}{1913}. Works.\par Chomsky\BD{1928} fails with LMTX, works with MkIV.\par Chomsky \BD{1928} \emph{fails with LMTX, works with MkIV}.\par Chomsky \BD{1928}. Works.\par \BD blah\par \contextversion\ \texenginename \stoptext -- Rik ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist :ntg-context@ntg.nl /https://www.ntg.nl/mailman/listinfo/ntg-context webpage :https://www.pragma-ade.nl /http://context.aanhet.net archive :https://bitbucket.org/phg/context-mirror/commits/ wiki :https://contextgarden.net __ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
[NTG-context] \autoinsertedspace fails
Happy New Year all! Following up on the problem with \autoinsertnextspace (https://mailman.ntg.nl/pipermail/ntg-context/2022/107111.html) and the new \autoinsertedspace that came from that report, I see that there is still a problem, or perhaps a problem again after it was previously repaired. The following code, run under the latest (and recent previous) version, produces an incorrect result, with no space inserted where expected in many cases. As the first examples after \starttext show, the problem appears to be with \autoinsertedspace, but perhaps I am using it incorrectly in the macro as well. \starttexdefinition unexpanded BD \dodoublegroupempty \doBD \stoptexdefinition \starttexdefinition doBD #1#2 \removeunwantedspaces\ % insert a space ( \ifsecondargument #1|–|#2 \else\iffirstargument #1– \else {\red I NEED A DATE OR DATES!} \fi\fi ) \autoinsertedspace \stoptexdefinition \tt \starttext This\autoinsertedspace fails unexpectedly with autoinsertedspace.\par This\autoinsertedspace \emph{fails unexpectedly} with autoinsertedspace.\par This\autoinsertnextspace works with autoinsertnextspace.\par This\autoinsertnextspace \emph{fails} as expected with autoinsertnextspace.\par Saussure\BD{1857}{1913} works.\par Saussure \BD{1857}{1913} \emph{works}.\par Saussure \BD{1857}{1913}. Works.\par Chomsky\BD{1928} fails with LMTX, works with MkIV.\par Chomsky \BD{1928} \emph{fails with LMTX, works with MkIV}.\par Chomsky \BD{1928}. Works.\par \BD blah\par \contextversion\ \texenginename \stoptext -- Rik ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
[NTG-context] \autoinsertedspace fails following \nbsp under LMTX
ConTeXt ver: 2022.11.14 22:58 LMTX on W11 x64 I have been testing the recently added \autoinsertedspace, and I found an odd failure. The following compiles with \nbsp commented as shown, but once that line is active, the compilation fails: lua error: callback error: ...MTX/tex/texmf-context/tex/context/base/mkxl/font-hsh.lmt:151: table index is nil It fails differently in MkIV (but it is nice to see that the new command has been backported): luatex warning > node filter: error: ...MTX/tex/texmf-context/tex/context/base/mkiv/node-nut.lua:380: Attempt to node.direct.remove() a non-existing node %<-- \starttexdefinition unexpanded New \dodoublegroupempty \doNew \stoptexdefinition \starttexdefinition doNew #1#2 \removeunwantedspaces \ (#1|–|#2) \autoinsertedspace \stoptexdefinition \starttext ABC 0\New{123}{456} 789 ABC % \nbsp 0\New{123}{456} 789 \stoptext Am I doing something wrong here? \nbsp is needed to prevent improper line breaks. -- Rik ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] simplifying repeated macro calls in metafun
On 6/24/2021 5:42 AM, Aditya Mahajan wrote: On Wed, 23 Jun 2021, Aditya Mahajan wrote: On Thu, 24 Jun 2021, Jeong Dal wrote: Now, I am trying to do the same thing using \startuseMPgraphic, but I don’t the correct result yet. Using \startuseMPgraphic, and \dorecurse, the code is simpler. But, it seems to me that \startanimation … \stopanimation is not working with \dorecurse{}{} … It just list all the graphics. Any hint is welcome. A while back, I wrote some code to easily generate metapost animations. https://adityam.github.io/context-blog/post/metapost-animation/ I haven't used it much because I am mostly on linux, and its is a PITA to get an older version of Adobe Reader to work under wine. Here's a version using these macros. It runs with MkIV but not with LMTX. Sorry, no time to debug what's going wrong in LMTX right now. mp variable handling in lmtx is a bit more sophisticated when we pass colors, numerics, dimensions there is some guess work going on wrt the type of the variable and on the average that works ok but in lmtx we can also fetch variables so here is a basic setup for you (not much animation but it shows the idea \unprotect % this is similar to mkiv, although we add protection against % overload; i should still use the new argument handling here \permanent\protected\def\startMPanimation {\dodoublegroupempty\meta_start_animation} \permanent\protected\lettonothing\stopMPanimation \def\meta_start_animation#1% {\normalexpanded{\meta_start_animation_indeed{#1}}} \permanent\protected\def\meta_start_animation_indeed#1#2#3\stopMPanimation {\gdefcsname\??mpgraphic#1\endcsname{\meta_handle_use_graphic{#1}{#2}{#3}}} % this one is like yours too but it has more wrapping inside % wrt namespace, picking up variables etc; as you can see, % we just operate in the normal mp related variable namespace \permanent\tolerant\protected\def\useMPanimation#=#*#=% {\meta_begin_graphic_group{#1}% \checkmpcategoryparent \let\currentmpcategory\currentMPgraphicname \setupcurrentmpcategory[#2]% \dorecurse{\mpcategoryparameter{n}}{% \letmpcategoryparameter{i}\recurselevel \begincsname\??mpgraphic#1\endcsname\empty }% \meta_end_graphic_group} % so, the main thing here is that we added the loop and % for convenience i store the current step \protect \starttext \setupMPvariables [animation] [n=4] % watch how we *pick up* a variable, no expansion mess, we % avoid heuristics, it might even be faster (not that it % matters because tex is already pretty fast) \startMPanimation{circle} fill fullcircle scaled (10cm / mpvarn("i")); \stopMPanimation % there currently are mpvarn, mpvard, mpvars, mpvarb \useMPanimation{circle}{n=4} \stoptext - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl - ___ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] about \startMPanimation
Dear Hans, Thank you for the clear explanation. I thought “” is appeared because of the font problem in my system. I did something wrong when I run the sample code, which didn’t work. Yes, it is working well in my code now. It makes the procedure of creating animation simpler. Thank you and thanks Wolfgang! Best regards, Dalyoung > 2019. 5. 13. 오후 10:04, Hans Hagen 작성: > > On 5/13/2019 2:14 PM, Jeong Dal wrote: >> Dear Wolfgang, >> I found the following code with a comment “code by Wolfgang” at >> https://adityam.github.io/context-blog/post/metapost-animation/ >> |\unprotect| >> |\installnamespace{MPanimationvariables}\unexpanded\def\startMPanimation{\dodoublegroupempty\meta_start_animation} >> >> \def\meta_start_animation#1%{\normalexpanded{\meta_start_animation_indeed{#1}}} >> >> \unexpanded\def\meta_start_animation_indeed#1#2#3\stopMPanimation{\doifsomething{#2}{\getparameters[\MPanimationvariables#1:][#2]}%\setgvalue{\??mpgraphic >> >> animation:#1}{\meta_handle_use_graphic{#1}{n,t}{#3}}}\let\stopMPanimation\relax\unexpanded\def\useMPanimation%{\dosingleargument\use_meta_animation}\def\use_meta_animation[#1]#2%{\edef\c_MP_animation_frames{\getvalue{\MPanimationvariables#2:n}}%\startanimation[#1]\dorecurse{\c_MP_animation_frames}{\expanded{\frame{\useMPgraphic{animation:#2}{n=\c_MP_animation_frames,t=\recurselevel\stopanimation}\protect| >> In the code, there are many “”.(\MPanimationvariables#1, >> {\??mpgraphic animation:#1}) >> I wonder it is correct or not. >> Would you please check it? > these ?? etc indicate (protected) namespaces so it's correct > > Hans > > > > - > Hans Hagen | PRAGMA ADE > Ridderstraat 27 | 8061 GH Hasselt | The Netherlands > tel: 038 477 53 69 | www.pragma-ade.nl <http://www.pragma-ade.nl/> | > www.pragma-pod.nl <http://www.pragma-pod.nl/> > - ___ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] about \startMPanimation
On 5/13/2019 2:14 PM, Jeong Dal wrote: Dear Wolfgang, I found the following code with a comment “code by Wolfgang” at https://adityam.github.io/context-blog/post/metapost-animation/ |\unprotect| |\installnamespace{MPanimationvariables}\unexpanded\def\startMPanimation{\dodoublegroupempty\meta_start_animation} \def\meta_start_animation#1%{\normalexpanded{\meta_start_animation_indeed{#1}}} \unexpanded\def\meta_start_animation_indeed#1#2#3\stopMPanimation{\doifsomething{#2}{\getparameters[\MPanimationvariables#1:][#2]}%\setgvalue{\??mpgraphic animation:#1}{\meta_handle_use_graphic{#1}{n,t}{#3}}}\let\stopMPanimation\relax\unexpanded\def\useMPanimation%{\dosingleargument\use_meta_animation}\def\use_meta_animation[#1]#2%{\edef\c_MP_animation_frames{\getvalue{\MPanimationvariables#2:n}}%\startanimation[#1]\dorecurse{\c_MP_animation_frames}{\expanded{\frame{\useMPgraphic{animation:#2}{n=\c_MP_animation_frames,t=\recurselevel\stopanimation}\protect| In the code, there are many “”.(\MPanimationvariables#1, {\??mpgraphic animation:#1}) I wonder it is correct or not. Would you please check it? these ?? etc indicate (protected) namespaces so it's correct Hans - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl - ___ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] about \startMPanimation
Dear Wolfgang, I found the following code with a comment “code by Wolfgang” at https://adityam.github.io/context-blog/post/metapost-animation/ <https://adityam.github.io/context-blog/post/metapost-animation/> \unprotect \installnamespace{MPanimationvariables} \unexpanded\def\startMPanimation {\dodoublegroupempty\meta_start_animation} \def\meta_start_animation#1% {\normalexpanded{\meta_start_animation_indeed{#1}}} \unexpanded\def\meta_start_animation_indeed#1#2#3\stopMPanimation {\doifsomething{#2}{\getparameters[\MPanimationvariables#1:][#2]}% \setgvalue{\??mpgraphic animation:#1}{\meta_handle_use_graphic{#1}{n,t}{#3}}} \let\stopMPanimation\relax \unexpanded\def\useMPanimation% {\dosingleargument\use_meta_animation} \def\use_meta_animation[#1]#2% {\edef\c_MP_animation_frames{\getvalue{\MPanimationvariables#2:n}}% \startanimation[#1] \dorecurse{\c_MP_animation_frames} {\expanded{\frame{\useMPgraphic{animation:#2}{n=\c_MP_animation_frames,t=\recurselevel \stopanimation} \protect In the code, there are many “”.(\MPanimationvariables#1, {\??mpgraphic animation:#1}) I wonder it is correct or not. Would you please check it? Best regards, Dalyoung ___ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Conditional float references
On 23 Sep 2013, at 09:57 , Marco Patzer li...@homerow.info wrote: Subject: [NTG-context] Conditional float references a couple of times the question came up??? how to create more intelligent referencing. [….] I don't know if there's interest in integrating such functionality into the core. I attached some code, a new macro \smartref, which takes the same arguments as \in. Hi Marco, I would be very interested in being able to use this macro, integrated or not, since in my project there are numerous figures with lots of references to them throughout the entire text, and \at{page}[] is not satisfactory for me. I tried the code you supplied by pasting the whole lot into a TeXShop-file, and, when that did not work, in Alphax, processing the latter from Terminal, but in both cases I received an error message that I do not know what to do with. Strangely enough it complains about an error in line 1 even if that contains a commented out comment. I reproduce the error message here, hoping that you, or somebody elsm, can see what I did wrong. (I apologize on behalf of TeXShop and Alhax for the length of this message.) Thanks in advance for any help. Robert Blackstone Error message: Last login: Tue Sep 24 09:02:03 on ttys000 sh: /Users/robertblackstone/context/tex/setuptex: No such file or directory iMac-Bergen-R-5:context-minimal-24-09 robertblackstone$ . /Users/robertblackstone/context-minimal-24-09/tex/setuptex Setting /Users/robertblackstone/context-minimal-24-09/tex as ConTeXt root. iMac-Bergen-R-5:context-minimal-24-09 robertblackstone$ context /Users/robertblackstone/Dropbox/C-tests/Referencing-Smart_referencing/Referencing-Smart_referencing-test1.tex mtx-context | run 1: luatex --fmt=/Users/robertblackstone/context-minimal-24-09/tex/texmf-cache/luatex-cache/context/5fe67e0bfe781ce0dde776fb1556f32e/formats/luatex/cont-en --jobname=Referencing-Smart_referencing-test1 --lua=/Users/robertblackstone/context-minimal-24-09/tex/texmf-cache/luatex-cache/context/5fe67e0bfe781ce0dde776fb1556f32e/formats/luatex/cont-en.lui --no-parse-first-line --c:currentrun=1 --c:fulljobname=/Users/robertblackstone/Dropbox/C-tests/Referencing-Smart_referencing/Referencing-Smart_referencing-test1.tex --c:input=/Users/robertblackstone/Dropbox/C-tests/Referencing-Smart_referencing/Referencing-Smart_referencing-test1.tex --c:kindofrun=1 --c:maxnofruns=8 cont-yes.mkiv This is LuaTeX, Version beta-0.76.0-2013040508 (rev 4627) \write18 enabled. (/Users/robertblackstone/context-minimal-24-09/tex/texmf-context/tex/context/base/cont-yes.mkiv ConTeXt ver: 2013.09.21 13:53 MKIV beta fmt: 2013.9.24 int: english/english system 'cont-new.mkiv' loaded (/Users/robertblackstone/context-minimal-24-09/tex/texmf-context/tex/context/base/cont-new.mkiv) system files jobname 'Referencing-Smart_referencing-test1', input '/Users/robertblackstone/Dropbox/C-tests/Referencing-Smart_referencing/Referencing-Smart_referencing-test1', result 'Referencing-Smart_referencing-test1' fontslatin modern fonts are not preloaded languageslanguage 'en' is active (/Users/robertblackstone/Dropbox/C-tests/Referencing-Smart_referencing/Referencing-Smart_referencing-test1.tex ! Parameters must be numbered consecutively. system tex error on line 1 in file /Users/robertblackstone/Dropbox/C-tests/Referencing-Smart_referencing/Referencing-Smart_referencing-test1.tex: Parameters must be numbered consecutively ... 1 \unprotect 2 \unexpanded\def\strc_references_smart 3 {\strc_references_start_goto 4 \let\currentreferencecontent\currentreferencedefault 5 \strc_references_pickup_smart_goto} 6 \def\strc_references_pickup_smart_goto 7 {\dodoublegroupempty\strc_references_pickup_goto_smart_indeed} 8 \starttexdefinition strc_references_pickup_goto_smart_indeed #left#right#dummy[#label] 9 \leftreferencetoks 10 \iffirstargument 11 {#left} to be read again l l.1 ...ferences_pickup_goto_smart_indeed\endcsname#l eft#right#dummy[#label] \ctxcommand #1i-\directlua {commands.#1} \syst_helpers_start_tex_definition_two ...n(#1)} {#2} l.32 \stoptexdefinition ? ___ 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 ___
[NTG-context] Conditional float references
Hi, a couple of times the question came up¹²³ how to create more intelligent referencing. There are already mechanisms in the core, namely \somewhere and \atpage but they both have drawbacks. \somewhere happily prints its text if the figure is placed on the same double page. In fact, no text at all should be printed if the figure is visible. Furthermore it's a little verbose to use unless hidden in a custom macro. \atpage on the other hand doesn't hesitate to print “see figure 1.2 at page 42” while you're on page 42. I'm aware that automatic generation of reference text is problematic since the text depends on the placement of floats which in turn depends on the text which might result in oscillation. I'm not sure how likely this is to occur in practice. I don't know if there's interest in integrating such functionality into the core. I attached some code, a new macro \smartref, which takes the same arguments as \in. \smartref{figure}[fig:somefigure] - it prints the reference if it is on the same page (e.g. Figure 1.2) - it prints the reference and a customizable text if the reference is on the next/previous page (e.g. Figure 1.2 on the previous page) - it prints the reference and the page if the reference is further away than one page (e.g. Figure 1.2 on page 42) - it adapts to single-sided and double-sided layouts Marco ¹ http://thread.gmane.org/gmane.comp.tex.context/65295 ² http://thread.gmane.org/gmane.comp.tex.context/59455 ³ http://thread.gmane.org/gmane.comp.tex.context/76001 \unprotect \unexpanded\def\strc_references_smart {\strc_references_start_goto \let\currentreferencecontent\currentreferencedefault \strc_references_pickup_smart_goto} \def\strc_references_pickup_smart_goto {\dodoublegroupempty\strc_references_pickup_goto_smart_indeed} \starttexdefinition strc_references_pickup_goto_smart_indeed #left#right#dummy[#label] \leftreferencetoks \iffirstargument {#left} \else \defaultleftreferencetoks \let\leftofreferencecontent\empty \fi \rightreferencetoks \ifsecondargument {#right} \else \defaultrightreferencetoks \let\rightofreferencecontent\empty \fi \doifreferencefoundelse{#label} {\goto{\referencesequence}[#label] \strc_references_check_visibility \ifreferenceisvisible\else \space\strc_references_smart_string \fi} {\let\currentreferencecontent\dummyreference \goto{\referencesequence}[#label]} \strc_references_stop_goto \stoptexdefinition \newif\ifreferenceisvisible \referenceisvisiblefalse \starttexdefinition strc_references_check_visibility \def\strc_references_smart_string{\labeltext\v!atpage\currentreferencepage} \referenceisvisiblefalse \ifnum\referencepagestate=\plusone %% 1 = reference on current page \referenceisvisibletrue \else \ifsinglesided \strc_references_do_relative_else\plusone {\def\strc_references_smart_string{\labeltext\v!nextpage}} {\strc_references_do_relative\minusone {\def\strc_references_smart_string{\labeltext\v!previouspage}}{}} \else \ifodd\realpageno \strc_references_do_relative_else\minusone {\def\strc_references_smart_string{\labeltext\v!previouspage} \referenceisvisibletrue} {\strc_references_do_relative_else\plusone {\def\strc_references_smart_string{\labeltext\v!nextpage}}{}} \else \strc_references_do_relative_else\minusone {\def\strc_references_smart_string{\labeltext\v!previouspage}} {\strc_references_do_relative_else\plusone \referenceisvisibletrue{}} \fi \fi \fi \stoptexdefinition \starttexdefinition strc_references_do_relative_else #relativepagenumber \ifnum\currentreferencerealpage=\numexpr\realpageno+#relativepagenumber\relax \expandafter\firstoftwoarguments \else \expandafter\secondoftwoarguments \fi \stoptexdefinition \let\smartref\strc_references_smart \startinterface all \setinterfacevariable {previouspage} {previouspage} \setinterfacevariable {nextpage} {nextpage} \stopinterface \setuplabeltext [\s!en] [\v!atpage=on page\nobreakspace, %% “at page” sounds weird \v!previouspage=on the previous page, \v!nextpage=on the next page] \protect \useMPlibrary [dum] \setuppagenumbering [alternative=doublesided] \starttext See \smartref{figure}[fig:alpha] and \smartref{figure}[fig:gamma]. \page See \smartref{figure}[fig:alpha] and \smartref{figure}[fig:gamma]. \startplacefigure [reference=fig:alpha] \externalfigure \stopplacefigure \startplacefigure [reference=fig:beta] \externalfigure \stopplacefigure \page See \smartref{figure}[fig:alpha] and \smartref{figure}[fig:gamma]. \startplacefigure [reference=fig:gamma] \externalfigure \stopplacefigure \startplacefigure [reference=fig:delta] \externalfigure \stopplacefigure \page See \smartref{figure}[fig:alpha] and \smartref{figure}[fig:gamma]. \page See \smartref{figure}[fig:alpha
Re: [NTG-context] Referring to multiple elements
2012-09-28 Sietse Brouwer sbbrou...@gmail.com: Hi Sietse, \in{figure}[alpha,beta,gamma] This outputs “figure 1”. What I'd like to have is “figure 1-3”. The attached quasi-module seems to do it! On my computer, at least. (I call it 'quasi' because it is really nothing more than code in a file of its own.No configurability whatsoever, except to the extent that I tried to comment well, and split things up into functions.) I'd have written it so that it properly identifies runs like '1.2.1, 1.2.2, 1.2.3', too, but I can't find a function that will turn reference strings into such a prefixed strings. I hope it does what you want! Let me know if you want/need any alterations, or discover bugs. Thanks a lot for that. I'd adjust the interface, so that it matches the behaviour of \in: \def\inrange {\dodoublegroupempty\doinrange} \def\doinrange#left#right#dummy[#label] {\iffirstargument {#left }%% \fi \ctxlua{userdata.inwithranges(#label)}%% \ifsecondargument {#right}%% \fi} Then you can write: See \inrange{figures} [fig:a,fig:c,fig:d,fig:e,fig:g,fig:x,fig:h] See \inrange{figures}{TT} [fig:a,fig:c,fig:d,fig:e,fig:g,fig:x,fig:h] See \inrange [fig:a,fig:c,fig:d,fig:e,fig:g,fig:x,fig:h] Maybe worth mentioning: You need the additional module `showtable.lua` from http://article.gmane.org/gmane.comp.tex.context/78336 Marco ___ 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 ___
Re: [NTG-context] prevent gobbling of spaces when omitting optional argument
Am 28.01.2011 um 23:24 schrieb Florian Wobbe: Hi, please consider the following minimal example: \def\before{\dodoubleempty\dobefore}% \def\dobefore[#1][#2]{before} \starttext \before[] after (should be: \before[]\ after without explicit \type{\ })\par \before[]after\par \before[][] after\par % this works \before[][]after\par \stoptext How can I prevent gobbling the following space, when the second optional argument is not given (i.e. first line). The macro itself should not insert space if the command is followed by any other character (2nd and 4th line). What do you want to achieve, maybe there is already something available. % \one, \one[…] and \one[…][…] (no spaces between “[][]” allowed) \def\one {\strictdoifnextoptionalelse\doone\noone} \def\noone{[]} \def\doone[#1]% {\strictdoifnextoptionalelse{\dodoone[#1]}{\nodoone[#1]}} \def\dodoone[#1][#2]% {[#1:#2]} \def\nodoone[#1]% {[#1]} % \two, \two{…} and \two{…} (no spaces between “{}{}” allowed) \def\two {\dodoublegroupempty\dotwo} \def\dotwo#1#2% {\ifsecondargument [#1:#2]% \else\iffirstargument [#1]% \else []% \fi\fi} \starttext \startlines \one text \one[1] text \one[1][2] text \two text \two{1} text \two{1}{2} text \stoplines \stoptext Wolfgang ___ 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 ___
Re: [NTG-context] Using defaults and indexes
Am 21.01.2009 um 16:02 schrieb Cecil Westerhof: And in the main file I have: \letterclosing{Hoogachtend}{Cecil Westerhof} But I would like to have this as the default, so I could use: \letterclosing Beside that I would like to have the possibility to use: \letterclosing{business} or \letterclosing{family} This would then use defined values. When the first parameter is filled, but not with a recognized value, then the second parameter should be filled. If not, the compilation of the file should generate an error. Is this something that can be done? \long\def\letterbody#1% {{\blank[line]\setupindenting[yes,medium]#1\par}} \def\letterclosing {\dodoublegroupempty\doletterclosing} \def\doletterclosing#1#2% {\ifsecondargument \dodoletterclosing{#1}{#2}% \else \doifelsenothing{#1} {\doletterclosing{Hoogachtend,}{Cecil Westerhof}}% {\processaction [#1] [ family={\dodoletterclosing{Informal closing,}{Cecil Westerhof}}, business={\dodoletterclosing{Formal closing}{Cecil Westerhof}}, unknown={\errorisfataltrue\waitonfatalerror}]}% \fi} \def\dodoletterclosing#1#2% {\blank[line]#1\blank[3*line]#2} \setupindenting[yes,none] \starttext \letterbody{\dorecurse{2}{\input knuth\par}} \letterclosing{Hoogachtend,}{Cecil Westerhof} \page \letterbody{\dorecurse{2}{\input knuth\par}} \letterclosing{family} \page \letterbody{\dorecurse{2}{\input knuth\par}} \letterclosing{business} \page \letterbody{\dorecurse{2}{\input knuth\par}} \letterclosing{unknown} \stoptext Wolfgang ___ 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 : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Using defaults and indexes
2009/1/21 Wolfgang Schuster schuster.wolfg...@googlemail.com: And in the main file I have: \letterclosing{Hoogachtend}{Cecil Westerhof} But I would like to have this as the default, so I could use: \letterclosing Beside that I would like to have the possibility to use: \letterclosing{business} or \letterclosing{family} This would then use defined values. When the first parameter is filled, but not with a recognized value, then the second parameter should be filled. If not, the compilation of the file should generate an error. Is this something that can be done? \long\def\letterbody#1% {{\blank[line]\setupindenting[yes,medium]#1\par}} \def\letterclosing {\dodoublegroupempty\doletterclosing} \def\doletterclosing#1#2% {\ifsecondargument \dodoletterclosing{#1}{#2}% \else \doifelsenothing{#1} {\doletterclosing{Hoogachtend,}{Cecil Westerhof}}% {\processaction [#1] [ family={\dodoletterclosing{Informal closing,}{Cecil Westerhof}}, business={\dodoletterclosing{Formal closing}{Cecil Westerhof}}, unknown={\errorisfataltrue\waitonfatalerror}]}% \fi} \def\dodoletterclosing#1#2% {\blank[line]#1\blank[3*line]#2} \setupindenting[yes,none] \starttext \letterbody{\dorecurse{2}{\input knuth\par}} \letterclosing{Hoogachtend,}{Cecil Westerhof} \page \letterbody{\dorecurse{2}{\input knuth\par}} \letterclosing{family} \page \letterbody{\dorecurse{2}{\input knuth\par}} \letterclosing{business} \page \letterbody{\dorecurse{2}{\input knuth\par}} \letterclosing{unknown} \stoptext Goes a long way. With two parameters it works. When using 'unknown' or 'dummy', I get \wait= messages. When giving enter, the document is still generated. But that is not a real problem. But when using: \letterclosing or \letterclosing{} I get the same wait= message and there is no letterclosing generated (or an empty one). Found the problem. \doifelsenothing{#1} {\doletterclosing{Hoogachtend,}{Cecil Westerhof}}% should be: \doifelsenothing{#1} {\doletterclosing{Hoogachtend,}{Cecil Westerhof}}% Now it seems to do what I want. -- Cecil Westerhof ___ 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 : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Using defaults and indexes
Am 21.01.2009 um 19:28 schrieb Cecil Westerhof: 2009/1/21 Wolfgang Schuster schuster.wolfg...@googlemail.com: When the first parameter is filled, but not with a recognized value, then the second parameter should be filled. If not, the compilation of the file should generate an error. I did only what you wrote. I was not clear enough again. What I mend was that when there is not a recognized value, then the output file should not be generated. When you give a return the file is still generated. But that is only a minor. (Maybe what I want is not possible.) \long\def\letterbody#1% {\def\@@letterbody{{\blank[line]\setupindenting[yes,medium]#1\par}}} \def\letterclosing {\dodoublegroupempty\doletterclosing} \def\doletterclosing#1#2% {\ifsecondargument \dodoletterclosing{#1}{#2}% \else \doifelsenothing{#1} {\dodoletterclosing{Hoogachtend,}{Cecil Westerhof}}% {\processaction [#1] [ family={\dodoletterclosing{Informal closing,}{Cecil Westerhof}}, business={\dodoletterclosing{Formal closing}{Cecil Westerhof}}, unknown={\message{Warning: Wrong keyword for \string \letterclosing.}}]}% \fi} \def\dodoletterclosing#1#2% {\@@letterbody \blank[line]#1\blank[3*line]#2} \starttext \letterbody{\dorecurse{2}{\input knuth\par}} \letterclosing{unknown} \stoptext Best wishes Wolfgang ___ 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 : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] description fails on \if
On Wed, Mar 26, 2008 at 9:23 PM, Hans van der Meer [EMAIL PROTECTED] wrote: Wolfgang, From your observation I am inclined to guess that the \ifx falls prey to the collection of arguments. The \relax can be replaced by an extra pair {} behind the description: \answerblock{}{}% also typesets without the if-error. You could also add title=no to \definedescription[answerblock], this stops TeX from looking after a optional argument between the braces. I more or less conclude that the lookahead from \dodoublegroupempty does not stop on the \if. If I remember correctly, that behaviour is to be expected from tex and the prospects for solving it generically within the format bleak. If Hans Hagen is listening, can he comment on this? I tried your module also with my ancient ConTeXt from august last year and it did also show this effect. Your module is broken since a very long time. Wolfgang ___ 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 : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] description fails on \if
On Tue, Mar 25, 2008 at 8:38 PM, Hans van der Meer [EMAIL PROTECTED] wrote: There is the following problem on code that did work around july 2007, but no longer under the current context version (2008-03-11). Define a description, I did: \definedescription[answerblock][% \c!margin=\v!no,\c!location=\v!left,% \c!headstyle=\@@exmintrostyle,\c!style=\@@exmstyle,% \c!before=,\c!inbetween=,\c!after=,% \c!hang=\@@exmhang,\c!width=\questionblockwidth,% \c!text=\placeanswerstart] Could you try to set title=no. Typeset with this description inside the following macro: \def\shortanswer#1\par{% \par % be sure to end paragraph here \answerblock{}% % {} needed here in description call \ifanswers #1\else\dotfill\strut\fi % crashing on this if \par% final \par of description ... \par } The above code crashes with: ! Incomplete \ifx; all text was ignored after ... After some detective work in which Wolfgang Schuster had a large share and has found the most elegant workaround, the addition of a \relax just after the description call prevents the error: \def\shortanswer#1\par{% \par % be sure to end paragraph here \answerblock{}% % {} needed here in description call \relax %\relax prevents crash on if \ifanswers #1\else\dotfill\strut\fi \par% final \par of description ... \par } The way \relax stops the error reminds me of the \relax that one places after a number in order to separate that from the code following. I did compare core-des.tex, both the last version and the archived from 2007-04-17. But I must admit, I did not succeed finding a clue among the differences about what could have happened. The code is a bit too intricate to just jump in and pinpoint the culprit -- at least for me. Allthough Wolfgang's workaround saves the day, I feel this problem deserves solving inside ConTeXt, not outside it. Someday somewhere another person will stumble on the same problem -- a situation that can and should be avoided, in my view. Therefore I explain the problem here as fully as possible hoping someone knowledgeable with descriptions we might need to fall back to Taco or Hans will find the best remedy. I would say the message comes from \dodoublegroupempty in \@@description. Wolfgang ___ 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 : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] description fails on \if
Wolfgang, From your observation I am inclined to guess that the \ifx falls prey to the collection of arguments. The \relax can be replaced by an extra pair {} behind the description: \answerblock{}{}% also typesets without the if-error. I more or less conclude that the lookahead from \dodoublegroupempty does not stop on the \if. If I remember correctly, that behaviour is to be expected from tex and the prospects for solving it generically within the format bleak. If Hans Hagen is listening, can he comment on this? Hans van der Meer On 26 mrt 2008, at 08:32, Wolfgang Schuster wrote: Allthough Wolfgang's workaround saves the day, I feel this problem deserves solving inside ConTeXt, not outside it. Someday somewhere another person will stumble on the same problem -- a situation that can and should be avoided, in my view. Therefore I explain the problem here as fully as possible hoping someone knowledgeable with descriptions we might need to fall back to Taco or Hans will find the best remedy. I would say the message comes from \dodoublegroupempty in \@@description. ___ 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 : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] description fails on \if
Hans van der Meer wrote: I more or less conclude that the lookahead from \dodoublegroupempty does not stop on the \if. If I remember correctly, that behaviour is to be expected from tex and the prospects for solving it generically within the format bleak. If Hans Hagen is listening, can he comment on this? indeed, but cooking up a solution that always works is hard 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 - ___ 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 : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] error in textbackground with metapost
There must be something badly amiss in the textbackground processing. Below a small example demonstrating the problem. When a block falls badly on a page boundary an error occurs as shown. One may have to tweak the \blank[] in order to get the error depending on local font settings etc. In my case 0.78 shoved the second block to page 2 without an error but from 0.79 onwards the error occurs. At 0.66 the block is split after the third line, but at 0.68 again the error shows. TeX complains as follows. ! Argument of \dodoubletestempty has an extra }. inserted text \par to be read again } \doifnextcharelse ...token =#1\def \!!stringa {#2} \def \!!stringb {#3}\futur... \doMPpositiongraphic ...ta {#1:}\setupMPvariables [self=pbg:1, mp=mpos:par:c... \dodoublegroupempty #1-\def \dodogetargument ## 1{\def \dodogetargument {\do... \dohandleMPpositiongraphicrange ...ositiongraphic {#3}{#4}\fi \fi ... l.29 third line ? Process aborted === % metapost based variable backgrounds \setupcolors[state=start] \definetextbackground[code][frame=off,location=paragraph, backgroundcolor=cyan,color=red,backgroundoffset=0pt] \definetyping[TEST] \setuptyping[TEST][option=JV, before={\bgroup\setupinterlinespace[line=3ex]% \testpage[1]\starttextbackground[code]}, after={\stoptextbackground\egroup}] \setupbodyfont[14pt] \starttext Testing textbackground\crlf \startTEST first line second line third line fourth line fifth line \stopTEST \blank[0.73\textheight] \startTEST first line second line third line fourth line fifth line \stopTEST \stoptext Hans van der Meer ___ 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 : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] ConTeXt Marcro Quesiton
On Wed, 7 Feb 2007, Hans Hagen wrote: Wolfgang Schuster wrote: On Tue, 6 Feb 2007 10:36:42 -0500 (EST) Aditya Mahajan [EMAIL PROTECTED] wrote: On Tue, 6 Feb 2007, Hans Hagen wrote: Aditya Mahajan wrote: Can someone suggest a better way to do this? I found another way, I hope that it has no gotcha's search for group(ed)(empty|argument) in cont-sys.tex Did you mean syst-gen.tex? I tied dodoublegroupempty but it did not work in one case (see previous post) and I can not figure out why. Aditya Hi Aditya, I tried something similiar and copied a example from core-rul.tex [snip] Hans, can you give us a hint what we are doing wrong or can you make a simple example to show us how we can create optional arguments between braces. the magic is in \permitspacesbetweengroups Magic indeed. It works for my case also. I will post an improved theorem macors to make use of this magic. Aditya ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] ConTeXt Marcro Quesiton
On Tue, 6 Feb 2007 10:36:42 -0500 (EST) Aditya Mahajan [EMAIL PROTECTED] wrote: On Tue, 6 Feb 2007, Hans Hagen wrote: Aditya Mahajan wrote: Can someone suggest a better way to do this? I found another way, I hope that it has no gotcha's search for group(ed)(empty|argument) in cont-sys.tex Did you mean syst-gen.tex? I tied dodoublegroupempty but it did not work in one case (see previous post) and I can not figure out why. Aditya Hi Aditya, I tried something similiar and copied a example from core-rul.tex The following macro use a method copied from textrule and the second argument between the braces should be optional. I looked into the log file created with tracingmacros and it seems TeX cannot find the optional argument. \long\def\startDEBITS#1\stopDEBITS {\bgroup \def\debit{\dosingleempty\dodebit}% \def\dodebit[##1]% {\def\dododebit1{\dodododebit[##1]{1}}% \dosinglegroupempty\dododebit}% \def\dodododebit[##1]##2% {\hbox to\hsize{\strut##1\hfill##2}}% \vbox{\hsize4cm\hrule#1\hrule}% \egroup} \starttext %\tracingmacros1 \startDEBITS \debit [Text] {100} ttt \debit [Text] {200} xxx \stopDEBITS %\tracingmacros0 \stoptext Hans, can you give us a hint what we are doing wrong or can you make a simple example to show us how we can create optional arguments between braces. Wolfgang ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] ConTeXt Marcro Quesiton
Wolfgang Schuster wrote: On Tue, 6 Feb 2007 10:36:42 -0500 (EST) Aditya Mahajan [EMAIL PROTECTED] wrote: On Tue, 6 Feb 2007, Hans Hagen wrote: Aditya Mahajan wrote: Can someone suggest a better way to do this? I found another way, I hope that it has no gotcha's search for group(ed)(empty|argument) in cont-sys.tex Did you mean syst-gen.tex? I tied dodoublegroupempty but it did not work in one case (see previous post) and I can not figure out why. Aditya Hi Aditya, I tried something similiar and copied a example from core-rul.tex The following macro use a method copied from textrule and the second argument between the braces should be optional. I looked into the log file created with tracingmacros and it seems TeX cannot find the optional argument. \long\def\startDEBITS#1\stopDEBITS {\bgroup \def\debit{\dosingleempty\dodebit}% \def\dodebit[##1]% {\def\dododebit1{\dodododebit[##1]{1}}% \dosinglegroupempty\dododebit}% \def\dodododebit[##1]##2% {\hbox to\hsize{\strut##1\hfill##2}}% \vbox{\hsize4cm\hrule#1\hrule}% \egroup} \starttext %\tracingmacros1 \startDEBITS \debit [Text] {100} ttt \debit [Text] {200} xxx \stopDEBITS %\tracingmacros0 \stoptext Hans, can you give us a hint what we are doing wrong or can you make a simple example to show us how we can create optional arguments between braces. \long\def\startDEBITS#1\stopDEBITS {\vbox \bgroup \hsize4cm \def\debit {\dosingleempty\dodebit} \def\dodebit[##1]% {\def\dododebit{\dodododebit[##1]}% \permitspacesbetweengroups \dosinglegroupempty\dododebit} \def\dodododebit[##1]##2% {\dontleavehmode\hbox to\hsize{\strut##1\hfill##2}} \hrule#1\hrule \egroup} \starttext \startDEBITS \debit [Text]{100} ttt \debit [Text] {200} xxx \stopDEBITS the magic is in \permitspacesbetweengroups i suppose some \par needs to be added someplace - 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 - ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] ConTeXt Marcro Quesiton
On Tue, 6 Feb 2007, Hans Hagen wrote: Aditya Mahajan wrote: Can someone suggest a better way to do this? I found another way, I hope that it has no gotcha's search for group(ed)(empty|argument) in cont-sys.tex Did you mean syst-gen.tex? I tied dodoublegroupempty but it did not work in one case (see previous post) and I can not figure out why. Aditya ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
[NTG-context] ConTeXt Marcro Quesiton
Hi, I wand to write a macro, that handles both [] and {} as optional arguments. For example, I have a command with three optionl arguments [#1][#2]#3 I want \commandto give #1=\empty, #2 = \empty, #3 = \empty \command [1]to give #1=1, #2 empty, #3 empty, \command [1] {3}to give #1=1, #2 empty, #3 = 3 \command [1] [2] {3}to give #1=1, #2=2, #3=3 \command {3}to give #1=empty, #2=empty, #3=3. I tried the following macro, it works except for \command[1][2]{3}. \def\finalcommand[#1][#2]#3% {1 :- (#1), 2 :- (#2), 3 :- (#3)} \def\command% {\dodoubleempty\docommand} \def\docommand[#1][#2]% {\dodoublegroupempty{\finalcommand[#1][#2]}} \starttext \command \command [1] \command [1] {3} \command [1] [2] {3} \command {3} \stoptext which gives 1 :- (), 2 :- (), 3 :- () 1 :- (1), 2 :- (), 3 :- () 1 :- (1), 2 :- (), 3 :- (3) 1 :- (1), 2 :- (2), 3 :- () 3 - This does not work 1 :- (), 2 :- (), 3 :- (3) Can someone suggest a better way to do this? Aditya ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] ConTeXt Marcro Quesiton
On Mon, 5 Feb 2007, Aditya Mahajan wrote: Hi, I wand to write a macro, that handles both [] and {} as optional arguments. For example, I have a command with three optionl arguments [#1][#2]#3 I want \commandto give #1=\empty, #2 = \empty, #3 = \empty \command [1]to give #1=1, #2 empty, #3 empty, \command [1] {3}to give #1=1, #2 empty, #3 = 3 \command [1] [2] {3}to give #1=1, #2=2, #3=3 \command {3}to give #1=empty, #2=empty, #3=3. I tried the following macro, it works except for \command[1][2]{3}. \def\finalcommand[#1][#2]#3% {1 :- (#1), 2 :- (#2), 3 :- (#3)} \def\command% {\dodoubleempty\docommand} \def\docommand[#1][#2]% {\dodoublegroupempty{\finalcommand[#1][#2]}} \starttext \command \command [1] \command [1] {3} \command [1] [2] {3} \command {3} \stoptext which gives 1 :- (), 2 :- (), 3 :- () 1 :- (1), 2 :- (), 3 :- () 1 :- (1), 2 :- (), 3 :- (3) 1 :- (1), 2 :- (2), 3 :- () 3 - This does not work 1 :- (), 2 :- (), 3 :- (3) Can someone suggest a better way to do this? I found another way, I hope that it has no gotcha's \def\finalcommand[#1][#2]#3% {1 :- (#1), 2 :- (#2), 3 :- (#3)} \def\command% {\dodoubleempty\docommand} \def\docommand[#1][#2]% {\def\useoneargument##1{\finalcommand[#1][#2]{##1}} \def\fakeoneargument{\finalcommand[#1][#2]{}} \doifnextcharelse\bgroup{\useoneargument}{\fakeoneargument}} Aditya ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] extentable arrows
Aditya Mahajan wrote: The syntax can be made identical (even better) than that of amsmath. \def\xrightarrow{\dosingleempty\doxrightarrow} \def\xleftarrow {\dosingleempty\doxleftarrow} \def\doxrightarrow[#1]{\dodoublegroupempty\dodoxrightarrow{#1}} \def\doxleftarrow[#1]{\dodoublegroupempty\dodoxleftarrow{#1}} \def\dodoxrightarrow#1#2{\mathrel {{\domthxarr0359\rightarrowfill{#1}{#2 \def\dodoxleftarrow#1#2{\mathrel {{\domthxarr3095\leftarrowfill{#1}{#2 \starttext $$ A \xrightarrow[]{stuff on top} B $$ $$ A \xrightarrow[stuff below]{} B $$ \startformula A \xleftarrow[stuff below]{stuff on top} B \stopformula $$ A \xleftarrow B $$ $$ \rightarrow A \xrightarrow{stuff on top} B \leftarrow $$ $$ \rightarrow A \xleftarrow[stuff below] B \leftarrow $$ \stoptext hm, this is not the context way, two equal kind of contents and then one of them in [], maybe \def\xrightarrow{\doifnextcharelse[\noxrightarrow\doxrightarrow} \def\xleftarrow {\doifnextcharelse[\noxleftarrow\doxleftarrow} \def\doxrightarrow{\dodoublegroupempty\dodoxrightarrow} \def\doxleftarrow {\dodoublegroupempty\dodoxleftarrow } \def\noxrightarrow[#1]{\dodoublegroupempty\dodoxrightarrow{#1}} \def\noxleftarrow [#1]{\dodoublegroupempty\dodoxleftarrow {#1}} which accepts \xrightarrow{x}{y} \xrightarrow{x} \xrightarrow{}{y} \xrightarrow[x]{y} etc, actyally, we should then also accept \xrightarrow[x][y] but more interesting is to use the optional arg for tuning purposes \if0#1\else\mkern#1mu\fi test, does a \mkern0mu hurt? Will make copy paste a bit easier! Though these days I find myself writing more in context and soon will face the reverse problem. I will need to copy context math into latex (needed for final journal submission) and some of the math features are simply missing from latex :) 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 - ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] extentable arrows
Aditya Mahajan wrote: I am simply trying to copy from amsmath definition. better think context -) \unprotect \def\mtharrfactor{1} \def\mtharrextra {0} \def\domthxarr#1#2#3#4#5#6#7#8% {\begingroup \def\mtharrfactor{1}% \def\mtharrextra {0}% \processaction[#1] % will be sped up [ \v!none=\def\mtharrfactor{0}, \v!small=\def\mtharrextra{10}, \v!medium=\def\mtharrextra{15}, \v!big=\def\mtharrextra{20}, \v!normal=, \v!default=, \v!unknown=\doifnumberelse{#1}{\def\mtharrextra{#1}}\donothing]% \mathsurround\zeropoint \muskip0=#4mu \muskip0=\mtharrfactor\muskip0 \advance\muskip0 \mtharrextra mu \muskip2=#5mu \muskip2=\mtharrfactor\muskip2 \advance\muskip2 \mtharrextra mu \setbox0\hbox{$\scriptstyle \if#20\else\mkern#2mu\fi \mkern\muskip0\relax #8\relax \mkern\muskip2\relax \if#30\else\mkern#3mu\fi $}% \setbox4\hbox{#6}% \dimen0\wd0 \ifdim\wd4\dimen0 \dimen0\wd4 \fi \setbox2\hbox{$\scriptstyle \if#20\else\mkern#2mu\fi \mkern\muskip0\relax #7\relax \mkern\muskip2\relax \if#30\else\mkern#3mu\fi $}% \ifdim\wd2\dimen0 \dimen0\wd2 \fi \setbox4\hbox to \dimen0{#6}% \mathrel{\mathop{% \hbox to \dimen0{\hss\copy4\hss}}% \limits^{\box0}_{\box2}} \endgroup} % ams: \def\xrightarrow{\doifnextcharelse[\noxrightarrow\doxrightarrow} \def\xleftarrow {\doifnextcharelse[\noxleftarrow\doxleftarrow} \def\doxrightarrow{\dodoublegroupempty\dodoxrightarrow} \def\doxleftarrow {\dodoublegroupempty\dodoxleftarrow } \def\noxrightarrow[#1]{\dodoublegroupempty\dodoxrightarrow{#1}} \def\noxleftarrow [#1]{\dodoublegroupempty\dodoxleftarrow {#1}} \def\dodoxrightarrow#2#3{\mathrel{{\domthxarr{}0359\rightarrowfill{#1}{#2 \def\dodoxleftarrow #2#3{\mathrel{{\domthxarr{}3095\leftarrowfill {#1}{#2 % context: \def\xrightarrow {\dosingleempty\doxrightarrow} \def\xleftarrow {\dosingleempty\doxleftarrow} \def\doxrightarrow[#1]{\dotriplegroupempty\dodoxrightarrow{#1}} \def\doxleftarrow [#1]{\dotriplegroupempty\dodoxleftarrow {#1}} \def\dodoxrightarrow#1#2#3{\mathrel{{\domthxarr{#1}0359\rightarrowfill{#2}{#3 \def\dodoxleftarrow #1#2#3{\mathrel{{\domthxarr{#1}3095\leftarrowfill {#2}{#3 \starttext \startformula \xrightarrow{}{stuff on top}\stopformula \startformula \xrightarrow{stuff below}{}\stopformula \startformula \xrightarrow{stuff below}{stuff on top}\stopformula \startformula \xleftarrow [none]{stuff below}{stuff on top}\stopformula \startformula \xleftarrow [small]{stuff below}{stuff on top}\stopformula \startformula \xleftarrow [medium]{stuff below}{stuff on top}\stopformula \startformula \xleftarrow [big]{stuff below}{stuff on top}\stopformula \stoptext - 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 - ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] extentable arrows
On Wed, 28 Jun 2006, Taco Hoekwater wrote: Aditya Mahajan wrote: \xrightarrow{big superscipt} Any suggestions? Not completely identical, but similar. The syntax can be made identical (even better) than that of amsmath. \def\xrightarrow{\dosingleempty\doxrightarrow} \def\xleftarrow {\dosingleempty\doxleftarrow} \def\doxrightarrow[#1]{\dodoublegroupempty\dodoxrightarrow{#1}} \def\doxleftarrow[#1]{\dodoublegroupempty\dodoxleftarrow{#1}} \def\dodoxrightarrow#1#2{\mathrel {{\domthxarr0359\rightarrowfill{#1}{#2 \def\dodoxleftarrow#1#2{\mathrel {{\domthxarr3095\leftarrowfill{#1}{#2 \starttext $$ A \xrightarrow[]{stuff on top} B $$ $$ A \xrightarrow[stuff below]{} B $$ \startformula A \xleftarrow[stuff below]{stuff on top} B \stopformula $$ A \xleftarrow B $$ $$ \rightarrow A \xrightarrow{stuff on top} B \leftarrow $$ $$ \rightarrow A \xleftarrow[stuff below] B \leftarrow $$ \stoptext Will make copy paste a bit easier! Though these days I find myself writing more in context and soon will face the reverse problem. I will need to copy context math into latex (needed for final journal submission) and some of the math features are simply missing from latex :) Aditya ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context