ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] On the use of btx datasets to manage images and plots
@ 2024-11-25 17:02 marco.riggirello.98
  2024-11-25 20:47 ` [NTG-context] " Hans Hagen
  0 siblings, 1 reply; 2+ messages in thread
From: marco.riggirello.98 @ 2024-11-25 17:02 UTC (permalink / raw)
  To: ntg-context

Dear all,
since this is my first post on the mailing lists, let me make a small preamble: after years of LaTeX experience I decided in May to give ConTeXt a try. The journey has been extremely pleasant up to now, so I want to thank all the contributors to this project for making such a great piece of software.

Now, let's dig into the topic:

I'm a PhD student in High Energy Physics (HEP) and my typical work include producing lot of plots and then presenting them in various meetings, comparing my results with existing ones present in the literature.

Tipically, many plots and figures are re-used in different meetings and they might end up in the final thesis. My current workflow is just copying in different directories these (mostly vector) images and copying the caption between different tex sources.

This workflow clearly scales very bad, and I would like to exploit all the goodies of the ConTeXt dataset machinery.

In the Bibliografies manual it is mentioned that one can use datasets to manage images as well [1]. My case however is (slightly) more complicated than the one showed in the manual. What I would like to have is four databases:
- a bibliography dataset;
- an "others' figure" dataset, with all the images I took from the references. This means that in some way in the caption I would like to cite the references included in the bibliography dataset;
- a "own figures" dataset, with the plots I produced with external programs;
- a "metafun figures" dataset, pointing at the metafun code corresponding to some diagram.

In my idea, for each figure dataset the \placebtxrendering should plot the figure with the right label to refer to in the main text and the right caption. (Clearly for the metafun dataset it should not include the pdf of the diagrams but instead compile the metafun code).

In this way, I could create a single ConTeXt project with different products for different presentations, posters and other documents.

Do you think this workflow can be implemented in ConTeXt? If so, how? Is btx the right tool for the job?

I hope I was clear, and sorry if I was not. Thanks in advance for the help.

Cheers

MR

[1] https://www.pragma-ade.nl/general/manuals/mkiv-publications.pdf#%5B%7B%22num%22%3A33%2C%22gen%22%3A0%7D%2C%7B%22name%22%3A%22Fit%22%7D%5D
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [NTG-context] Re: On the use of btx datasets to manage images and plots
  2024-11-25 17:02 [NTG-context] On the use of btx datasets to manage images and plots marco.riggirello.98
@ 2024-11-25 20:47 ` Hans Hagen
  0 siblings, 0 replies; 2+ messages in thread
From: Hans Hagen @ 2024-11-25 20:47 UTC (permalink / raw)
  To: ntg-context

[-- Attachment #1: Type: text/plain, Size: 2970 bytes --]

On 11/25/2024 6:02 PM, marco.riggirello.98@gmail.com wrote:
> Dear all,
> since this is my first post on the mailing lists, let me make a small preamble: after years of LaTeX experience I decided in May to give ConTeXt a try. The journey has been extremely pleasant up to now, so I want to thank all the contributors to this project for making such a great piece of software.
> 
> Now, let's dig into the topic:
> 
> I'm a PhD student in High Energy Physics (HEP) and my typical work include producing lot of plots and then presenting them in various meetings, comparing my results with existing ones present in the literature.
> 
> Tipically, many plots and figures are re-used in different meetings and they might end up in the final thesis. My current workflow is just copying in different directories these (mostly vector) images and copying the caption between different tex sources.
> 
> This workflow clearly scales very bad, and I would like to exploit all the goodies of the ConTeXt dataset machinery.
> 
> In the Bibliografies manual it is mentioned that one can use datasets to manage images as well [1]. My case however is (slightly) more complicated than the one showed in the manual. What I would like to have is four databases:
> - a bibliography dataset;
> - an "others' figure" dataset, with all the images I took from the references. This means that in some way in the caption I would like to cite the references included in the bibliography dataset;

You can add an entry to your bib dataset, say

   image = {foo.pdf}

and access that field

   \externalfigure[\btxflush{image}]

> - a "own figures" dataset, with the plots I produced with external programs;
> - a "metafun figures" dataset, pointing at the metafun code corresponding to some diagram.
> 
> In my idea, for each figure dataset the \placebtxrendering should plot the figure with the right label to refer to in the main text and the right caption. (Clearly for the metafun dataset it should not include the pdf of the diagrams but instead compile the metafun code).
> 
> In this way, I could create a single ConTeXt project with different products for different presentations, posters and other documents.
> 
> Do you think this workflow can be implemented in ConTeXt? If so, how? Is btx the right tool for the job?
> 
> I hope I was clear, and sorry if I was not. Thanks in advance for the help.

There are many ways to do this and as you also need bibliographies it 
makes sense to use these. You can also use lua files instead of bib ones.

Attached is an example of metapost (the sample file will be processed 
automatically when it changes).

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
-----------------------------------------------------------------

[-- Attachment #2: metafun-001-sample-2.tex --]
[-- Type: text/plain, Size: 82 bytes --]

\startMPpage
    fill fullcircle scaled 4cm withcolor "darkgreen";
\stopMPpage

[-- Attachment #3: metafun-001.tex --]
[-- Type: text/plain, Size: 1220 bytes --]

\starttext

\startbuffer[samples]
@IMAGE {sample1,
    title       = "sample-1",
    author      = "My Self",
    mpcode      = {fill fullcircle scaled 4cm withcolor "darkblue";}
}

@IMAGE {sample2,
    title       = "sample-2",
    author      = "My Self",
    mpfile      = "metafun-001-sample-2.tex"
}
\stopbuffer

\definebtxdataset
  [samples]

\usebtxdataset
  [samples]
  [samples.buffer]

\definebtx
  [samples]
  [default=,
   specification=samples]

\definebtx
  [samples:list:image]
  [samples:list]

\definebtxrendering
  [samples]
  [specification=samples,
   group=samples,
   dataset=samples,
   method=dataset,
   numbering=no,
   criterium=all]

\startsetups btx:samples:list:image
  \tbox \bgroup
    \bTABLE[offset=1ex]
      \bTR
        \bTD[ny=4]
          \dontleavehmode
          \doifelsesomething{\btxflush{mpfile}} {
            \externalfigure[\btxflush{mpfile}]
          } {
            \MPcode{
                \btxflush{mpcode}
            }
          }
        \eTD
        \bTD
            \btxflush{title}
        \eTD
      \eTR
    \eTABLE
  \egroup
\stopsetups

\placebtxrendering[samples][criterium=all]

\stoptext

[-- Attachment #4: Type: text/plain, Size: 511 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-11-25 20:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-25 17:02 [NTG-context] On the use of btx datasets to manage images and plots marco.riggirello.98
2024-11-25 20:47 ` [NTG-context] " Hans Hagen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).