[NTG-context] dictionary example

2021-06-12 Thread jbf
I am wondering if someone has tried a two-column dictionary layout with 
ConTeXt. What is confounding me at the moment is the gap between entries 
in the columns. My MWE is below. Try as I may, I seem unable to get rid 
of those gaps! I obviously want each entry to follow on from the other. 
I'm obviously not doing things right! If someone has already set up a 
dictionary and has a model they could share I'd be grateful. I'm 
attaching a screenshot of the result from the code below.


Julian

--

\setuphead[subsubject][before=,after=]

\definemarking[subsubject]
\setupheadertexts
[{\getmarking[subsubject][top]–\getmarking[subsubject][bottom]}][][{\getmarking[subsubject][top]–\getmarking[subsubject][bottom]}][]

\setupcolumns[n=2,align=raggedright,balance=no,tolerance={verytolerant,stretch}]
\definedescription[des][headstyle=bold,style=normal,alternative=serried, 
width=fit]

\starttext

\startsubject[title={A}]
\startsubsubject[marking={Term 1}]
\startcolumns
\startdes{term 1}1. bla. 2. bla bla 3. bla bla bla. {\em adjective}. 
\textbullet\hskip 2pt

\input weisman
\rightarrow {\bf something else}.
\stopdes
\stopsubsubject

\startsubsubject[marking={Term 2}]
\startdes{term 2}1. bla. 2. bla bla 3. bla bla bla. {\em noun} 
\textbullet\hskip 2pt \input weisman

\stopdes
\stopsubsubject

\startsubsubject[marking={Term 3}]
\startdes{term 3}1. bla. 2. bla bla 3. bla bla bla. {\em noun} 
\textbullet\hskip 2pt \input weisman

\stopdes
\stopcolumns
\stopsubsubject
\stopsubject

___
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] Genealogy and context

2021-03-03 Thread Hans Hagen

On 2/28/2021 7:32 PM, David van Diepen wrote:

Hello,

My son is very much interested in genealogy. He already has collected
information on thousands of people. Now it would be nice to be able to
present this information in the form of a book. There is a possibility
to have this done by a commercial service, however then it's not
possible to adapt the format or to insert custom text. Media can be
added but not in the way we like it.

Genealogical information is stored as structured data. I have added a
fragment of an Gramps XML file below. In such a file there are events,
people, families and other groupings of data and these are linked by
handles.

What we would like to produce is a book with a number of blocks on
every page describing a family: Father, mother, dates of birth and
death, date of marriage, occupations and children. It would also be
good it there are references to the grandparents.

My question is: Where should I get started with a project in which a
document is generated automatically from data? As far as I know context
should be very suitable for this but I don't have any experience with
this. Until now I've used context to make documents without any data
being added automatically, except for the bibliography.

Thank you in advance,

David van Diepen

Example Gramps XML file is below:


http://gramps-project.org/xml/1.7.1/grampsxml.dtd;>
http://gramps-project.org/xml/1.7.1/;>
   
 
 
 
   
   
   
   Birth
   
   
   
 
 
   Death
   
   
   
 
 
   Marriage
   
   
   
 
   
   
   
   F
   
 Catharina
 Geldof
   
   
   
   
 
  
   M
   
 Cornelis
 Geldof
   
   
   
   
   
   
 
 
   F
   
 Maatje
 de Voogd
   
   
   
   
   
   
 
   
   
 
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
 
  


\startbuffer[test]

http://gramps-project.org/xml/1.7.1/;>
  



  
  
  id="E1746">

  Birth
  
  
  

id="E1747">

  Death
  
  
  

id="E6977">

  Marriage
  
  
  

  
  
  id="I0987">

  F
  
Catharina
Geldof
  
  
  
  

 id="I0049">

  M
  
Cornelis
Geldof
  
  
  
  
  
  

id="I0050">

  F
  
Maatje
de Voogd
  
  
  
  
  
  

  
  
id="F0016">

  
  
  
  
  

 

\stopbuffer

%  mapping

\startxmlsetups xml:mysetups
\xmlsetsetup{#1}{database|families|family|person|childref}{xml:*}
\stopxmlsetups

\xmlregistersetup{xml:mysetups}

\startxmlsetups xml:database
\xmlfirst{#1}{/families}
\stopxmlsetups

\startxmlsetups xml:families
\xmlall{#1}{/family}
\stopxmlsetups

\startxmlsetups xml:person
\starttabulate[|||]
\BC name\NC \xmlfirst{#1}{name/first/text()} \NC \NR
\BC surname \NC \xmlfirst{#1}{name/surname/text()} \NC \NR
\BC gender  \NC \xmlfirst{#1}{gender} \NC \NR
\stoptabulate
\stopxmlsetups

\startxmlsetups xml:childref
% \startsubsubject[title=Child]

\xmlfirst{main}{/database/people/person[@handle='\xmlatt{#1}{hlink}']}
% \stopsubsubject
\stopxmlsetups

\startxmlsetups xml:family
\xmldoif {#1}{/father} {
\startsubject[title=Father]

\xmlfirst{main}{/database/people/person[@handle='\xmlattribute{#1}{/father}{hlink}']}
\stopsubject
}
\xmldoif {#1}{/mother} {
\startsubject[title=Mother]

\xmlfirst{main}{/database/people/person[@handle='\xmlattribute{#1}{/mother}{hlink}']}
\stopsubject
}
\xmldoif {#1}{/childref} {
\startsubject[title=Children]
\xmlall{#1}{/childref}
\stopsubject
}
\stopxmlsetups

\starttext
% \xmlprocess{main}{somefile.xml}{}
\xmlprocessbuffer{main}{test}{}
\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
___


[NTG-context] Wrong counting of lines and paragraphs

2020-08-07 Thread Marcus Vinicius Mesquita
Dear list,

In the MWE below you don't get lines and paragraphs numbered correctly:

\setuplinenumbering[location=inner,align=right,style=\tfxx,distance=10pt,color=red]
\setupparagraphnumbering[state=start,style=bold,distance=0pt,color=darkblue]

\setuphead[title][alternative=text,style=bold]
\setuphead[subject][alternative=text,style=bolditalic]
\setuphead[subsubject][alternative=text,style=\ss]
\setuphead[subsubsubject][alternative=text,style=\ss\it]

\startbuffer[waltham]
  \input waltham
\stopbuffer

\starttext
\startlinenumbering

\starttitle[title={Waltham}]
\dorecurse{4}{\getbuffer[waltham]\par}

\startsubject[title={Waltham}]
\dorecurse{5}{\getbuffer[waltham]\par}

\startsubsubject[title={Waltham}]
\dorecurse{5}{\getbuffer[waltham]\par}

\startsubsubsubject[title={Waltham}]
\dorecurse{2}{\getbuffer[waltham]\par}
\stopsubsubsubject

\stopsubsubject
\stopsubject
\stoptitle

\stoplinenumbering

\stoptext

Have I hit a bug?

Regards

Marcus Vinicius


-- 
Todas as coisas fatigam o corpo, salvo a música, que não fatiga nem o corpo
nem seus membros, por ser descanso da alma, primavera do coração, distração
do aflito, entretenimento do solitário, e viático do viajante.

Kunnâsh al-Hâ'ik (Cancioneiro de al-Hâ'ik)
\setuplinenumbering [location=inner,align=right,style=\tfxx,distance=10pt,color=red]
\setupparagraphnumbering[state=start,style=bold,distance=0pt,color=darkblue]

\setuphead[title][alternative=text,style=bold]
\setuphead[subject][alternative=text,style=bolditalic]
\setuphead[subsubject][alternative=text,style=\ss]
\setuphead[subsubsubject][alternative=text,style=\ss\it]

\startbuffer[waltham]
  \input waltham
\stopbuffer

\starttext
\startlinenumbering

\starttitle[title={Waltham}]
\dorecurse{4}{\getbuffer[waltham]\par}

\startsubject[title={Waltham}]
\dorecurse{5}{\getbuffer[waltham]\par}

\startsubsubject[title={Waltham}]
\dorecurse{5}{\getbuffer[waltham]\par}

\startsubsubsubject[title={Waltham}]
\dorecurse{2}{\getbuffer[waltham]\par}
\stopsubsubsubject

\stopsubsubject
\stopsubject
\stoptitle

\stoplinenumbering

\stoptext


MWE.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] Feature request for export: Interactive Notes

2015-04-25 Thread Pablo Rodriguez
On 04/25/2015 02:19 PM, Idris Samawi Hamid ادريس سماوي حامد wrote:
 [...]
   Indeed, I plan to present the results of this experiment (porting an
   entire academic article to xhtml and WP) in a future article for one  
   of the TeX journals...

 I’m really interested in reading it. Also because I’m trying to use
 ConTeXt to generate high-quality PDF documents from XHTML files
 generated by pandoc ;-).
 
 Ah, I'll be interested in seeing that workflow as well ;-)

Hi Idris,

I’m working on an article on this topic. But without bibligraphies, I
have never used myself in ConTeXt or in pandoc :-(.

   Now we can of course already export xhtml footnotes from ConTeXt but  
   there will be no interactive links. In the current project, there are 77
   footnotes; I had to add the links manually to get the output to do  
   what we wanted.

 I’m afraid that missing links for footnotes is a bug,
 
 Hmm, what do you mean exactly?

If footnotes in ePub (or XHTML) have no links, how is the user supposed
to handle them?

I must be missing something, because I think footnotes are hardly
accesible in XHTML without links.

 This is why I said that it makes much more sense to export the footnotes  
 as endnotes. At the end of, e.g., a blog post you'll have a section for  
 footnotes/endnotes. In the context source I had to make a derivative  
 version and use something like
 
 \startsubsubject[title=Endnotes]
 \placefootnotes
 \stopsubsubject
 
 [Aside: I wonder if there is a way in ConTeXt to setup \placefootnotes  
 etc. in a mode so that it gets invoked only in the export. Will explore  
 this for the article.]

How about the system mode: \doifmode{*export}{\placefootnotes}?

I discovered this (http://wiki.contextgarden.net/Modes#System_modes)
after the reply from Hans to my own question.

Best,


Pablo
-- 
http://www.ousia.tk
___
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] Feature request for export: Interactive Notes

2015-04-25 Thread Idris Samawi Hamid ادريس سماوي حامد

Hi Pablo,

On Sat, 25 Apr 2015 03:05:07 -0600, Pablo Rodriguez oi...@gmx.es wrote:


On 04/25/2015 02:36 AM, Idris Samawi Hamid ادريس   سماوي حامد wrote:

Dear gang,

  I've spent a considerable amount of time over the past month trying to
  master the art of xhtml output. We are close to being able to use  
ConTeXt

  as a replacement for markdown in, e.g., WordPress.


Hi Idris,

Markdown or pandoc? Markdown is the markup format, pandoc is the tool.


In this case we're talking about markdown qua source. In the WordPress  
case, pandoc of course is not needed: WP can either use md directly or (as  
I prefer) an editor such as MarkdownPad~2 will export the html for you,  
which you can then paste to WP.



Replacing pandoc with ConTeXt to generate XHTML or ePub files has a
downside.

As far as I know, ConTeXt is much slower for this task.


Absolutely, by far. But see below.


With a sample
from pandoc (http://pandoc.org/epub.html#a-real-book), it takes between
5 and 3 seconds on my computer (depending whether pandoc is loaded in
memory or not).


Sure, and as you know I've done an entire small book using pandoc  
(docx-md; then md-epub; md-context-pdf)



With pandoc you have also more formats to write to.


Yes, but the goal here is much narrower: to use ConTeXt as source. Perhaps  
if pandoc supported ConTeXt input I might have gone that route, but I  
don't see that happening anytime soon...


For simple tasks the markdown/pandoc route is excellent. But as the  
typesetting needs become more advanced (e.g., bibliographies), markdown as  
source makes less and less sense. And pandoc export to epub has  
limitations, as you and I have discussed before.


Yes, the ConTeXt route is slower, and the learning curve has been  
considerably longer than I anticipated. But the resulting workflow is  
*much* more flexible for serious academic typesetting and export tasks.



  Indeed, I plan topresent the results of this experiment (porting an
  entire academic article to xhtml and WP) in a future article for one  
of

  the TeX journals...


I’m really interested in reading it. Also because I’m trying to use
ConTeXt to generate high-quality PDF documents from XHTML files
generated by pandoc ;-).


Ah, I'll be interested in seeing that workflow as well ;-)

  Now we can of course already export xhtml footnotes from ConTeXt but  
there

  will be no interactive links. In the current project, there are 77
  footnotes; I had to add the links manually to get the output to do  
what we

  wanted.


I’m afraid that missing links for footnotes is a bug,


Hmm, what do you mean exactly?


  [Also note that it makes much more sense to export the footnotes as
  endnotes, particularly for long blog posts.]


I think that footnotes are related to pages. You can only have proper
footnotes in a page.


This is why I said that it makes much more sense to export the footnotes  
as endnotes. At the end of, e.g., a blog post you'll have a section for  
footnotes/endnotes. In the context source I had to make a derivative  
version and use something like


\startsubsubject[title=Endnotes]
\placefootnotes
\stopsubsubject

[Aside: I wonder if there is a way in ConTeXt to setup \placefootnotes  
etc. in a mode so that it gets invoked only in the export. Will explore  
this for the article.]


Some crude regular expressions helped me to edit ConTeXt's *div.xhtml  
output; with scripting one should be able to do it all automatically. But  
my scripting skill set is limited-to-nonexistent so the part of the task  
that couldn't fit easily into a regex sub I had to do manually.


Best wishes
Idris
--
Idris Samawi Hamid
Professor of Philosophy
Colorado State University
Fort Collins, CO 80523
___
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] itemize in two columns and pagebreaks

2012-06-29 Thread Marcin Borkowski
 wynosi
  \math{-2\frac{7}{12}+3\frac{5}{12}=3\frac{7}{12}-4\frac{5}{12}=\frac{1}{12}}.

  Prowadząc podobną analizę dla gracza~II widzimy, że ta sama
  strategia pozwala mu uzyskać przeciętną
  stratę~\math{\frac{1}{12}}.  Wynika stąd, że znalezionej
  strategii nie da się ulepszyć, a~gra nie jest sprawiedliwa
  (preferuje I~gracza).
\stopanswer
  \stopitem
  \startitem
Rozważmy wariant gry {\em parzyste czy nieparzyste}, w~którym
każdy z~graczy wybiera jedną z~liczb~\math{\{0,1,2\}}.  Spróbuj
wyliczyć optymalną strategię dla pierwszego gracza.
\startanswer
  Nie ma ani strategii dominujących, ani punktów siodłowych.
  Postępujemy jak w~poprzednim ćwiczeniu \todo{rozpisać układ
równań}; okazuje się, że I~gracz powinien wybierać~\math{1}
  z~prawdopodobieństwem~\math{\frac{1}{2}} i~pozostałe liczby
  z~prawdopodobieństwem~\math{\frac{1}{4}}.  Uwaga: ta metoda {\em
nie działa dla każdej macierzy}!
\stopanswer
  \stopitem
\stopexercises

\stopchapter

\startchapter[title={Nim-suma liczb całkowitych nieujemnych}]

\startexercises
  \startitem
Przelicz następujące liczby w~zapisie dwójkowym na system
dziesiątkowy:
\startitemize[r,columns,two][left=(,right=),stopper={}]
  \startitem
\math{(101)_2}
  \stopitem
  \startitem
\math{(101011)_2}
  \stopitem
\stopitemize
  \stopitem
  \startitem
Przelicz następujące liczby na system dwójkowy:
\startitemize[r,columns,two][left=(,right=),stopper={}]
  \startitem
\math{10}
  \stopitem
  \startitem
\math{77}
  \stopitem
\stopitemize
  \stopitem
\stopexercises
\stopchapter

\startchapter[title={Kombinatoryczne gry symetryczne}]
  
\stopchapter


\startchapter[title={Przykładowe gry}]

\startsection[title={Zakreśl do piętnastu (20~minut)}]
  \startsubsubject[title={Zasady gry}]
Wypisujemy na kartce liczby od~\math{1} do~\math{9}.  Gracze na
przemian zakreślają liczbę (każdy swoim kolorem).  Gracz, który
jako pierwszy wśród \quotation{swoich} liczb będzie miał trójkę
liczb, których suma wynosi~\math{15}, wygrywa.
  \stopsubsubject
  \startsubsubject[title={Zadania}]
\startexercises
  \startitem
Jakimi wynikami może zakończyć się gra?
\startanswer
  Wygraną jednego z~graczy lub remisem.
\stopanswer
  \stopitem
  \startitem
Rozegrajcie kilka\ppauza kilkanaście gier.  Czy pierwszy gracz
może zawsze wygrać?  A~drugi?
\startanswer
  Nie, gdy obaj gracze grają optymalnie, gra kończy się
  remisem.  (Optymalną strategię znajdziemy za chwilę.)
\stopanswer
  \stopitem
  \startitem
Wypiszcie wszystkie trójki liczb ze zbioru
\math{\{1,2,\dots,9\}}, które sumują się do~\math{15}.  Jak
wypisać je \quotation{po kolei}, czyli tak, by żadnej nie
pominąć i~żadnej nie wypisać więcej niż jeden raz?  Ile ich
jest?  Które liczby ile razy występują w~tych trójkach?
\startanswer
  \math{(1,5,9)}, \math{(1,6,8)}, \math{(2,4,9)},
  \math{(2,5,8)}, \math{(2,6,7)}, \math{(3,4,8)},
  \math{(3,5,7)}, \math{(4,5,6)}.  Każda trójka wypisana jest
  rosnąco i~wypisane są w~porządku leksykograficznym.  Trójek
  jest \math{8}, a~poszczególne liczby występują w~nich:
  \math{5} czterokrotnie, \math{2,4,6,8} trzykrotnie,
  \math{1,3,7,9} dwukrotnie.
\stopanswer
  \stopitem
  \startitem
Jak ułożyć liczby od \math{1} do~\math{9}, żeby było łatwiej
grać, tj. żeby trójki sumujące się do~\math{15} były
\quotation{dobrze widoczne}?
\startanswer
  Ułożenie ich np. w~następującym {\em kwadracie magicznym}
  \starttabulate[|c|c|c|][before={},after={}]
\NC 2 \NC 9 \NC 4 \NC\NR
\NC 7 \NC 5 \NC 3 \NC\NR
\NC 6 \NC 1 \NC 8 \NC\NR
  \stoptabulate
  pokazuje, że rozważana gra jest {\em izomorficzna}
  z~\quotation{kółkiem i~krzyżykiem}.
\stopanswer
  \stopitem
\stopexercises
  \stopsubsubject
\stopsection

\startsection[title={Kółko i~krzyżyk (30~minut)}]
  \startsubsubject[title={Zasady gry}]
Znane każdemu (?).
  \stopsubsubject
  \startsubsubject[title={Zadania}]
\startexercises
  \startitem
Jakie są możliwe wyniki w~grze w~{\em Kółko i~krzyżyk}?
\startanswer
  Wygrana jednego z~graczy lub remis.
\stopanswer
  \stopitem
  \startitem
Narysuj kilka początkowych poziomów drzewa gry.  Narysuj kilka
gałęzi aż do zakończenia gry.
  \stopitem
  \startitem
Oszacuj liczbę możliwych rozgrywek w~{\em Kółko i~krzyżyk}.
\startanswer
  \startitemize[a,packed][stopper