3

My name is Patrick and I am quite new to TeX.

I want to have a command which will leave a colorbox with text at the location used and also store some information not shown at first.

And in addition I want to collect all appearances of that command and its content and generate a table out of it on second compile run to be shown at a predefined location. I am not shy to use lua if this will make it easier. How could I achieve this?

Any help is appreciated very much.

Bernard
  • 271,350
  • 3
    Welcome in this great community. – Sebastiano May 26 '21 at 20:39
  • 1
    In case of considering using the datatool-package and maintaining databases both in memory and as csv-file, the discussion Use LaTeX to produce parts lists? might be of interest. (In order to compile the code of my answer you need a LaTeX-installation which is up to date/with recent expl3.) – Ulrich Diez May 26 '21 at 22:30
  • 1
    In which way shall the order of occurrences of instances of your command in the .tex-input-file correspond to the order in which entries occur in the table in the .pdf-output-file? In other words: Is (whatsoever) sorting needed with the instances of the command collected for forming table-entries? There are different approaches: One could maintain databases for table-creation via datatool-package. One could create one's own \listof...-command via \@starttoc and \addtocontents... One could use makeindex with one's own style, xindy, glossary,... – Ulrich Diez May 26 '21 at 22:32
  • @Ulrich Diez: Thanks for the answers. The occurences will have a score rating. So they will need to be sorted by score. Is lua not one of the possible solutions? I was expecting it to be. But I am in no way sad if not. Writing to csv is great as this would be a feature following the basic implementation. – Patrick Hener May 27 '21 at 05:07
  • @UlrichDiez: I just now read your working example at the other post. Great work! I will try it this way. The example given in the other post works perfectly for me. I will see if I can adapt it to do what I want on my side then. Is there any more direct way to reach you if I would have further questions? Like discord, irc, slack or such? – Patrick Hener May 27 '21 at 06:06
  • @UlrichDiez: I wish you a quick and good recovery then. – Patrick Hener May 27 '21 at 12:45
  • The question is quite abstract as is and thus answers will necessarily have to be abstract as well. Could you make it mor concrete by providing a small but complete (i.e. compilable as is) example showing what kind of content you imagin inputting (just make it a normal colorbox) and explaining which information should be stored and typeset in a table? – schtandard May 29 '21 at 13:43
  • I did manage to get a working solution which fits my needs using datatool and modifying the Code linked in @UlrichDiez answers. I even implemented sorting. Great Code to base my solution on. – Patrick Hener May 29 '21 at 17:37
  • @PatrickHener I am glad to hear that you have been getting along. Since you are new here: It's perfectly fine to post answers to one's own questions here as well... You might consider using your solution to write an answer. For example, it would be interesting to read how you went about implementing the sorting and -eh- what rooms for improvement/optimization you found when looking at my code. (It is not to be doubted that there are quite a few of them.) – Ulrich Diez May 30 '21 at 00:04

0 Answers0