[NTG-context] Bug in latest beta, shifted metapost (possibly with drawarrow)
Dear list, the example below has shifted axes. I updated to the latest standalone earlier today. The problem was not present some weeks ago. In particular look at the red line that should start from the origin... \starttext \startMPpage ut:=1.0cm; ux:=0.6cm; vardef diffp(expr riktn) = ((-1,0)--(1,0)) rotatedaround (origin,angle(ut,riktn*ux)) enddef; path taxel,xaxel; taxel:=((-1.4,0)--(5.4,0)); xaxel:=((0,-1.4)--(0,4.6)); drawarrow taxel xyscaled(ut,ux); drawarrow xaxel xyscaled(ut,ux); label.bot("$t$", (point length(taxel) of taxel) xyscaled(ut,ux)); label.lft("$P$", (point length(xaxel) of xaxel) xyscaled(ut,ux)); draw image( vardef fun(expr t, x) = x*(3-x) enddef; for i=-1 step 0.5 until 5 : for j=-1 step 0.5 until 4 : ii:=i; jj:=j; draw diffp(fun(ii,jj)) scaled 2bp shifted (ii*ut,jj*ux); endfor; endfor; draw function (2, "x", "3/(1+2*exp(-3*x))" ,-1, 5, 1/5) xyscaled (ut,ux); draw (0,0)--(3,3) xyscaled(ut,ux) withcolor darkred; ); \stopMPpage \stoptext /Mikael ctx-listexample17.pdf Description: Adobe PDF document ___ 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] Clickable question/answer numbers
Dear Otared (and others), while waiting for Hans reply on the \namedenumerationparameter and \enumerationparameter, this is the best I could do. Now, only "Question" is clickable and not the number, but I think I could live with that if no other solution show up. Best regards, Mikael \usemodule[references-show] \setupinteraction[state=start,color=,contrastcolor=,style=] \defineblock[answer] \hideblocks[answer] \def\myanswer[#1]{\inleft{\in[#1]\reference[A:#1]{\in[#1]}}} \defineenumeration[exercise][ text=Question, title=yes, titlestyle=, titlecolor=black, headstyle={\sc}, headcolor=darkred, style=, number=yes, ] \def\startquestion{\dodoubleempty\dostartquestion} \long\def\dostartquestion[#1][#2]#3\stopquestion{% \iffirstargument \setupenumeration[exercise][text={\goto{Question}[A:#1]}] \ifsecondargument \startexercise[#1]{#2} \else \startexercise[#1] \fi \else \setupenumeration[exercise][text=Question] \startexercise \fi #3 } \def\stopquestion{\stopexercise} \starttext \section{A section with questions} \startquestion[Q:test][This is a title] This is a question with title. \stopquestion \beginanswer \myanswer[Q:test] This is an answer \endanswer \startquestion[Q:test2] This is a question without title. \startformula (a+b)^2=a^2+ab+ba+b^2. \stopformula \stopquestion \beginanswer \myanswer[Q:test2] This is an answer. \endanswer \startquestion This is a question without reference. It cannot have any answer. \stopquestion \page[yes] \subject{Answers} \useblocks[answer] \stoptext On Thu, Nov 3, 2016 at 12:58 PM, Mikael P. Sundqvist wrote: > Dear Hans, > > This seems to be exactly what I need, but I cannot get it to work. > With the example below nothing comes from those > commands (I just updated my standalone to the latest one). On the > other hand, with text instead of reference it works. > > Best regards, Mikael > > \defineenumeration[question][ > text=Question, > ] > > \starttext > \startquestion[test] > This question has reference > \namedenumerationparameter{question}{reference} which could also > be achieved via \enumerationparameter{reference}. On the other hand, > \namedenumerationparameter{question}{text} > gives Question as assumed. > \stopquestion > > \startquestion[reference=test2] > This question has reference > \namedenumerationparameter{question}{reference} which could also > be achieved via \enumerationparameter{reference}. On the other hand, > \namedenumerationparameter{question}{text} > gives Question as assumed. > \stopquestion > \stoptext > > On Thu, Nov 3, 2016 at 10:34 AM, Hans Hagen wrote: >> On 11/2/2016 9:58 PM, Mikael P. Sundqvist wrote: >>> >>> Dear Otared, >>> >>> thank you again. This is somehow a proof that it should work. In my >>> real document I use the title to name some exercises (after old >>> exams), and I don't see how that can be combined with your solution. >>> >>> If someone else reads this: I think the question boils down to the >>> following: >>> >>> \startquestion[Q:test] >>> How can I here automatically get access to to the string "Q:test"? >>> \stopquestion >> >> >> it depends what automatically means >> >> \enumerationparameter{reference} >> >> or >> >> \namedenumerationparameter{question}{reference} >> >> >>> Best regards, Mikael >>> >>> On Wed, Nov 2, 2016 at 9:04 PM, Otared Kavian wrote: Hi Mikael, A partial solution to the feature we are discussing is contained in the example below, but somone more aware of ConTeXtish coding might improve it. It is not satisfactory in that one has to define twice \startquestion and \StartQuestion, \beginanswer and \BeginAnswer, and more importantly one cannot generate automatically the references (I tried \getnumber[question] and such to append to Q:\getnumber[question] for instance, but something does not work…). Le me know if you find a satisfactory solution… Best regards: OK %%% begin interactive-question-answer.tex \setupinteraction[state=start,color=,contrastcolor=,style=] \defineblock[answer] \hideblocks[answer] \def\myanswer[#1]{\inleft{\in[#1]\reference[A:#1]{\in[#1]}}} \define[1]\AnswerToQuestion{Question \goto{(see Solution)}[A:Q:#1]} \define[1]\StartQuestion{\startquestion[reference=Q:#1,title={\AnswerToQuestion{#1}}]} \define[1]\BeginAnswer{\beginanswer\myanswer[Q:#1]} \defineenumeration[question][ text=, %Question, headcolor=darkred, title=yes, titleleft=, titleright={.}, width=fit, number=yes, prefix=yes, prefixsegments=section, ] \starttext \section{A section with questions} \StartQuestion{test} Prove that $(a +b)^2 = a^2 + 2ab + b^2$ for all $a,b\in{\Bbb R}$. \BeginAnswer{test} Indeed $(a+b)^2 = (a+b)(a+
Re: [NTG-context] Vim wiki page updated
On 03/11/2016 12:28, Hans Hagen wrote: if you need a command list .. there are scripts for that (no vim yet, but for scite we ship simple lists of commands) Are these scripts available somewhere? what kind of datafile do you need? I need the list of all macros, vardefs, internals, and global variables from all MetaFun files. The format should be Vim's syntax format: https://github.com/vim/vim/blob/master/runtime/syntax/mp.vim Nicola ___ 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] Clickable question/answer numbers
Dear Hans, This seems to be exactly what I need, but I cannot get it to work. With the example below nothing comes from those commands (I just updated my standalone to the latest one). On the other hand, with text instead of reference it works. Best regards, Mikael \defineenumeration[question][ text=Question, ] \starttext \startquestion[test] This question has reference \namedenumerationparameter{question}{reference} which could also be achieved via \enumerationparameter{reference}. On the other hand, \namedenumerationparameter{question}{text} gives Question as assumed. \stopquestion \startquestion[reference=test2] This question has reference \namedenumerationparameter{question}{reference} which could also be achieved via \enumerationparameter{reference}. On the other hand, \namedenumerationparameter{question}{text} gives Question as assumed. \stopquestion \stoptext On Thu, Nov 3, 2016 at 10:34 AM, Hans Hagen wrote: > On 11/2/2016 9:58 PM, Mikael P. Sundqvist wrote: >> >> Dear Otared, >> >> thank you again. This is somehow a proof that it should work. In my >> real document I use the title to name some exercises (after old >> exams), and I don't see how that can be combined with your solution. >> >> If someone else reads this: I think the question boils down to the >> following: >> >> \startquestion[Q:test] >> How can I here automatically get access to to the string "Q:test"? >> \stopquestion > > > it depends what automatically means > > \enumerationparameter{reference} > > or > > \namedenumerationparameter{question}{reference} > > >> Best regards, Mikael >> >> On Wed, Nov 2, 2016 at 9:04 PM, Otared Kavian wrote: >>> >>> Hi Mikael, >>> >>> A partial solution to the feature we are discussing is contained in the >>> example below, but somone more aware of ConTeXtish coding might improve it. >>> It is not satisfactory in that one has to define twice \startquestion and >>> \StartQuestion, \beginanswer and \BeginAnswer, and more importantly one >>> cannot generate automatically the references (I tried \getnumber[question] >>> and such to append to Q:\getnumber[question] for instance, but something >>> does not work…). >>> >>> Le me know if you find a satisfactory solution… >>> >>> Best regards: OK >>> %%% begin interactive-question-answer.tex >>> \setupinteraction[state=start,color=,contrastcolor=,style=] >>> >>> \defineblock[answer] >>> \hideblocks[answer] >>> >>> \def\myanswer[#1]{\inleft{\in[#1]\reference[A:#1]{\in[#1]}}} >>> >>> \define[1]\AnswerToQuestion{Question \goto{(see Solution)}[A:Q:#1]} >>> >>> >>> \define[1]\StartQuestion{\startquestion[reference=Q:#1,title={\AnswerToQuestion{#1}}]} >>> >>> \define[1]\BeginAnswer{\beginanswer\myanswer[Q:#1]} >>> >>> \defineenumeration[question][ >>> text=, %Question, >>> headcolor=darkred, >>> title=yes, >>> titleleft=, >>> titleright={.}, >>> width=fit, >>> number=yes, >>> prefix=yes, >>> prefixsegments=section, >>> ] >>> >>> \starttext >>> >>> \section{A section with questions} >>> >>> \StartQuestion{test} >>> >>> Prove that $(a +b)^2 = a^2 + 2ab + b^2$ for all $a,b\in{\Bbb R}$. >>> >>> \BeginAnswer{test} >>> >>> Indeed $(a+b)^2 = (a+b)(a+b) = a^2 + ab + ba +b^2 = a^2 + 2ab +b^2$ since >>> $ba=ba$. >>> \endanswer >>> >>> \stopquestion >>> >>> \page[yes] >>> >>> \startsection[title={Answers to all questions}] >>> >>> \useblocks[answer] >>> >>> \stopsection >>> \stoptext >>> %%% end interactive-question-answer.tex >>> On 2 Nov 2016, at 16:16, Mikael P. Sundqvist wrote: Dear Otared (and list), thank you for your reply and support. The links from the answers to the questions work as wanted with my solution, it is the links from the questions to the answers that do not. I guess I need something like headcommand={\in{Question}[A:###]}, where ### is the reference tag I set. But I don't know what to change the ### into (or if that would work). Best regards, Mikael On Wed, Nov 2, 2016 at 1:52 PM, Otared Kavian wrote: > > Hi Mikael, > > I had a similar question some time ago, but I wanted to add a sort of > automatic referencing of questions and answers (and interaction going from > questions to answers and back). > > If you accept the hurdle of adding manual references, in your case you > can add (for instance…) > >\goto{:-)}[Q:test] > > to the end of your answer to go back to the respective question. But > when you have several dozens of such references to add manually, it is > not a > good idea. > > However I could not find a way to code the items (that is the > questions) in such a way that each adds automatically a unique reference, > and so I am interested too in the solution of the problem you mention. > > Best regards: OK > > >> On 2 Nov 2016, at 12:43, Mikael P. Sundqvi
Re: [NTG-context] Vim wiki page updated
On 11/3/2016 11:25 AM, Nicola wrote: On 03/11/2016 10:45, Hans Hagen wrote: On 11/2/2016 11:35 PM, Aditya Mahajan wrote: On Wed, 2 Nov 2016, Nicola wrote: The syntax scripts in Vim already cover all of MetaFun. MetaFun keywords are highlighted by default inside ConTeXt documents; for MetaPost files ('mp' filetype), you must put let g:mp_metafun_macros = 1 into your vimrc. Ah, great! if you need a command list .. there are scripts for that (no vim yet, but for scite we ship simple lists of commands) Are these scripts available somewhere? what kind of datafile do you need? I've rolled out my own, but I will happily use/adapt something "more official". > The indent file is adapted from (I think) latex-suite's indent file with > modificiations that suit my taste. I am not sure these should go into > the default vim indent file, but it may be worthwhile for you to take a > quick look. MetaPost indentation is tough. I have rewritten the indent script in Vim from scratch, and now it works reasonably well. I will try yours, but you might try the one currently in Vim, too. I did not change metapost indenting, but defined some rules for indenting of context files. I believe that your indent file does not attempt to indent context files (I may be mistaken because I am just reading the .vim files, not testing it as I don't have vim8 yet). Correct, no indentation for ConTeXt. This is something that may be worth adding. I could maybe create a GitHub repository, to make it easier to merge your work. That will be nice. Then I can also send you pull requests for specific things. Ok, I'll let you know when I've done it. Pull requests will make my life much easier :) Nicola ___ 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 ___ -- - 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] Vim wiki page updated
On 03/11/2016 10:45, Hans Hagen wrote: On 11/2/2016 11:35 PM, Aditya Mahajan wrote: On Wed, 2 Nov 2016, Nicola wrote: The syntax scripts in Vim already cover all of MetaFun. MetaFun keywords are highlighted by default inside ConTeXt documents; for MetaPost files ('mp' filetype), you must put let g:mp_metafun_macros = 1 into your vimrc. Ah, great! if you need a command list .. there are scripts for that (no vim yet, but for scite we ship simple lists of commands) Are these scripts available somewhere? I've rolled out my own, but I will happily use/adapt something "more official". > The indent file is adapted from (I think) latex-suite's indent file with > modificiations that suit my taste. I am not sure these should go into > the default vim indent file, but it may be worthwhile for you to take a > quick look. MetaPost indentation is tough. I have rewritten the indent script in Vim from scratch, and now it works reasonably well. I will try yours, but you might try the one currently in Vim, too. I did not change metapost indenting, but defined some rules for indenting of context files. I believe that your indent file does not attempt to indent context files (I may be mistaken because I am just reading the .vim files, not testing it as I don't have vim8 yet). Correct, no indentation for ConTeXt. This is something that may be worth adding. I could maybe create a GitHub repository, to make it easier to merge your work. That will be nice. Then I can also send you pull requests for specific things. Ok, I'll let you know when I've done it. Pull requests will make my life much easier :) Nicola ___ 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] Vim wiki page updated
On 11/2/2016 11:35 PM, Aditya Mahajan wrote: On Wed, 2 Nov 2016, Nicola wrote: The syntax scripts in Vim already cover all of MetaFun. MetaFun keywords are highlighted by default inside ConTeXt documents; for MetaPost files ('mp' filetype), you must put let g:mp_metafun_macros = 1 into your vimrc. Ah, great! if you need a command list .. there are scripts for that (no vim yet, but for scite we ship simple lists of commands) > The indent file is adapted from (I think) latex-suite's indent file with > modificiations that suit my taste. I am not sure these should go into > the default vim indent file, but it may be worthwhile for you to take a > quick look. MetaPost indentation is tough. I have rewritten the indent script in Vim from scratch, and now it works reasonably well. I will try yours, but you might try the one currently in Vim, too. I did not change metapost indenting, but defined some rules for indenting of context files. I believe that your indent file does not attempt to indent context files (I may be mistaken because I am just reading the .vim files, not testing it as I don't have vim8 yet). > The ftplugin file mainly contains shortcuts like `a expand to α, etc; > again, > adapted from latex-suite (which in-turn borred the idea from auctex). These > depend on a ftplugin file provided by latex-suite. There were also a few > macros to reflow text, but your code is more robust and has more features. I will look into those, too. Do you know that Vim has built-in support for digraphs (:h digraphs)? For example, α can be obtained by typing a* in Insert mode. I know of digraphis but it can be tricky to remember all the mapping (for example for \subset, \circ, etc.). Auctex uses fairly intuitive shortcuts. I could maybe create a GitHub repository, to make it easier to merge your work. That will be nice. Then I can also send you pull requests for specific things. Aditya ___ 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 ___ -- - 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] Clickable question/answer numbers
On 11/2/2016 9:58 PM, Mikael P. Sundqvist wrote: Dear Otared, thank you again. This is somehow a proof that it should work. In my real document I use the title to name some exercises (after old exams), and I don't see how that can be combined with your solution. If someone else reads this: I think the question boils down to the following: \startquestion[Q:test] How can I here automatically get access to to the string "Q:test"? \stopquestion it depends what automatically means \enumerationparameter{reference} or \namedenumerationparameter{question}{reference} Best regards, Mikael On Wed, Nov 2, 2016 at 9:04 PM, Otared Kavian wrote: Hi Mikael, A partial solution to the feature we are discussing is contained in the example below, but somone more aware of ConTeXtish coding might improve it. It is not satisfactory in that one has to define twice \startquestion and \StartQuestion, \beginanswer and \BeginAnswer, and more importantly one cannot generate automatically the references (I tried \getnumber[question] and such to append to Q:\getnumber[question] for instance, but something does not work…). Le me know if you find a satisfactory solution… Best regards: OK %%% begin interactive-question-answer.tex \setupinteraction[state=start,color=,contrastcolor=,style=] \defineblock[answer] \hideblocks[answer] \def\myanswer[#1]{\inleft{\in[#1]\reference[A:#1]{\in[#1]}}} \define[1]\AnswerToQuestion{Question \goto{(see Solution)}[A:Q:#1]} \define[1]\StartQuestion{\startquestion[reference=Q:#1,title={\AnswerToQuestion{#1}}]} \define[1]\BeginAnswer{\beginanswer\myanswer[Q:#1]} \defineenumeration[question][ text=, %Question, headcolor=darkred, title=yes, titleleft=, titleright={.}, width=fit, number=yes, prefix=yes, prefixsegments=section, ] \starttext \section{A section with questions} \StartQuestion{test} Prove that $(a +b)^2 = a^2 + 2ab + b^2$ for all $a,b\in{\Bbb R}$. \BeginAnswer{test} Indeed $(a+b)^2 = (a+b)(a+b) = a^2 + ab + ba +b^2 = a^2 + 2ab +b^2$ since $ba=ba$. \endanswer \stopquestion \page[yes] \startsection[title={Answers to all questions}] \useblocks[answer] \stopsection \stoptext %%% end interactive-question-answer.tex On 2 Nov 2016, at 16:16, Mikael P. Sundqvist wrote: Dear Otared (and list), thank you for your reply and support. The links from the answers to the questions work as wanted with my solution, it is the links from the questions to the answers that do not. I guess I need something like headcommand={\in{Question}[A:###]}, where ### is the reference tag I set. But I don't know what to change the ### into (or if that would work). Best regards, Mikael On Wed, Nov 2, 2016 at 1:52 PM, Otared Kavian wrote: Hi Mikael, I had a similar question some time ago, but I wanted to add a sort of automatic referencing of questions and answers (and interaction going from questions to answers and back). If you accept the hurdle of adding manual references, in your case you can add (for instance…) \goto{:-)}[Q:test] to the end of your answer to go back to the respective question. But when you have several dozens of such references to add manually, it is not a good idea. However I could not find a way to code the items (that is the questions) in such a way that each adds automatically a unique reference, and so I am interested too in the solution of the problem you mention. Best regards: OK On 2 Nov 2016, at 12:43, Mikael P. Sundqvist wrote: Dear list, I have a pretty large text with a lot of questions and answers, and want the user(students) to be able to click in the pdf to go from a certain exercise to its answer, and back. I have a solution (see below) to go from answers to questions, but not the other way around. I simply have no idea on how to make the red text (in the head) in the example question clickable with the answer on the next page as target. As you can see, the answer has a tag A:Q:test (I want to set these automatically in that manner), and clicking the green text I get to the correct place. I just don't see how to make the "Question 1.1" clickable with that target. I hope I make myself clear. If it matters, in the solution one could assume that the optional tag of the \startquestion \stopquestion is given for all questions. Best regards, Mikael %% qa.tex \setupinteraction[state=start,color=,contrastcolor=,style=] \defineblock[answer] \hideblocks[answer] \def\myanswer[#1]{\inleft{\in[#1]\reference[A:#1]{\in[#1]}}} \defineenumeration[question][ text=Question, headcolor=darkred, width=fit, number=yes, prefix=yes, prefixsegments=section, ] \starttext \section{A section with questions} \startquestion[Q:test] Solve this question! \stopquestion We could, however, click \color[darkyellow]{\in{Answer}[A:Q:test]}. \beginanswer \myanswer[Q:test] What question? The answer is \quotation{do it yourself}! \endanswer \page[yes] \subject{Answers} \us